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

Utility I wrote for GNU+Linux

Name: Anonymous 2012-02-13 3:19

It's a small utility like cat or sed that can be used on Linux systems. It's called why. Licensed under the GPLv3 (or later).

Here is the code (save it in `why.c'):
#include <stdio.h>

void main()
{
printf("Fuck you, that's why.\n");

}


Install with:
gcc -o why why.c ;sudo cp ./why /bin/why

Name: Anonymous 2012-02-13 3:33

i think the newline is superfluous and so i'll probably wait for why 2.0  before installing a pirated copy of it.  yeah i know its GPL, but i just gotta be me…

Name: Anonymous 2012-02-13 3:38

>>2
The newline is actually a workaround for the infamous (and unpatched) bash put-the-prompt-on-the-same-line-as-the-last-outputted-line-of-the-last-command bug.

What do you mean by `pirate'? Are you going to buy a copy from seafaring murderous thugs? Why would you do that? That attitude hurts all of the Free Software Movement.

Name: Anonymous 2012-02-13 7:10

Name: Anonymous 2012-02-13 7:53

>>4
Referring to fedora and freedesktop! Oh my! And why not Lennart while you're at it?

Name: Anonymous 2012-02-13 8:00

>>5
Lennart says nothing about /bin

Name: Anonymous 2012-02-13 8:59

considering why is not managed by your package manager, the appropriate location for the why binary is /usr/local/bin

Name: Anonymous 2012-02-13 9:25

I'll make a PACMAN PKG for this.

Name: Anonymous 2012-02-13 10:46

>>4
UMENA /usr/bin/env why?

Name: Anonymous 2012-02-13 10:55

>Fuck you, that's why.
Back to reddit.

Name: Anonymous 2012-02-13 11:00

Where are  the ``undefined behavior'' guys ?

Name: Anonymous 2012-02-13 11:09

>>11
Exit code? Nice dubs.

Name: Anonymous 2012-02-13 11:10

>>12
Thanks bro

Name: Anonymous 2012-02-13 11:27

>>11
There's no undefined behavior here, since the language obviously isn't C.

Name: Anonymous 2012-02-13 13:06

>>11
Its not C Standard code

Name: Anonymous 2012-02-13 13:48

Learn Visual Basic

Name: Anonymous 2012-02-13 14:56

>>4
Jews did /bin

Name: Anonymous 2012-02-13 22:52

Doesn't compile under CLISP. That means it's shit.

Name: REMINPLEMENTED 2012-02-14 0:15

save to why:
#/bin/bash
echo "fuck you thats why"
install with
cp why /usr/bin/why;sudo chmod +rwxrwxrwx /usr/bin/why

licensed under MIT licecnse

Name: Anonymous 2012-02-14 10:10

>>3
I always thought that was how it was supposed to work.  Does zsh have this bug?

Name: Anonymous 2012-02-14 17:18

Licensed under the GPLv3 (or later).
I can't wait for this version to have seventeen flags that do nothing related to the program. Meanwhile the MIT/BSD version remains pure, which leads to people bitching that it ``isn't as good''.

Name: Anonymous 2012-02-14 22:02

Please use int main(void); for the definition of main

Name: Anonymous 2012-02-14 22:38

>>22
why

Name: Anonymous 2012-02-14 22:52

>>23
That's the standard way of writing a main that takes no arguments.

Name: Anonymous 2012-02-14 23:24

>>23
"Fuck you, that's why.\n"

Name: Anonymous 2012-02-15 8:12

Any Scheme port yet?

Name: Anonymous 2012-02-15 15:34

>>26
I can make one for Racket.

Name: Anonymous 2012-02-16 18:21

I hacked it a little to include colors! Still under GPLv3, of course. Hope you like it.

Save to why.c:

#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <string.h>

int AttExch[] = {0,1,2,3,4,7,8};
int ColExch[] = {0,1,2,3,4,5,6,7};
typedef enum _Attr
{
Reset = 0,
Bright = 1,
Dim = 2,
Underline = 3,
Blink = 4,
Reverse = 7,
Hidden = 8,
}Attr;

typedef enum _Colors
{
Black = 0,
Red     = 1,
Green = 2,
Yellow = 3,
Blue = 4,
Magenta = 5,
Cyan = 6,
White = 7,
}Colors;


typedef struct _ColorCodes{
        Attr Attribute;
        Colors Foreground;
        Colors Background;
} ColorCodes;

/* Prototypes */
void textcolor(ColorCodes codes);
void RandomColors();
int * FillRandArray(int);
Attr RevAttr(int);
Colors RevColor(int);


int main()
{
        const char message[] = "Fuck you, that's why.";
        ColorCodes cc;
        int length = strlen(message);
        int * arr = (int *)FillRandArray(length);

        int i = 0, average = 0, secaver = 0;

        cc.Attribute = Bright;
        cc.Foreground = Red;
        cc.Background = Blue;
        textcolor(cc);

        i = 0;
        while(i < length)
        {
                if( i == length)
                {
                        free(arr);
                        // Uncomment the following lines and
                        // comment the break to loop forever.
                        //arr = (int *)FillRandArray(length);
                        //i=0;
                        break;
                }
                cc.Attribute = RevAttr(AttExch[arr[i] % 6]);
                cc.Foreground = RevColor(ColExch[0]);  // arr[i] % 7]); Only black
                cc.Background = RevColor(ColExch[arr[i] % 6] + 1); // no black
                textcolor(cc);
                //printf(" - [%d - %d - %d]\n",cc.Attribute,cc.Background,cc.Foreground);
                printf("%c", message[i]);
                i++;
        }

        cc.Attribute = Reset;
        cc.Foreground = White;
        cc.Background = Black;
        textcolor(cc);

        printf("\n");
        return 0;
}

void textcolor(ColorCodes codes)
{
        char* command = (char*)malloc(50 * sizeof(char));
        /* Command is the control command to the terminal */

        sprintf(command, "%c[%d;%d;%dm", 0x1B, codes.Attribute, codes.Foreground + 30, codes.Background + 40);

        printf("%s", command);
        free(command);
}

void RandomColors()
{
        int derp = 44;
        srand ((unsigned int) time(NULL) * derp );

}

int * FillRandArray(int len)
{
        int * Arr = (int*) malloc(len * sizeof(int));
        int * key = (int*) malloc(len * sizeof(int));
        int i;
        int temp;
        double temp2;

        srand ((unsigned int) time(NULL) );

        for(i = 0; i <= len - 2; i++)
        {
                 temp2 = pow((double)(rand() % 256),(rand() % 3) + 1);
                 temp = (int) ((double)((rand() >> 16) ^ ~(int)temp2));
                 Arr[i] = abs(temp) % 255;

                 /*temp2 = pow((double)(rand() % 256),(rand() % 3) + 1);
                 temp = (int) ((double)((rand() >> 16) ^ ~(int)temp2));
                 key[i] = abs(temp) % 255;

                Arr[i] = ( ( (Arr[i] * rand() ) % 255) >> 13) ^ ( ( (key[i]* rand() ) % 255) << 13 );
                Arr[i] = abs(Arr[i]) % 1023 * 1023;
                Arr[i] = ( ( (Arr[i] * rand() ) % 255) << 13) ^ ( ( (key[i]* rand() ) % 255) >> 13 );
                Arr[i] = abs(Arr[i]) % 767 * 767;
                Arr[i] = ( ( (Arr[i] * rand() ) % 255) >> 13) ^ ( ( (key[i]* rand() ) % 255) << 13 );
                Arr[i] = abs(Arr[i]) % 511 * 511;
                Arr[i] = ( ( (Arr[i] * rand() ) % 255) << 13) ^ ( ( (key[i]* rand() ) % 255) >> 13 );
                Arr[i] = abs(Arr[i]) % 255;
                */
        }

        return Arr;
}

Colors RevColor(int a)
{
        switch(a)
        {
        case 0:
                return Black;
        case 1:
                return Red;
        case 2:
                return Green;
        case 3:
                return Yellow;
        case 4:
                return Blue;
        case 5:
                return Magenta;
        case 6:
                return Cyan;
        case 7:
                return White;
        default:
                return Blue;

        }
}

Attr RevAttr(int a)
{
        switch(a)
        {
        case 0:
                return Reset;
        case 1:
                return Bright;
        case 2:
                return Dim;
        case 3:
                return Underline;
        case 4:
                return Blink;
        case 7:
                return Reverse;
        case 8:
                return Hidden;
        default:
                return Bright;
        }
}


Install with the following:
gcc -lm -o why why.c; sudo cp ./why /bin/why && echo "Done Installing!"

Name: Anonymous 2012-02-16 18:28

>>26
(display "Fuck you, that's why.") (newline)

Name: Anonymous 2012-02-16 18:33

>>28
typical C faggot
                 /*temp2 = pow((double)(rand() % 256),(rand() % 3) + 1);
                 temp = (int) ((double)((rand() >> 16) ^ ~(int)temp2));
                 key[i] = abs(temp) % 255;

                Arr[i] = ( ( (Arr[i] * rand() ) % 255) >> 13) ^ ( ( (key[i]* rand() ) % 255) << 13 );
                Arr[i] = abs(Arr[i]) % 1023 * 1023;
                Arr[i] = ( ( (Arr[i] * rand() ) % 255) << 13) ^ ( ( (key[i]* rand() ) % 255) >> 13 );
                Arr[i] = abs(Arr[i]) % 767 * 767;
                Arr[i] = ( ( (Arr[i] * rand() ) % 255) >> 13) ^ ( ( (key[i]* rand() ) % 255) << 13 );
                Arr[i] = abs(Arr[i]) % 511 * 511;
                Arr[i] = ( ( (Arr[i] * rand() ) % 255) << 13) ^ ( ( (key[i]* rand() ) % 255) >> 13 );
                Arr[i] = abs(Arr[i]) % 255;
                */

Name: Anonymous 2012-02-16 19:20

#include <stdlib.h>
int main(void){return system("echo Fuck you, that's why.");}

Name: Anonymous 2012-02-16 21:46

>>30
You are right, that looks terrible. I actually wrote this to act as a shell for people that tried to SSH into the 4chan FTP server that I was running, where it would simply display random shit in random colors. I wanted to see just how convoluted I could get it. Obviously, that block didn't work, so I moved on to the next trivial bit and tried to fuck around with it. I didn't intend, when writing, for it to ever be used in such a critical tool as why. I hope that some real hacker* can someday fix it up nicer.

______________________________________________
*http://catb.org/jargon/html/H/hacker.html

Name: Anonymous 2012-02-16 22:31

dubs I wrote for this thread

check 'em

Name: Anonymous 2012-02-16 23:22

>>28
Typical GPL shit.

Name: Anonymous 2012-02-16 23:56

Warmly awaiting kWhy for my graphical KDE provided pleasure.

Name: Anonymous 2012-02-17 0:06

I made a gtk version, are you proud?


#!/bin/bash

 zenity --info --text="fuck you, thats why"


install with
cp why /usr/bin/why;sudo chmod +rwxrwxrwx /usr/bin/why

Name: Anonymous 2012-02-17 0:10

is there a windows port yet?

Name: Anonymous 2012-02-17 0:42

>>37
Save into Why.vbs


MsgBox("Fuck you, that's why.")

Name: Anonymous 2012-02-17 0:45

>>38
can you make a color version?

Name: Anonymous 2012-02-17 0:45

>>28
Without a name (or pseudonym) attached to that work, there is no effective reason why there should be a copyright attached to it. If you publish your own work and you're anonymous, that work is nothing less than public domain work.

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