Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Post code

Name: Anonymous 2011-10-06 9:06

Any code you work with right now, and we'll criticize it(or not).

Name: Anonymous 2011-10-06 9:14

print ("print");

Name: Anonymous 2011-10-06 9:14

#define ngetext(string) strrchr(string,'.')
#define getext(string) ngetext(string)?ngetext(string):".???"
#define pos1(pos1_int1) (1<<(pos1_int1))
#define getbit(getbit_int,getbit_pos)    ((getbit_int&(pos1(getbit_pos)))>>getbit_pos)
#define bitchar(bitchar_bit)    (48|bitchar_bit)
#define getbitc(getbitc_int,getbitc_pos)  bitchar(getbit(getbitc_int,getbitc_pos))
#define digit2_byte(digit2_dig) ((digit2_dig)&0xF)
#define ten_e(ten_ex) (u8)(pow(10,ten_ex))
#define dec2byte(array_dec,dec_amult)  ((digit2_byte(array_dec))*ten_e(dec_amult))
#define deccar(deccar_str,deccar_ind,deccar_mul) dec2byte(deccar_str[deccar_ind+deccar_mul],deccar_mul)
#define declsum(declo18_str,declo18_ind) (deccar(declo18_str,declo18_ind,0)+deccar(declo18_str,declo18_ind,1)+deccar(declo18_str,declo18_ind,2)+deccar(declo18_str,declo18_ind,3)+deccar(declo18_str,declo18_ind,4)+deccar(declo18_str,declo18_ind,5)+deccar(declo18_str,declo18_ind,6)+deccar(declo18_str,declo18_ind,7)+deccar(declo18_str,declo18_ind,8)+deccar(declo18_str,declo18_ind,9)+deccar(declo18_str,declo18_ind,10)+deccar(declo18_str,declo18_ind,11)+deccar(declo18_str,declo18_ind,12)+deccar(declo18_str,declo18_ind,13)+deccar(declo18_str,declo18_ind,14)+deccar(declo18_str,declo18_ind,15)+deccar(declo18_str,declo18_ind,16)+deccar(declo18_str,declo18_ind,17))
//.dec2byte((dec2quads_String)[(dec2quads_Istart)+0],0)
//10*((dec2quads_String)[(dec2quads_Istart)+1]-48)
/* get
a^-1 = 1/a;     (-1)*a = -a.
    a^{m + n} = a^m * a^n
    a^{m - n} ={a^m}/{a^n}
    (a^m)^n = a^{m* n}
    (a * b)^n = a^n * b^n
*/
#define dec2quads(dec2quads_String,dec2quads_Slen,dec2quads_Retq,dec2quads_Istart) ;u8* (dec2quads_Retq)=malloc((((dec2quads_Slen)/18)+1)*8);for((dec2quads_Istart)=0;(dec2quads_Istart)<(dec2quads_Slen);(dec2quads_Istart)+=18){(dec2quads_Retq)[(dec2quads_Istart)/18]=declsum(dec2quads_Retq,dec2quads_Istart);}
// s/18 dec=x+1 8 bytes
char* merge(char* str1,const char* str2){
char* res=malloc(strlen(str1)+strlen(str2)+1);
strcpy(res,str1);strcpy(res+strlen(str1),str2);return res;}
s8 stoquad(char* str){s8 res;sscanf(str,"%lli",&res);return res;}
u8 stouquad (char* str){u8 res;sscanf(str,"%llu",&res);return res;}
//char* slice(char* str,u8 len){}
u1* bytetodec(u1* str,u4 srclen){
  /*SLow&horrible conversion of byte into decimal compatible arrays 000*/
u1* res=malloc(3*(srclen+1));
u4 i;for(i=0;i<srclen;i++){
if(str[i]<10){//decode:first byte from end by3 byte groups.
res[i*3]='1';
res[(i*3)+1]='0';
res[(i*3)+2]=str[i]+48;continue;}
if(str[i]<100){res[i*3]='1';
res[(i*3)+1]=(str[i]/10)+48;//num+48
res[(i*3)+2]=(str[i]%10)+48;continue;}
if(str[i]<200){res[i*3]='2';
res[(i*3)+1]=((str[i]-100)/10)+48;
res[(i*3)+2]=(str[i]%10)+48;continue;}
res[i*3]='3';
res[(i*3)+1]=((str[i]-200)/10)+48;
res[(i*3)+2]=(str[i]%10)+48;
;}
;
return res;
}


