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

What do you code in your free time?

Name: Anonymous 2009-03-20 15:41

I mean, everything has been already done by someone else and I don't think everyone is involved in BIG projects and shit like that.

Name: Anonymous 2009-03-20 15:42

What's the difference between fun() and fun(void) in C?

Name: Anonymous 2009-03-20 15:43

ABC interpreter.

Name: Anonymous 2009-03-20 15:45

>>1
I'm currently working on a C Preprocessor to give to the Anonix project

Name: Anonymous 2009-03-20 15:57

( ゚ ヮ゚) $0.99 iPhone Apps!

Name: Anonymous 2009-03-20 16:25

>>5
Haha, you develop on OSX.

I feel kind of bad about it :(

Name: Anonymous 2009-03-20 16:58

Sex with Leah Culver

Name: Anonymous 2009-03-20 17:03

>>7
Anonymous lies!

Name: Anonymous 2009-03-20 19:06

My last 'project' was a cellular automata implementation in pascal with editing capability.

I'm a noob

Name: Anonymous 2009-03-20 19:46

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

char *bbcode[10] = {
    "o", "spoiler", "aa", "m",
    "sub", "sup", "s", "b", "u", "i"
};

typedef struct stack_t {
    int value;
    struct stack_t *next;
} stack_t;

stack_t *push(int value, stack_t *stack) {
    stack_t *buf;

    if ((buf = malloc(sizeof(stack_t))) == NULL)
        return NULL;

    buf->value = value;
    buf->next = stack;
  
    return buf;
}

stack_t *pop(int *out, stack_t *stack) {
    stack_t *next = NULL;

    if(stack != NULL) {
        *out = stack->value;
        next = stack->next;
        free(stack);
    }
  
    return next;
}

int main(int argc, char **argv) {
    stack_t *stack = NULL;
    int maxcode, arg, pushorpop, code;
    int pushed = 0;

    srand(time(NULL));
    maxcode = sizeof(bbcode)/sizeof(char*);

    if(argc == 1) {
        return -1;
    }

    for(arg = 1; arg < argc; arg++) {
        pushorpop = rand() % 2;
        if(pushed == 0)
            pushorpop = 0;

        if(pushed > 4)
            pushorpop = 1;

        if(pushorpop == 0) {
            code = rand() % maxcode;
            stack = push(code, stack);
            pushed++;
            printf(" [%s]", bbcode[code]);
        } else {
            stack = pop(&code, stack);
            pushed--;
            printf("[/%s] ", bbcode[code]);
        }
        printf("%s", argv[arg]);
    }
    while(pushed > 0) {
        stack = pop(&code, stack);
        pushed--;
        printf("[/%s]", bbcode[code]);
    }
    printf("\n");
    return 0;
}

Name: Anonymous 2009-03-20 19:49

I just finished a web search interface to my anime database.

Name: Anonymous 2009-03-20 19:53

>>10
That's not optimized. It might push the same code twice, causing the unpleasant effect of several words in a row having the same formatting. Please fix it by ensuring that two redundant codes can't exist in the stack at the same time.

Please avoid calling rand() multiple times until you find a suitable code. Moreover, don't call rand() if some overriding condition is met ((pushed == 0) and (pushed > 4) in your code).

Name: Anonymous 2009-03-20 20:02

That's not optimized. It might push the same code twice, causing the unpleasant effect of several words in a row having the same formatting. Please fix it by ensuring that two redundant codes can't exist in the stack at the same time.
how would you handle something like [m]a [aa]b [m]c[/m] d[/aa] e[/m]?

anyway, here's a better one:
/* Copyright (c) 2008 Anonymous
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that you grant this
 * same permission to anyone you distribute it to without any additional
 * restrictions.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <time.h>

int main(int argc, char *argv[]){
 char *stack[argc - 1], *bbcode[10] = {"aa", "b", "i", "m", "o", "s", "spoiler",
   "sub", "sup", "u"};
 size_t stack_size = 1, argv_index = 2;
#ifdef __STRICT_ANSI__
 srandom(time(0));
#else
 srandomdev();
#endif
 if(argc == 1) return -1;
 for(printf("[%s]%s", stack[0] = bbcode[random() % 10], argv[1]);
   argv_index < argc; ++argv_index)
  if(random() % 2 && stack_size)
   printf("[/%s] %s", stack[--stack_size], argv[argv_index]);
  else
   printf(" [%s]%s", stack[stack_size++] = bbcode[random() % 10],
     argv[argv_index]);
 while(stack_size) printf("[/%s]", stack[--stack_size]);
 puts("");
 return 0;
}

Name: Anonymous 2009-03-20 20:09

>>10
>>13
These both suck some long Sussman'.
You really should implement a more probabilistic model rather than just using plain randomness for everything. (i.e.: nest depth of tags effects chance of escaping tags or increasing nest dept, && certain random patterns that have already occured should be more likely to reoccur.

Name: Anonymous 2009-03-20 20:20

You really should implement a more probabilistic model rather than just using plain randomness for everything. (i.e.: nest depth of tags effects chance of escaping tags or increasing nest dept, && certain random patterns that have already occured should be more likely to reoccur.
that's great if you want to get the same five patterns over and over again instead of coming up with new ones.

Name: Anonymous 2009-03-20 20:20

Have you generated your random BBCode today?

Name: Anonymous 2009-03-20 20:27

Yes, indeed. I actually have. Was a great experience.

Name: Anonymous 2009-03-20 20:28

ITT: OPTIMIZING BBCODE GENERATORS THAT TAKE NANOSECONDS TO RUN.

Name: Anonymous 2009-03-20 20:29

I'm glad to hear that. HAND.

Name: Anonymous 2009-03-20 20:33

>>15
...You don't undertand the word 'probabilistic' do you? It does not mean deterministic, it simply means weighted randomness. So you dont end up with shit like >>16

Name: Anonymous 2009-03-20 20:34

>>20
>>16 is weighted.

Name: Anonymous 2009-03-20 20:41

4%20 HOMEY

Ma
rijuana MUST be legalized.

BBCode MASTERS smoke WEED!

Name: Anonymous 2009-03-20 20:41

HOLY SHIT I LOVE ICECREAM

Marijua
n
a MUST be legalized.

BBCode MASTERS smoke WEED!

Name: Anonymous 2009-03-20 20:41

GREEEEEEN

Marijuana MUST be legalized.

BBCode MASTERS sm
oke WEED!

Name: Anonymous 2009-03-20 20:41

GREEEEEEN

Marijuana MUST be lega
lized.

BBCode MASTERS smoke WEED!

Name: Anonymous 2009-03-20 20:43

GREEEEEEN

Marijuana MUST be legalized.

B
BCode MASTERS smoke WEED!

Name: Anonymous 2009-03-20 20:43

GREEEEEEN

Marijuana MUST be legalized.

BBCode MASTERS
smoke WEED!

Name: Anonymous 2009-03-20 20:43

THE NEED FOR WEED

Marijuana MUST be legalized.

BBCode
MASTERS smoke WEED!

Name: Anonymous 2009-03-20 20:43

4:20 HOMEY

Mar
ijuana MU
ST
b
e legalized.

BBCode MASTERS smoke WEED!

Name: Anonymous 2009-03-20 20:43

HOLY SHIT I LOVE ICECREAM

Marijuana MUST be legalized.

BBC
ode MASTERS smoke WEED!

Name: Anonymous 2009-03-20 20:44

GREEEEEEN

Marijuana
MUST be legalized.

B
BCode MASTERS smoke WEED!

Name: Anonymous 2009-03-20 20:44

4:20 HOMEY

M
arijuana MUST be legalized.

BBCode MASTE
RS smoke WEED!

Name: Anonymous 2009-03-20 20:44

THE NEED FOR WEED

Mar
ijuana MUST be legalized.

BBC
ode M
ASTE
RS smoke WEED!

Name: Anonymous 2009-03-20 20:44

4:20 HOMEY

Marijuana MUST be legalized.

BB
C
ode
M
ASTERS smoke WEED!

Name: Anonymous 2009-03-20 20:44

GREEEEEEN

Mar
ijuana MUST be legalized.

BBCo
de MASTERS smoke WEED!

Name: Anonymous 2009-03-20 20:44

GREEEEEEN

Marij
uana MUST be
legalized.

BBCode MASTERS smoke WEED!

Name: Anonymous 2009-03-20 20:44

HOLY SHIT I LOVE ICECREAM

Marijuana MUST be legalized.

BB
Code MASTERS smoke WEED!

Name: Anonymous 2009-03-20 20:44

4:20 HOMEY

Marijua
na
MUST be legalized.

BBCode MASTERS smoke WEED!

Name: Anonymous 2009-03-20 20:44

GREEEEEEN

Ma
rijuana MUST be legalized.

BBCode MASTERS smoke WEED!

Name: Anonymous 2009-03-20 20:45

4:20 HOMEY

Ma
rijuana MUST be legalized.

BBCode
MASTERS smoke WEED!

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