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

bbcode

Name: Anonymous 2008-11-08 20:29

/*
 * bbcoder.c -- Generate enterprise grade forum posts.
 *
 * Copyright (C) 2008  Anonymous
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to
 * the Free Software Foundation, Inc.
 * 51 Franklin Street, Fifth Floor
 * Boston, MA  02110-1301, USA
 *
 */

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

char *bbcode[7] = {
    "spoiler", "sub", "sup", "b", "u", "o", "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 maxc, arg, pushorpop, c;
    int pushed = 0;

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

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

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

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

Name: Anonymous 2008-11-10 12:08

"""
bbcoder.py, version 0.1

Copyright (C) 2008  Anonymous

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to
the Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor
Boston, MA  02110-1301, USA"""

import sys
from StringIO import StringIO

# List of valid BBCode tags
BB_TAGS = ("spoiler", "sub", "sup", "b", "u", "o", "i", "s", "code")
# Escape character to go up a level
ESCAPE_CHAR = "`"
# Stack of currently opened BBCode tags
bbStack = []
# Output string
stringBuffer = StringIO()

# Clean up after the user quits, by printing the accumulated text
def EndHandler():
    # Empty BBCode stack
    while len(bbStack) > 0:
        stringBuffer.write("[/%s]" % bbStack.pop())
    # Print string
    stringBuffer.seek(0)
    print
    print "---"
    print stringBuffer.read()
    sys.exit(0);

# Parses the line and returns
def ParseLine(line):
    # Line is the escape character: Go up one level on the BBCode stack
    if line == ESCAPE_CHAR:
        if len(bbStack) > 0:
            stringBuffer.write("[/%s]" % bbStack.pop())
    # Line is a BBCode tag: Add tag to the string buffer and push
    # tag on the stack
    elif line.lower() in BB_TAGS:
        bbStack.append(line)
        stringBuffer.write("[%s]" % line)
    # Line is empty: Add a newline character
    elif line == "":
        stringBuffer.write("\n")
    # Otherwise: Just add the literal text
    else:
        stringBuffer.write(line)

# Prints the current location in the BBCode nesting
def PrintBBCodeLocation():
    tagList = ["[%s]" % tag.upper() for tag in bbStack]
    sys.stdout.write("".join(tagList) + ": ")
    sys.stdout.flush()

def Main():
    while True:
        try:
            PrintBBCodeLocation()
            line = raw_input()
            ParseLine(line)
        except EOFError:
            EndHandler()

if __name__ == "__main__": Main()


Example usage:
: u
[U]: b
[U][B]: s
[U][B][S]: sup
[U][B][S][SUP]: BB
[U][B][S][SUP]: `
[U][B][S]: sub
[U][B][S][SUB]: CODE
[U][B][S][SUB]: <CTRL+D or whatever EOF is on your platform>


Result:
BBCODE

Name: Anonymous 2008-11-10 12:16

>>41
OH HI, FAGGOT. I THINK YOU SHOULD COMMENT YOUR CODE A LITTLE BETTER.

Name: Anonymous 2008-11-10 13:05

>>42
Thank you for pointing that out. I will next time.

Name: Anonymous 2008-11-10 13:19

>>43
OH HI, FAGGOT. I THINK YOU SHOULD INDENT YOUR CODE A LITTLE LESS.

Name: Anonymous 2008-11-10 13:31

>>44
You can take away my freedom, but you can't take my indentation, mongrel!

Name: Anonymous 2008-11-10 14:36

Fag, or Faggot (slang), an American generally pejorative word or slur for a homosexual, especially a homosexual man, or for men who are judged to be "unmanly", weak or effeminate; in modern usage the word can be used as a general insult irrespective of sexuality or gender

Name: Anonymous 2008-11-10 15:21

V2.0
/*
 * bbcoder.c -- generate enterprise grade forum posts.
 *
 * Copyright (C) 2008  Anonymous
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to
 * the Free Software Foundation, Inc.
 * 51 Franklin Street, Fifth Floor
 * Boston, MA  02110-1301, USA
 *
 */

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

#ifdef CDB
char *bbcode[7] = {
    "highlight",
#else
char *bbcode[8] = {
    "o", "spoiler",
#endif
    "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 maxc, arg, pushorpop, c;
    int pushed = 0;

    srand(time(NULL));
    maxc = 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) {
            c = rand() % maxc;
            stack = push(c, stack);
            pushed++;
            printf(" [%s]", bbcode[c]);
        } else {
            stack = pop(&c, stack);
            pushed--;
            printf("[/%s] ", bbcode[c]);
        }
        printf("%s", argv[arg]);
    }
    while(pushed > 0) {
        stack = pop(&c, stack);
        pushed--;
        printf("[/%s]", bbcode[c]);
    }
    printf("\n");
    return 0;
}


Now even more ENTERPRISE

Name: Anonymous 2008-11-10 15:23

Fag, or Faggot (slang), an American generally pejorative word or slur for a homosexual, especially a homosexual man, or for men who are judged to be "unmanly", weak or effeminate; in modern usage the word can be used as a general insult irrespective of sexuality or gender

Name: Anonymous 2008-11-10 18:18

/* 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 do not
 * distribute it under any GNU license.
 *
 * 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>

#define RANDOM_MAX 32767
#define BBCODE_TAGS_COUNT 9

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

Name: Anonymous 2008-11-10 20:19


{-------------------------------------------------------------------------------
 - bbcoder.hs -- Generate enterprise-grade /prog/ posts.                       -
 - Copyright (c) 2008 Anonymous                                                -
 - All rights reserved.                                                        -
 -                                                                             -
 - Redistribution and use in source and binary forms, with or without          -
 - modification, are permitted provided that the following conditions are met: -
 -     * Redistributions of source code must retain the above copyright        -
 -       notice, this list of conditions and the following disclaimer.         -
 -     * Redistributions in binary form must reproduce the above copyright     -
 -       notice, this list of conditions and the following disclaimer in the   -
 -       documentation and/or other materials provided with the distribution.  -
 -                                                                             -
 - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS -
 - OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED           -
 - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE      -
 - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY        -
 - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES  -
 - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR          -
 - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER  -
 - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT          -
 - LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY   -
 - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -
 - DAMAGE.                                                                     -
 ------------------------------------------------------------------------------}

import System.Random

bbcodes = ["b", "i", "m", "o", "s", "spoiler", "sub", "sup", "u"]

randomBBCode =
  do n <- randomRIO (0, length bbcodes - 1)
     return (bbcodes !! n)

bbcodify = bbcodify' . words
  where
        bbcodify' []     = return ""
        bbcodify' (w:ws) =
          do bbcode <- randomBBCode
             rest   <- bbcodify' ws
             return ("[" ++ bbcode ++ "]" ++ w ++ " " ++ rest ++
                     "[/" ++ bbcode ++ "]")

main =
  do line <- getContents
     bbcode <- bbcodify line
     putStrLn bbcode

Name: Anonymous 2008-11-10 20:21

>>50
Faggot, use bind: getContents >>= bbcodify >>= putStrLn

Name: Anonymous 2008-11-10 20:37

I never claimed to be a good Spanish speaker.

Name: Anonymous 2008-11-10 20:41

/* 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 do not
 * distribute it under any GNU license.
 *
 * 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[9] = {"b", "i", "m", "o", "s", "spoiler", "sub",
   "sup", "u"};
 size_t stack_size = 0, argv_index;
#ifdef __STRICT_ANSI__
 srandom(time(0));
#else
 srandomdev();
#endif
 if(argc == 1) return -1;
 for(argv_index = 1; argv_index < argc; ++argv_index){
  if(random() & 1 && stack_size){
   --stack_size;
   printf("[/%s] %s", stack[stack_size], argv[argv_index]);
  }else{
   stack[stack_size] = bbcode[random() / 3641];
   printf(" [%s]%s", stack[stack_size], argv[argv_index]);
   ++stack_size;
  }
 }
 while(stack_size){
  --stack_size;
  printf("[/%s]", stack[stack_size]);
 }
 puts("");
 return 0;
}

Name: Anonymous 2008-11-10 20:45

>>53
Give up, you've been beat by Haskell's awesomeness.


{-------------------------------------------------------------------------------
 - bbcoder.hs -- Generate enterprise-grade /prog/ posts.                       -
 - Copyright (c) 2008 Anonymous                                                -
 - All rights reserved.                                                        -
 -                                                                             -
 - Redistribution and use in source and binary forms, with or without          -
 - modification, are permitted provided that the following conditions are met: -
 -     * Redistributions of source code must retain the above copyright        -
 -       notice, this list of conditions and the following disclaimer.         -
 -     * Redistributions in binary form must reproduce the above copyright     -
 -       notice, this list of conditions and the following disclaimer in the   -
 -       documentation and/or other materials provided with the distribution.  -
 -                                                                             -
 - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS -
 - OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED           -
 - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE      -
 - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY        -
 - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES  -
 - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR          -
 - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER  -
 - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT          -
 - LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY   -
 - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -
 - DAMAGE.                                                                     -
 ------------------------------------------------------------------------------}

module Main where
import System.Random

bbcodes = ["b", "i", "m", "o", "s", "spoiler", "sub", "sup", "u"]

randomBBCode = randomRIO (0, length bbcodes - 1) >>= return . (bbcodes !!)

bbcodify = bbcodify' . words
  where bbcodify' []     = return ""
        bbcodify' (w:ws) =
          do bbcode <- randomBBCode
             rest   <- bbcodify' ws
             return $ concat ["[", bbcode, "]", w, " ", rest, "[/", bbcode, "]"]

main = getContents >>= bbcodify >>= putStrLn

Name: Anonymous 2008-11-10 21:22

I can write a faster fibonacci program in C than in Haskell.

Name: Anonymous 2008-11-10 21:27

/* 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 do not
 * distribute it under any GNU license.
 *
 * 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.
 */

using System;
using System.Collections.Generic;

class BBCoder{
 public static void Main(string[] args){
  string[] bbcode = new string[] {"b", "i", "m", "o", "s", "spoiler", "sub", "sup", "u"};
  Stack<string> tag_stack = new Stack<string>();
  Random rand = new Random();
  foreach(string arg in args){
   if(rand.Next(2) != 0 && tag_stack.Count != 0) Console.Write("[/" + tag_stack.Pop() + "] " + arg);
   else{
    string tag = bbcode[rand.Next(bbcode.Length)];
    Console.Write(" [" + tag + "]" + arg);
    tag_stack.Push(tag);
   }
  }
  while(tag_stack.Count != 0) Console.Write("[/" + tag_stack.Pop() + "]");
  Console.WriteLine();
 }
}

Name: Anonymous 2008-11-10 21:27

>>55
If you care so much about speed, write in assembly.

Name: Anonymous 2008-11-10 21:58

#!/usr/bin/env perl

# 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 do not
# distribute it under any GNU license.
#
# 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.

use strict;

my(@b,@s,$t)=qw(b i m o s spoiler sub sup u);
@ARGV or exit;
print map((.5>rand)&&@s?'[/'.pop(@s)."] $_":push(@s,$t=$b[rand 9])&&" [$t]$_",@ARGV),map("[/$_]",reverse@s),"\n";

Name: Anonymous 2008-11-10 22:18

>>58
"Watching golf is like watching flies fuck."
--George Carlin

Name: Anonymous 2008-11-10 22:42

what does m do?

Name: Anonymous 2008-11-10 22:48

>>54
Here's a better version that works more like the others (i.e. less gay.)


{-------------------------------------------------------------------------------
 - bbcoder.hs -- Generate enterprise-grade /prog/ posts.                       -
 - Copyright (c) 2008 Anonymous                                                -
 - All rights reserved.                                                        -
 -                                                                             -
 - Redistribution and use in source and binary forms, with or without          -
 - modification, are permitted provided that the following conditions are met: -
 -     * Redistributions of source code must retain the above copyright        -
 -       notice, this list of conditions and the following disclaimer.         -
 -     * Redistributions in binary form must reproduce the above copyright     -
 -       notice, this list of conditions and the following disclaimer in the   -
 -       documentation and/or other materials provided with the distribution.  -
 -                                                                             -
 - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS -
 - OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED           -
 - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE      -
 - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY        -
 - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES  -
 - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR          -
 - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER  -
 - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT          -
 - LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY   -
 - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -
 - DAMAGE.                                                                     -
 ------------------------------------------------------------------------------}

module Main where
import System.Random

bbcodes = ["b", "i", "m", "o", "s", "spoiler", "sub", "sup", "u"]

randomBBCode = randomRIO (0, length bbcodes - 1) >>= return . (bbcodes !!)

bbcodify = bbcodify' . words
  where bbcodify' []     = return ""
        bbcodify' (w:ws) =
          do bbcode <- randomBBCode
             rest   <- bbcodify' ws
             quick  <- randomIO
             return $ concat $ ["[", bbcode, "]", w] ++
               (if quick
                  then ["[/", bbcode, "]", rest]
                  else [" ", rest, "[/", bbcode, "]"])

main = getContents >>= bbcodify >>= putStrLn


even asthe world listened to BarackObama’s victory speech, MrMedvedev was laying outa Russianversion ofdemocracy.Themaintelevisionnewsdevoted 45minutes to Mr Medvedev, leaving justfiveminutesforMr Obama.

Name: Anonymous 2008-11-10 22:51

even asthe worldlistened toBarack Obama’svictory speech,Mr Medvedevwas layingout aRussian versionof democracy.The maintelevision newsdevoted 45minutes toMr Medvedev,leaving justfive minutesfor MrObama.

Name: Anonymous 2008-11-10 23:53

>>61
Even that one sucks, faggot.


{-------------------------------------------------------------------------------
 - bbcoder.hs -- Generate enterprise-grade /prog/ posts.                       -
 - Copyright (c) 2008 Anonymous                                                -
 - All rights reserved.                                                        -
 -                                                                             -
 - Redistribution and use in source and binary forms, with or without          -
 - modification, are permitted provided that the following conditions are met: -
 -     * Redistributions of source code must retain the above copyright        -
 -       notice, this list of conditions and the following disclaimer.         -
 -     * Redistributions in binary form must reproduce the above copyright     -
 -       notice, this list of conditions and the following disclaimer in the   -
 -       documentation and/or other materials provided with the distribution.  -
 -                                                                             -
 - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS -
 - OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED           -
 - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE      -
 - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY        -
 - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES  -
 - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR          -
 - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER  -
 - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT          -
 - LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY   -
 - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -
 - DAMAGE.                                                                     -
 ------------------------------------------------------------------------------}

module Main where
import System.Random

bbcodify = (bbcodify' [] "") . words
  where bbcodify' s str [] = return $ str ++ (concat $ map bbcodeEnd s)
        bbcodify' s str (w:ws) =
          do c <- randomBBCode
             p <- randomIO >>= (\p -> return (if length s < 2 then True else p))
             let pop  = if null s then 0  else head s
             let rest = if null s then [] else tail s
             if p
               then bbcodify' (c:s) (str ++ bbcodeBeg c   ++ w ++ " ") ws
               else bbcodify' rest  (str ++ bbcodeEnd pop ++ w ++ " ") ws
        bbcodeBeg i = "["  ++ decodeBBCode i ++ "]"
        bbcodeEnd i = "[/" ++ decodeBBCode i ++ "]"
        bbcodes = words "b i m o s spoiler sub sup u"
        decodeBBCode = (bbcodes !!)
        randomBBCode = randomRIO (0, length bbcodes - 1)

main = getContents >>= bbcodify >>= putStrLn

Name: Anonymous 2008-11-11 0:01

/* 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 do not
 * distribute it under any GNU license.
 *
 * 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.
 */

using System;
using System.Collections.Generic;

class BBCoder{
 public static void Main(string[] args){
  string[] bbcode = new string[] {"aa", "b", "i", "m", "o", "s", "spoiler", "sub", "sup", "u"};
  Stack<string> tag_stack = new Stack<string>();
  Random rand = new Random();
  foreach(string arg in args){
   if(rand.Next(2) != 0 && tag_stack.Count != 0) Console.Write("[/" + tag_stack.Pop() + "] " + arg);
   else{
    tag_stack.Push(bbcode[rand.Next(bbcode.Length)]);
    Console.Write(" [" + tag_stack.Peek() + "]" + arg);
   }
  }
  while(tag_stack.Count != 0) Console.Write("[/" + tag_stack.Pop() + "]");
  Console.WriteLine();
 }
}

Name: Anonymous 2008-11-11 1:07

>>60
monospace font without code hilighting

Name: Anonymous 2008-11-11 1:18


/* bbgen r0 -- Anonymous -- PUBLIC DOMAIN */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

char *tags[8] = { "b","i","o","s","u","sub","sup","spoiler"};

int bain(int argc, char **argv) {
 int i,j;
 if(argc<1)
  return 0;
 if(argc<2)
  return printf("%s ",*argv);
 i=rand()%16;
 j=rand()%argc;
 if(i<8)
  printf("[%s]",tags[i]);
 bain(j,argv);
 bain(argc-j,argv+j);
 if(i<8)
  printf("[/%s]",tags[i]);
}

int main(int argc, char **argv) {
 srand(time(0));
 return bain(argc-1,argv+1);
}


Permission is hereby granted, free of charge, to any person obtaining this work (the Work), to deal in the Work without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Work, and to permit persons to who the Work is furnished to do so.

Name: Anonymous 2008-11-11 1:59

>>66
you forgot about the "aa" and "m" tags.

Name: Anonymous 2008-11-11 2:14

>>67
/* bbgen r1 -- Anonymous -- PUBLIC DOMAIN */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

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

int bain(int argc, char **argv) {
 int i,j;
 if(argc<1)
  return 0;
 if(argc<2)
  return printf("%s ",*argv);
 i=rand()%20;
 j=rand()%argc;
 if(i<10)
  printf("[%s]",tags[i]);
 bain(j,argv);
 bain(argc-j,argv+j);
 if(i<10)
  printf("[/%s]",tags[i]);
}

int main(int argc, char **argv) {
 srand(time(0));
 return bain(argc-1,argv+1);
}

Name: Anonymous 2008-11-11 2:31

>>68
why not put the space after closing tags instead of before them?
/* 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;
#ifdef __STRICT_ANSI__
 srandom(time(0));
#else
 srandomdev();
#endif
 if(argc == 1) return -1;
 printf("[%s]%s", stack[0] = bbcode[random() % 10], argv[1]);
 for(argv_index = 2; 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 2008-11-11 3:12

>>69
puts()? In my C? Get the fuck out! It's not even doing anything useful.

Name: Anonymous 2008-11-11 3:38

>>70
what better way is there to output a newline character? putchar('\n')? printf("\n")? both are longer, and using printf like that is considered harmful.

Name: Anonymous 2008-11-11 3:45

[i]Ecco un semplice esperimento che vi insegnera'
un'importante lezione sull'elettricita':
in [spoiler]un
a [spoiler]giornata [u]fredda e secca, strofinate i piedi su
 un tappeto, quindi con la mano raggiungete l
a bocca di un vostro
amico
e toccate una d
elle
sue
otturazioni
dentarie. Avete fatto [i]attenzione [/
i]a [/u]come [sub]il vostro amico si e' [i]contratto [
/i]violentemente [/sub]ed [/spoiler]ha [/spoiler]urlato per il dolor
e?
Questo ci insegna che l'elettricita' puo' esse
re una forza molto potente, ma non dobbiamo mai
usarla per far soffrire gli alt
ri, a meno che non abbiamo bisogno di impar
are
un'importante
lezione sull'elettricita'. Ci insegna
 
anche
come
funziona un circuito elettrico. Quando [
sub]avete strofinato i piedi, voi avete raccolto deg
li "elettroni", i
quali sono piccolissimi [/sub]oggetti che
 i fabbricanti tessono nei
loro [u]tappeti per
attirare la sporcizia. Gli elettroni viaggiano [su
b]attraverso il sangue [/sub]e si raccolgono sul vost
ro
dito,
dove formano una
scintilla
che balz
a sulle otturazioni del vostro amico, e poi [spoiler
]viaggia in giu' [/spoiler]verso i suoi piedi e
rit
orna
al
tappeto, chiudendo il circuito. Fatto El
ettronico
Divertente: se voi strofinaste i pied
i abbastanza a
lungo
senza
toccare
niente
,
raccogliereste [spoiler]cosi' tanti elettroni che il [spoiler
]vostro [/spoiler]dito esploderebbe! Ma non c'e' nulla di [i
]cui [/i]preoccuparsi,
sempreche'
non abbiate la m
oquette...
--
Dave
Barry, "What is Electricity?" [
/spoiler][/u][/i]

Name: Anonymous 2008-11-11 4:40

>>72
RAAAAAAAAAAAA AAAAAAAAGE

Name: Anonymous 2008-11-11 10:48

>>71
Explicity is better than implicity.

Name: Anonymous 2008-11-11 11:42

When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.

To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.

Name: Anonymous 2008-11-11 12:34

When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.

Name: Anonymous 2008-11-11 13:12

When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.

Name: Anonymous 2008-11-11 13:19

I realize I had never done any SERIOUS text processing with anything else than shell scripts or regexes. It’s kind of hard to get it right.

Name: Sageing fail since 1463 2008-11-11 13:56

>>75-78
Epic Fail!

Name: Anonymous 2008-11-11 14:11

>>79
Did you mean to post ``>>75-78
Epic Fail!''?

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