u1* dectobyte(u1* dec,u8 size){
u8 outsize=size/3;
u1* res=malloc(size/3);
for(u4 i=0;i<outsize;i++){
res[i]=((dec[i*3]-49)*100)+((dec[(i*3)+1]-48)*10)+(dec[(i*3)+2]-48);};
return res;}
//#define bbits(b)  (b&0x80?'1':'0')##(byte & 0x40 ? 1 : 0)##(byte & 0x20 ? 1 : 0)##(byte & 0x10 ? 1 : 0)##(byte & 0x08 ? 1 : 0)##(byte & 0x04 ? 1 : 0)##(byte & 0x02 ? 1 : 0)##(byte & 0x01 ? 1 : 0)

Name: Anonymous 2011-10-06 9:33

Working on a python irc script that sends out streams that are live to users who trigger it.



def check_online_own3d(streamID):
    f = urllib.urlopen("http://api.own3d.tv/liveCheck.php?live_id=" + streamID)
    liveLink = f.read()
    f.close()
   
    if '<isLive>true</isLive>' in liveLink:
        ready = 1
    else:
        ready = 0
  
    return ready


def on_text(word, word_eol, userdata):
    destination = xchat.get_context()
    triggernick = word[0]
    trigger = re.split(' ', word[1].lower())
   
    if trigger[0] == '!stream' and trigger[1] == 'list':
        strStreamListOwn3d = 'none'
        liveStreamListOwn3d = []
        inStreamListOwn3d = []
        #own3d
        loop = 0
        infile = open(os.path.join("C:\\Program Files\\XChat-WDK\\plugins\\streamFiles", "streamListOwn3d.txt"))
        findingLine = infile.readlines()
        infile.close()
        for i in findingLine:
            streamID = findingLine[loop].strip()
            if check_online_own3d(streamID) == 1:
                inStreamListOwn3d.append(streamID)
            loop += 1
       
       
        if '40553' in inStreamListOwn3d:
                 liveStreamListOwn3d.append('http://www.own3d.tv/live/40553/ComeWithMe')

        strStreamListOwn3d = str(liveStreamListOwn3d)
        
        if liveStreamListOwn3d == []:
            destination.command("say " + triggernick + ": No live streams currently online.")
        else:
            destination.command("say " + triggernick + ": Live Streams are " + strStreamListOwn3d)
       
       
        return xchat.EAT_NONE


xchat.hook_print('Channel Message', on_text)


Would appearciate help to optimize the bit that checks if it is online. Right now it takes about 10 secs to reply with the live links.

Name: Anonymous 2011-10-06 10:33

>>3
>dec2quads(
H.P.LOVECRAFT QUALITY

Name: Anonymous 2011-10-06 10:59

#if defined (__GNUC__)
#define VMCALL __attribute__((hot, fastcall))
#elif defined (MSVC)
#define VMCALL __fastcall
#else
#define VMCALL
#endif

#define VMDECL(name) static int VMCALL name(unsigned int op, thread* t)

Name: Anonymous 2011-10-06 11:09

[code]Sub unwrap()

Function trunc(kc, n)
k1 = kc
trunc = 0
While (k1 > n)
k1 = k1 - n
trunc = trunc + 1
Wend
End Function
   
Dim xx(311, 264)
nrow = 88: ncol = 35: nwraps = 2: nwrapcols = 20
sname1 = "wrapped": sname2 = "unwrapped":

Sheets(sname2).Select: Sheets(sname2).Cells.Select
Selection.ClearContents: Selection.Borders.LineStyle = xlNone

For kkrow = 1 To nrow: Cells(kkrow + 32, 2) = kkrow: Next kkrow
For kkcol = 1 To ncol: Cells(32, kkcol + 2) = kkcol: Next kkcol

For kkcol = 1 To ncol
Cells(33, kkcol + 2).Borders(xlEdgeTop).LineStyle = XlLineStyle.xlDouble
Cells(nrow + 32, kkcol + 2).Borders(xlEdgeBottom).LineStyle = XlLineStyle.xlDouble
Next kkcol
For kkrow = 1 To nrow
Cells(kkrow + 32, 3).Borders(xlEdgeLeft).LineStyle = XlLineStyle.xlDouble
Cells(kkrow + 32, ncol + 2).Borders(xlEdgeRight).LineStyle = XlLineStyle.xlDouble
Next kkrow

For kkrow = 1 To nrow: For kkcol = 1 To ncol
Sheets(sname1).Select
kkr1 = nwraps * (kkrow - 1) + trunc(kkcol, nwrapcols) + 1
kkc1 = kkcol - nwrapcols * trunc(kkcol, nwrapcols)
xx(kkrow, kkcol) = Cells(kkr1, kkc1)
Sheets(sname2).Select
Cells(kkrow + 32, kkcol + 2) = xx(kkrow, kkcol)
Next kkcol: Next kkrow

End Sub

Name: Anonymous 2011-10-06 12:49


#!/bin/bash
root=`echo ~`
watched_folder="$root/downloads/torrents/links"

if [ ! 1 -eq $# ]; then
        echo This script needs one argument
        exit 1
fi

file="$root/scripts/torrents/$1"

if [ ! -f "$file" ]; then
# History file does not exist yet
        touch "$file"
        echo Created a history file
fi

url="http://api.dailytvtorrents.org/1.0/torrent.getLatest?show_name=$1&just_link=yes"
link=`curl -s "$url"`
old_link=`cat "$file"`

# Change this by checking if .torrent file already there
if [ ! "$old_link" = "$link" ]; then
# Last download of the torrent != current try

# Do we need to start deluged?
        ps=`pgrep deluged`
        if [ "$ps" = "" ]; then
                sudo /etc/rc.d/deluged start
        fi

        cd "$watched_folder"
        curl -s -O "$link"

        echo "Got one"
# We remember it
    echo $link > $file
else
        echo "Nothing new"
fi


Coupled with some cron tasks = automated download of the series I watch.

Name: Anonymous 2011-10-06 12:52

>>4

if ...:
    ready = 1
else:
    ready = 0
  
return ready


why not "return ...". What you're doing is just ugly and Pythonic

Name: Anonymous 2011-10-06 13:05


#include "hurrdurr.h"

hurr
durr
herp
derp //derp

Name: Anonymous 2011-10-06 13:07

    Private Sub Process(ByVal ID As Byte)
        Dim Ev As Reflection.EventInfo
        Dim EvDel As System.Delegate
        Dim Args As New Collections.List(Of Object)
        Try
            Ev = PacketEvents(ID)
        Catch Err As Collections.KeyNotFoundException
            Throw New UnknownPacketException(ID)
        End Try
        EvDel = CType(GetType(Client).GetField(Ev.Name + "Event", Reflection.BindingFlags.Instance Or Reflection.BindingFlags.NonPublic).GetValue(Me), System.Delegate)
        For Each Arg As Reflection.ParameterInfo In Ev.EventHandlerType.GetMethod("Invoke").GetParameters()
            Dim Type As System.Type = Arg.ParameterType
            If Type Is GetType(Client) Then
                Args.Add(Me)
            ElseIf Type Is GetType(Boolean) Then
                Args.Add(Stream.ReadByte() <> 0)
            ElseIf Type Is GetType(Byte) Then
                Args.Add(Stream.ReadByte())
            ElseIf Type Is GetType(Short) Then
                Args.Add(Stream.ReadShort())
            ElseIf Type Is GetType(Integer) Then
                Args.Add(Stream.ReadInteger())
            ElseIf Type Is GetType(Long) Then
                Args.Add(Stream.ReadLong())
            ElseIf Type Is GetType(Single) Then
                Args.Add(Stream.ReadSingle())
            ElseIf Type Is GetType(Double) Then
                Args.Add(Stream.ReadDouble())
            ElseIf Type Is GetType(String) Then
                Args.Add(Stream.ReadString())
            Else
                Throw New System.ArgumentException
            End If
            For Each Attr As PacketTerminatorAttribute In Arg.GetCustomAttributes(GetType(PacketTerminatorAttribute), False)
                If Attr.Value = CLng(Args(Args.Count - 1)) Then
                    GoTo EscapeOuterFor
                End If
            Next
        Next
EscapeOuterFor:
        If EvDel IsNot Nothing Then
            EvDel.DynamicInvoke(Args.ToArray())
        ElseIf (Ev.GetAddMethod().Attributes And Reflection.MethodAttributes.Public) <> 0 Then
            RaiseEvent ReceivedUnhandled(Me, ID, Ev.Name)
        End If
        'System.Console.Out.Write("{0}:", ID)
        'For Each Arg As Object In Args
        'System.Console.Out.Write(" {0}", Arg)
        'Next
        'System.Console.Out.WriteLine()
    End Sub

Name: Anonymous 2011-10-06 13:13

>>10
imperative AIDS

Name: Anonymous 2011-10-06 13:16

#!/usr/bin/bash
cat /etc/passwd | sed -n '2,${p;n;}' | cut -d: -f1 | rev | sort -rd | awk "NR>=$MY_LINE1 && NR<=$MY_LINE2" | tr '\n' ',' | sed "s/,/, /g" | sed "s/, $/./" | tr -d '\n'

Name: Anonymous 2011-10-06 15:07


#ifdef _MSC_VER
#pragma warning( disable : 4820  )
#pragma warning( disable : 4514  )
#endif

#include <SDL/SDL.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#include <fcntl.h>

//#define WIN32_LEAN_AND_MEAN
#include <windows.h>

#define MULTISAND_DEBUG

#include "defines.h"
#include "powder.h"
#include "menu.h"
#include "graphics.h"

//#include <getopt.h>


int main(int argc, char** argv)
{
    SDL_Event      MEvent;

    int    MouseX;
    int    MouseY;
    int    MouseSt;
    bool   UserQuit   = false;
    bool   brushchg   = false;
    ptype* pselection = &ptable[1];

    InitSDL("Multisand");

    if(init_particles() != 0)
    {
        puts("Error: Not enough memory!");
        exit(1);
    }

    while(!UserQuit)
    {
        //Clear menu area
        memset(menmem, 0, menmemsz);

        // Get mouse state and position
        while(SDL_PollEvent(&MEvent))
        {
            if(MEvent.type == SDL_QUIT)
            {
                UserQuit = true;
            }
        }

        MouseSt = SDL_GetMouseState(&MouseX, &MouseY);

        if(MouseSt & SDL_BUTTON(4) && brushsz < 7)
        {
            puts("Text");
            ++brushsz;
        }

        if(MouseSt & SDL_BUTTON(5) && brushsz > 0)
            --brushsz;


        //Is this optimized? TODO: Fix this, but later for sure
        if(update_menu(MouseX, MouseY, &pselection, MouseSt) & SDL_BUTTON(1) && MouseY < MENU_LOWEST_POINT)
        {
            brush_fill(MouseX, MouseY, pselection->ID);
            //vidmem[(XRES_BIT(MouseY)) + MouseX] = pselection->color;
        }
       // pmap[XRES_BIT(20) + 6] = pmap[XRES_BIT(20) + 7] = pmap[XRES_BIT(20) + 8] = 0xFF0000;
        //memcpy(vidmem, pmap, sizeof(pmap));

        SDL_UpdateRect(Video, 0, 0, 0, 0);
        SDL_Delay((Uint32)1);
    }

    SDL_Quit();
    return 0;
}

Name: Anonymous 2011-10-06 15:31


// deinterlace the 4 chunks from one imageData blob in one pass
// see appendix e of gif spec
//
// ideas: canvasize first, then deinterlace...
// and do canvas drawImage calls or putImageData calls to move the rows around
GIF.render.deinterlacePixels = function(oldpixels, w, h){

  var pixels = new Uint8Array(oldpixels.length);
  var stripes2 = Math.ceil(h/8); // the row where the 2nd interlaced chunk starts
  var stripes3 = Math.ceil(h/4);
  var stripes4 = Math.ceil(h/2);

  // pixels[(w*y) +x] = oldpixels[(w*y) +x] <- base calculation

  for(var y=0; y<h; y++){
    var interlacedRowOffset;
    var rowOffset = w * y;
    if (y % 8 === 0)
      interlacedRowOffset = w* (y/8);
    else if ((y + 4) % 8 === 0)
      interlacedRowOffset = w* ((y-4)/8+stripes2);
    else if (y % 2 === 0)
      interlacedRowOffset = w* ((y-2)/4+stripes3);
    else
      interlacedRowOffset = w* ((y-1)/2+stripes4);
    for(var x=0; x<w; x++)
      pixels[rowOffset+x] = oldpixels[interlacedRowOffset+x];
  }

  return pixels;
};

Name: Anonymous 2011-10-06 15:54

>>8
>root=`echo ~`
Why do this instead of using $HOME when needed?

Name: Anonymous 2011-10-06 16:12


#!/bin/bash

while true;
do
  runhaskell $1 &
  inotifywait -q -q -e modify $1
  killall ghc
done

Name: noob here 2011-10-06 16:21

How do you post so it's formatted correctly?

Name: Anonymous 2011-10-06 16:52

>>18

<paste code>

Name: Anonymous 2011-10-06 16:56


echo "SELECT key, concat('\'',val,'\'') FROM some_table" |  \
mysql -A -u user -p db01 | \
sed 's/^/SET /g' | \
redis-cli > /dev/null

Name: Anonymous 2011-10-06 17:00

>>18
You need to manually format it with BBCode. [ color=blue ]code[ /color ] (remove the spaces), etc.

Name: Anonymous 2011-10-06 17:35

Currently working on a mandelbrot set renderer and putting it into a screen saver.


No idea if this will actually format it correctly.
<paste code>
void Mandelbrot::Draw(Graphics* graphics)
{
    double minRe;
    double maxRe;
    double minIm;
    double maxIm;

    switch(_centerPosition)
    {
        // the image center effects where the image is zoomed into.
    case 6:
        // top left
         minRe = _x;
         maxRe = _x + _width;
         minIm = _y - _height;//_y + (_width-_x) * _imageBounds->Height / _imageBounds->Width;
         maxIm = minIm +(maxRe-minRe)*_imageBounds->Height / _imageBounds->Width;
        break;
    case 7:
        // top middle
         minRe = _x - _width * 0.5;
         maxRe = _x + _width * 0.5;
         minIm = _y - _height;
         maxIm = minIm +(maxRe-minRe)*_imageBounds->Height / _imageBounds->Width;
        break;
    case 8:
        // top right
         minRe = _x - _width;
         maxRe = _x;
         minIm = _y - _height;
         maxIm = minIm +(maxRe-minRe)*_imageBounds->Height / _imageBounds->Width;
        break;
    case 3:
        // middle left
         minRe = _x;
         maxRe = _x + _width;
         minIm = _y - _height * 0.5;
         maxIm = minIm +(maxRe-minRe)*_imageBounds->Height / _imageBounds->Width;
        break;
    case 4:
        // middle middle
         minRe = _x - _width * 0.5;
         maxRe = _x + _width * 0.5;
         minIm = _y - _height * 0.5;
         maxIm = minIm +(maxRe-minRe)*_imageBounds->Height / _imageBounds->Width;
        break;
    case 5:
        // middle right
         minRe = _x - _width;
         maxRe = _x;
         minIm = _y - _height * 0.5;
         maxIm = minIm +(maxRe-minRe)*_imageBounds->Height / _imageBounds->Width;
        break;
    case 0:
        // bottom left
         minRe = _x;
         maxRe = _x + _width;
         minIm = _y;
         maxIm = minIm +(maxRe-minRe)*_imageBounds->Height / _imageBounds->Width;
        break;
    case 1:
        // bottom middle
         minRe = _x - _width * 0.5;
         maxRe = _x + _width * 0.5;
         minIm = _y;
         maxIm = minIm +(maxRe-minRe)*_imageBounds->Height / _imageBounds->Width;
        break;
   
    default:
        // bottem right
         minRe = _x - _width;
         maxRe = _x;
         minIm = _y;
         maxIm = minIm +(maxRe-minRe)*_imageBounds->Height / _imageBounds->Width;
        break;
    }

    // local position data
    int imageHeight = (int)_imageBounds->Height;
    int imageWidth  = (int)_imageBounds->Width;
    unsigned maxIterations = GetIterations();
   
    BitmapData bitmapData;
    Bitmap bitmap(imageWidth, imageHeight);
    bitmap.LockBits(&Rect(0, 0, imageWidth, imageHeight), ImageLockModeWrite, PixelFormat32bppARGB, &bitmapData);
    UINT* pixel = (UINT*)bitmapData.Scan0;
    int stride = bitmapData.Stride / 4;

    double Re_factor = (maxRe-minRe)/(imageWidth-1);
    double Im_factor = (maxIm-minIm)/(imageHeight-1);

#pragma omp parallel for
    for(int y = 0; y < imageHeight; ++y)
    {
        double c_im = maxIm - y*Im_factor;

        for(int x=0; x < imageWidth; ++x)
        {
            double c_re = minRe + x*Re_factor;
            double Z_re = c_re, Z_im = c_im;
           
            double Z_re2 = Z_re * Z_re;
            double Z_im2 = Z_im * Z_im;
            unsigned n;
            for(n = 0; n < maxIterations; ++n)
            {
                Z_re2 = Z_re * Z_re;
                Z_im2 = Z_im * Z_im;

                if(Z_re2 + Z_im2 > 4)
                {
                    break;
                }

                Z_im = 2 * Z_re * Z_im + c_im;
                Z_re = Z_re2 - Z_im2 + c_re;
            }
           
            //if(c_re > 0)
                pixel[y * stride + x] = Color(n % 256, (byte)(255*((float)n / (float)maxIterations)),0).ToCOLORREF() + 0xff000000;
            //else
            //    pixel[y * stride + x] = 0xfffffffff;
           
            //if(n == maxIterations)
            //    pixel[y * stride + x] = 0xfffffffff;
        }
    }

    bitmap.UnlockBits(&bitmapData);
    graphics->DrawImage(&bitmap, *_imageBounds);
   
   
   
    std::wstringstream text;
    text << "Iterations: " << _maxIterations << " Current Iterations: " << _currentIterations
        << "\nX: " << _x << "\nY: " << _y  << "\nWidth: " << _width << " Height: "
        << _height <<"\nDtime: " << _outputText;
   
    std::wstring wstr = text.str();
    DrawString(graphics, wstr.c_str(), PointF(10,10));
}

Name: Anonymous 2011-10-06 17:37


  char day_name[7][10];
  int i;

  for (i = 0; i < 7; i++)
  {
    switch(i)
    {
      case 0: strcpy(day_name[i], "Sunday");
      case 1: strcpy(day_name[i], "Monday");
      case 2: strcpy(day_name[i], "Tuesday");
      case 3: strcpy(day_name[i], "Wednesday");
      case 4: strcpy(day_name[i], "Thursday");
      case 5: strcpy(day_name[i], "Friday");
      case 6: strcpy(day_name[i], "Saturday");
    }
  }


>>18
Don't listen to these trolls, use ... tags.

Name: george 2011-10-06 17:41

>>22
use recursion and threads it
should reduce sizeof( code );
if( cpu_cores > 1 ){
 (theoretically )speed_up( things );
}
i dont wanna sound like a dick by all accounts

Name: jc 2011-10-06 17:44

void R_RenderView( viewParms_t *parms ) {
    int firstDrawSurf;

    if ( parms->viewportWidth <= 0 || parms->viewportHeight <= 0 ) {
        return;
    }

    // Ridah, purge media that were left over from the last level
    if ( r_cache->integer ) {
        extern void R_PurgeBackupImages( int purgeCount );
        static int lastTime;

        if ( ( lastTime > tr.refdef.time ) || ( lastTime < ( tr.refdef.time - 200 ) ) ) {
            R_FreeImageBuffer();    // clear all image buffers
            R_PurgeShaders( 10 );
            R_PurgeBackupImages( 1 );
            R_PurgeModels( 1 );
            lastTime = tr.refdef.time;
        }
    }
    // done.

    tr.viewCount++;

    tr.viewParms = *parms;
    tr.viewParms.frameSceneNum = tr.frameSceneNum;
    tr.viewParms.frameCount = tr.frameCount;

    firstDrawSurf = tr.refdef.numDrawSurfs;

    tr.viewCount++;

    // set viewParms.world
    R_RotateForViewer();

    R_SetupFrustum();

    R_GenerateDrawSurfs();

    R_SortDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf );

    // draw main system development information (surface outlines, etc)
    R_FogOff();
    R_DebugGraphics();
    R_FogOn();

}

working on too late too late
bug fixes

Name: Anonymous 2011-10-06 17:45

>>23
Your code is bad. Use litterals:
char day_name[7][10] = {
  "Sunday",
  "Monday",
  "Tuesday",
  "Wednesday",
  "Thursday",
  "Friday",
  "Saturday"
};

Name: Anonymous 2011-10-06 17:46

>>24
I think that's all that OpenML does, it's not much more efficient on a 4 core machine.

I want to divide the bitmap into the number of cores and render each part on a separate core. There should be more cache hits that way rather then having it interlaced across the cores.

Name: Anonymous 2011-10-06 17:46

>>26
Sunday is the last day of the week and that's why you call Saturday and Sunday a weekend you stupid American faggot

Name: Anonymous 2011-10-06 17:47

>>28
I agree with you, but tell that to >>23.

Name: Anonymous 2011-10-06 17:52

>>23 dont listen to any of those stupid fucks
use cowboy codez

void name_that_day( int i )
{
 char req[ 1024 ];
 sprintf(req,"http://namethatday?int_to_char.php?%s", i);
 system( req );
 system("pause")//give yourself inf time to read it
}

Name: Anonymous 2011-10-06 18:05

>>26
you are wasting space on the days that are less than 9 chars

Name: Anonymous 2011-10-06 18:09

>>31
Yes, 13 * sizeof(char). If I had used pointers that'd be 7 * sizeof(char*) which is bigger on most architectures. The last alternative is using a Win32-like multistring but then retrieval would be slower.

Name: george@hotmail.com 2011-10-06 18:14

>>31
>>32
its called added protection assholes
new tech i ve been developing for the last 5 months

Name: Anonymous 2011-10-06 18:39

>>28
Do you put both of your bookends on the same side of your books? probably

>>26
Would it have helped if I had written it like this?

  char day_name[7][10];
  int i;

  for (i = 0; i < 7; i++)
  {
    switch(i)
    {
      case 0: strcpy(day_name[i], "Sunday");
      case 1: strcpy(day_name[i], "Monday");
      case 2: strcpy(day_name[i], "Tuesday");
      case 3: strcpy(day_name[i], "Wednesday");
      case 4: strcpy(day_name[i], "Thursday");
      case 5: strcpy(day_name[i], "Friday");
      case 6: strcpy(day_name[i], "Trollday");
    }
  }

Name: 11 2011-10-06 21:40

Yeah, that's right. My code is so great, you're all speechless.

Name: Anonymous 2011-10-06 22:04


#!/bin/sh
echo hello world
exit 24

Name: Anonymous 2011-10-06 22:34

Sub unwrap()

Function trunc(kc, n)
k1 = kc
trunc = 0
While (k1 > n)
k1 = k1 - n
trunc = trunc + 1
Wend
End Function
  
Dim xx(311, 264)
nrow = 88: ncol = 35: nwraps = 2: nwrapcols = 20
sname1 = "wrapped": sname2 = "unwrapped":

Sheets(sname2).Select: Sheets(sname2).Cells.Select
Selection.ClearContents: Selection.Borders.LineStyle = xlNone

For kkrow = 1 To nrow: Cells(kkrow + 32, 2) = kkrow: Next kkrow
For kkcol = 1 To ncol: Cells(32, kkcol + 2) = kkcol: Next kkcol

For kkcol = 1 To ncol
Cells(33, kkcol + 2).Borders(xlEdgeTop).LineStyle = XlLineStyle.xlDouble
Cells(nrow + 32, kkcol + 2).Borders(xlEdgeBottom).LineStyle = XlLineStyle.xlDouble
Next kkcol
For kkrow = 1 To nrow
Cells(kkrow + 32, 3).Borders(xlEdgeLeft).LineStyle = XlLineStyle.xlDouble
Cells(kkrow + 32, ncol + 2).Borders(xlEdgeRight).LineStyle = XlLineStyle.xlDouble
Next kkrow

For kkrow = 1 To nrow: For kkcol = 1 To ncol
Sheets(sname1).Select
kkr1 = nwraps * (kkrow - 1) + trunc(kkcol, nwrapcols) + 1
kkc1 = kkcol - nwrapcols * trunc(kkcol, nwrapcols)
xx(kkrow, kkcol) = Cells(kkr1, kkc1)
Sheets(sname2).Select
Cells(kkrow + 32, kkcol + 2) = xx(kkrow, kkcol)
Next kkcol: Next kkrow

End Sub

Name: Anonymous 2011-10-06 22:54


#!/bin/bash
echo "Segmentation fault" >&2
exit 139
# problem, lunix?

Name: Anonymous 2011-10-06 23:08

gcc code.c

segmentation fault

Name: Anonymous 2011-10-06 23:51

>>8
echo without quotes
laughing_hebrews.php

Name: HAXUS THE SAGE 2011-10-07 0:28

Not /prog/ related. GTFO!

Name: Anonymous 2011-10-07 0:52


sub addr-parse( Str $str, :$cidr ) {
    my @chunks = $str.comb: /\d+/;
    my $mask = @chunks[4] // 0;
    my $base = [+] @chunks[^4] Z+< 24, 16, 8, 0;
   
    return ( $base, $mask ) if $cidr;
    return $base;
}

sub cidr-str( Int $base, Int $mask ) {
    my $str = (
        for 24, 16, 8, 0 -> $s { ( $base +> $s ) +& 0xff; }
    ).join('.') ~ '/' ~ $mask;
   
    return $str;
}

Name: Anonymous 2011-10-07 2:21

I'm fucking amazed people actually use Basic.

Name: Anonymous 2011-10-07 3:35

lololol I'm C# and i am create object whilly nilly and i don't have to worry about cleaning it up again.

new
new
new
new
new

Thank you GC <3 You've saved me a lot of time and effort whilst I've been writing this 3D game engine. Daymn this thing has shadows, physics and al sorts of other shit. Imagine if I wrote this in C++, it would have taken aaaaages, best but is I can declare a portion of code as "Unsafe" and still use pointers.

I could have written it in lisp of course, but that would by far to slow for a proper games engine, that shit would be unusable.

Name: Anonymous 2011-10-07 4:06

>>44
I'm not sure if you're trying to troll users of garbagecollected languages, or just veeeeery butthurt

Name: Anonymous 2011-10-07 4:14

>>45
Not trolling, I've worked with C++ to make game engines and software renderers. C# makes it a lot easier on memory clean up thanks to the GC. The major downside being that the code is locked to windows platforms.

I guess Java gets around the platform issue, but Java sucks around 10 cocks a day.

Name: Anonymous 2011-10-07 4:17

>>34
I'm not sure whether you're trolling, but you don't need to do a loop. A switch without a default clause inside a loop for anything else than a finite-state machine or event handler is inefficient.
Also, I just realized that your code lacks break instructions.

Name: Anonymous 2011-10-07 4:22

>>46
How about Common Lisp?

Name: Anonymous 2011-10-07 4:41

Name: Anonymous 2011-10-07 5:07

>>49
Geçenlerde okuduğum ve gerçekten çok
It's in german.

Name: Anonymous 2011-10-07 6:07

>>50
he thinks turkish is german

laughing_bratwürste.jpg

Name: Anonymous 2011-10-07 7:31

Sorry, it's not English.

Option Explicit

const w = 3
const h = 3
const tyhja = "_"
redim TheGame(w,h)
dim fun
dim i, j
dim inp, x, y
dim view
dim merkki
dim winner
dim random_ok

view = ""
winner = "0"
fun = True
For i = 0 To w -1
  For j = 0 To h-1
    TheGame(i,j) = tyhja
  Next
Next
Randomize

msgbox "Super X0 !!!!!!!!!!!!!!!!!!111111oneoneelevenone" & vbCr & vbCr & "Paina OK, tampio"

Do While fun
  view = ""
  For i = 0 To h-1
    For j = 0 To w-1
      merkki = TheGame(j,i)
      view = view & merkki
      if merkki <> tyhja Then
        If i <> 0 and i <> h-1 Then
          if TheGame(j, i-1) = merkki and TheGame(j, i+1) = merkki Then
            winner = merkki
            fun = False
          End If
        End If
        If j <> 0 and j <> w-1 Then
          if TheGame(j-1, i) = merkki and TheGame(j+1, i) = merkki Then
            winner = merkki
            fun = False
          End If
        End If
        If j <> 0 and i <> 0 and i <> h-1 and j <> w-1 Then
          If (TheGame(j-1, i-1) = merkki and TheGame(j+1, i+1) = merkki) _
          Or (TheGame(j+1, i-1) = merkki and TheGame(j-1, i+1) = merkki) Then
          winner = merkki
          fun = False
        End If
      End If
    end if
  Next
  view = view & vbCr
Next
if fun then
  inp = InputBox(view)
  x = CInt(mid(inp, 1, 1)) - 1
  y = CInt(mid(inp, 2, 1)) - 1

  if TheGame(x,y) = tyhja then
    TheGame(x,y) = "X"
  end If

  random_ok = False
  do while not random_ok
    x = w * Rnd
    y = h * Rnd
    if TheGame(x, y) <> "0" Then
      TheGame(x,y) = "0"
      random_ok = True
    End If
  loop
end if
Loop

MsgBox winner & " voitti..."

Name: Anonymous 2011-10-07 7:33

I'm frightened to see some people actually do use BASIC.

Name: Anonymous 2011-10-07 7:36

>>53
Hey, that's vbs. I didn't have any compiler for that computer and I was bored.

Name: Anonymous 2011-10-07 9:40

Hey /frog/

Please criticize my C++ 2D-vector class. Implementation in header file for inlining.


#ifndef VEC2_H_INCLUDED_
#define VEC2_H_INCLUDED_

#include <cmath>

/**
 * Represents 2D vector.
 */
class Vec2
{
public:
    float x, y;
    /** Construct vector with given values */
    Vec2(float _x, float _y) : x(_x), y(_y) {}
    /** Create uninitialized vector */
    Vec2(){}
    /** Construct scaled copy */
    Vec2(const Vec2& v, float scale_ratio) {
        *this = v;
        scale(scale_ratio);
    }
    Vec2& operator += (const Vec2& v) {
        x += v.x;
        y += v.y;
        return *this;
    }
    Vec2& operator -= (const Vec2& v) {
        x -= v.x;
        y -= v.y;
        return *this;
    }
    Vec2 operator + (const Vec2& v) const {
        return Vec2(x+v.x, y+v.y);
    }
    Vec2 operator - (const Vec2& v) const {
        return Vec2(x-v.x, y-v.y);
    }
    /** multiply with scalar */
    void scale(float m) {
        x *= m;
        y *= m;
    }
    /** Dot product */
    float dot(const Vec2& v) const {
        return x * v.x + y * v.y;
    }
    /** Cross product */
    Vec2 cross(const Vec2& v) const {
        return Vec2(y - v.y, x - v.y);
    }
    float length() const {
        return std::sqrt(length2());
    }
    /** Square of length */
    float length2() const {
        return x*x + y*y;
    }
    /** Distance to other vector */
    float distance(const Vec2& v) const {
        return std::sqrt(distance2(v));
    }
    /** Distance to other vector squared */
    float distance2(const Vec2& v) const {
        float dx = x - v.x;
        float dy = y - v.y;
        return dx*dx + dy*dy;
    }
    /** Normalize vector. The length after normalization is 1 */
    void normalize() {
        scale(1 / length());
    }
    /** set new value */
    void set(float _x, float _y) {
        x = _x;
        y = _y;
    }
    /** Rotate vector by angle radians */
    void rotate(float angle) {
        float len = length();
        angle += atan2(y, x);
        x = cos(angle) * len;
        y = sin(angle) * len;
    }
    /** Create vector projection: u projected to *this */
    Vec2 projection(const Vec2& u) const {
        Vec2 p = *this;
        float len = length();
        p.scale(this->dot(u) / (len * len));
        return p;
    }
};

#endif

Name: Anonymous 2011-10-07 9:44

>>55
Please criticize my C++ 2D-vector class.
It's C++. Done.

Name: Anonymous 2011-10-07 13:04

>>54

just use JS then, it is in every browser.

Name: Anonymous 2011-10-07 15:55

I like the post code SW1A 0AA. (´・ω・)

Name: Anonymous 2011-10-07 16:52

59 GET

Don't change these.
Name: Email:
Entire Thread Thread List