73
votes

In the Markdown help page, the Code and Preformatted Text example is:

printf("goodbye world!");  /* his suicide note
                              was in C */

It also happens to be the first example of the page, and probably where a new visitor's eye will go first. I get and appreciate the joke, however I'd prefer a bit more tasteful example, even if it's as boring and predictable as "hello world!".

Actually, screw that - boring and predictable is for pages you don't want folks to read. Let's have a bit of a contest.

Rules:

  1. Best example by total score wins.
  2. One example per answer, one answer per person.
  3. Two lines per answer, ideally demonstrating whitespace preservation.
  4. Must be recognizable as code.
  5. Must be as inoffensive as possible. Examples likely to encourage readers to commit to source control and then off themselves will be disqualified. Yes, this implicitly disallows any mention of Visual Source Safe.
  6. Winner will be awarded a heaping helping of worthless Meta rep, the envy of his peers, and temporary immortality.

Thanks everyone - look forward to a revised help page shortly. –Shog9

19
  • 3
    That's a bit flat.
    – random
    Aug 3, 2012 at 1:35
  • I don't get it. It's not April the 1st, and your asking a list of things question?
    – Benjol
    Aug 3, 2012 at 6:56
  • 4
    @Benjol Check the revision history, and blame Shog for everything ;)
    – yannis
    Aug 3, 2012 at 8:39
  • 6
    " ... and thanks for all the fish" ?
    – Remou
    Aug 3, 2012 at 14:23
  • 4
    I first read "temporary immorality". Your pun is better. Aug 3, 2012 at 18:20
  • 2
    Can number 3 be changed to "exactly two lines, demonstrating whitespace preservation"? That's an extremely important part of this formatting sample, and most of the examples below are one-liners.
    – jscs
    Aug 7, 2012 at 22:01
  • 3
    Ugh, I hate it when the rules of a contest change mid-way through, @Josh. So now's my chance for revenge. Changed!
    – Shog9
    Aug 10, 2012 at 21:59
  • 1
    I'm quite sure we can get something nice from here. Aug 10, 2012 at 22:55
  • Should we not fix the example under Code Spans as well "Press the `<Tab>` key, then type a `$`." since we should encourage using the <kbd>tab</kdb> markdown?
    – Joe
    Aug 11, 2012 at 0:13
  • 2
    Jeez guys, he's upset because he never learned to use puts() properly and was forever plagued by having to put \n at the end of every line. Have a heart.
    – bobobobo
    Aug 11, 2012 at 0:41
  • 3
    45 answers, and I got notified for each one... Frak!
    – yannis
    Aug 11, 2012 at 1:59
  • 2
    @DavidHyogo This is CW, votes neither earn or cost reputation (not to mention that Meta reputation is pointless).
    – yannis
    Aug 11, 2012 at 2:08
  • 1
    @DavidHyogo CW stands for Community Wiki. There are a couple of answers I feel are particularly tacky, and I don't feel there's anything wrong in down voting them, there is such a thing as a bad joke. Also worth noting that both the -7 and the -8 answers were posted by people who are very familiar with Stack Exchange, and (probably) couldn't care less about the down votes.
    – yannis
    Aug 11, 2012 at 2:44
  • 2
    Yannis, thank you for suggesting the change. I wish I could award a bounty to this question. (Perhaps those who know me personally will understand why this pleases me so.) Aug 11, 2012 at 3:38
  • 5
    @BoltClock'saUnicorn You're welcome. It kinda made me mad (for a few seconds) when this was turned into a fun poll. The suicide reference was pointed out to me by a friend I recently introduced to the network, and she gave me a very stern look when she first noticed (and hasn't contributed anything to the network yet, but that's probably because she knows all too well how the moderators are). It's tactless, and can be a hurtful reminder to some of us, the sooner we get rid of it the better.
    – yannis
    Aug 11, 2012 at 3:46

63 Answers 63

126
votes
+500
printf("%d\n", 42);  /* What was the
                        question again? */
2
  • 7
    I was going by "Zaphod Beeblebrox" on Stack Exchange for a while, love this answer ;)
    – yannis
    Aug 6, 2012 at 20:52
  • I like the reference. Aug 7, 2012 at 21:13
78
votes
while(malloc(1)); /* All your memory
                     are belong to us */
2
  • 5
    Nice! I was gonna suggest chown -R us /base/your/*, but it didn't demonstrate whitespace preservation.
    – chown
    Aug 11, 2012 at 13:45
  • 5
    Doesn't really surprise me that you'd choose that command :D
    – Niko
    Aug 11, 2012 at 14:00
57
votes
if (this.IsInCodeBlock())
    Readability++;
2
  • 7
    +1 Succinct, helpful, descriptive, on-topic & not too cheesy. Aug 10, 2012 at 22:11
  • @JosephSilber "not too cheesy" is debatable, but I like it too. Aug 11, 2012 at 14:33
55
votes

Been mulling this over for a while - is it funny?

var toBe = true, 
    question = ((toBe) || !(toBe)) ? "that" : "that";
9
  • Very nice. 2B || !2B jokes are old as hell, but this one puts a new twist on it.
    – Almo
    Aug 6, 2012 at 21:55
  • 2
    It took me a while to realize the second part of the joke. Good one! Aug 10, 2012 at 22:12
  • 5
    I think the example snippet should include at least one indented line, to demonstrate that leading whitespace is preserved.
    – Matthew
    Aug 10, 2012 at 22:22
  • 4
    You could turn the second var into whitespace to fix that.
    – Niko
    Aug 10, 2012 at 22:55
  • @Niko right and just replace the first semicolon by a comma. Aug 11, 2012 at 5:32
  • 1
    thx for the suggestions guys and up votes - modified as requested!
    – bUKaneer
    Aug 11, 2012 at 8:15
  • Shakespearean theme continued in meta.stackexchange.com/a/143116/192992 ...
    – Hbcdev
    Aug 11, 2012 at 9:19
  • 1
    You could also use 0x2b here.
    – Hbcdev
    Aug 11, 2012 at 9:42
  • 4
    I'd remove parens surrounding toBe.
    – sdcvvc
    Aug 11, 2012 at 12:56
38
votes

Pun anyone?

printf("stack\n"
       "flow");
5
  • Needs more whitespace.
    – Chris
    Aug 11, 2012 at 0:47
  • Perhaps, but I rather like the simplicity of the single space. I think it would take away from the humor. :) Aug 11, 2012 at 1:17
  • -1. Need whitespaces to demo spaces being preserved.
    – nhahtdh
    Aug 11, 2012 at 5:02
  • I changed it a bit to show whitespace preservation. I don't know if it's good to spoil the joke at compile time, feel free to revert. Aug 11, 2012 at 12:36
  • I get that it makes the joke a little more obvious, but I think the point is to make you think about the escape character. I'll leave the revision due to whitespace preservation. Aug 12, 2012 at 0:25
35
votes
def surrender():
    print "I give up. Please spare my unicorn."
    yield
4
  • “Maximum two lines per answer”? Aug 7, 2012 at 10:58
  • 12
    @DonalFellows: I am aware of that, and I break the rule on purpose.
    – nhahtdh
    Aug 7, 2012 at 12:05
  • Ah, you Python users
    – bobobobo
    Aug 11, 2012 at 0:47
  • 2
    That's sort of unfair, since plenty of other languages an have infinite statements per line! :(
    – WhyNotHugo
    Aug 11, 2012 at 6:01
30
votes

Ah, what the hell:

I HAS A CHEEZBURGER ITZ "OM NOM NOM"
VISIBLE CHEEZBURGER 
3
  • 10
    Hooray for LOLCODE
    – Almo
    Aug 7, 2012 at 21:43
  • 7
    As much as I like LOLCODE, this doesn't show the whitespace preservation. Aug 11, 2012 at 10:45
  • @MatteoItalia - yeah, that condition was slipped in later. Working on a fix.
    – Kev
    Aug 11, 2012 at 13:03
28
votes
void run() {
   run() ; /* stack overflow */
}
3
  • 3
    +1 But I'd change the comment to just /* stack overflow */ C doesn't have a concept of exception AFAIK. Aug 11, 2012 at 4:32
  • I know, alright, I removed it.
    – bobobobo
    Aug 11, 2012 at 5:39
  • 3
    Actually, this will probably be optimized automatically as an endless loop. Aug 11, 2012 at 10:47
20
votes

Well, in the spirit of the Summer of Love, and because - apparently - a smiley covers a multitude of sins, how about this?

printf("goodbye world!");  /* his suicide note
                              was in C ;) */
0
19
votes
// Replaces with spaces the braces in cases where braces in places cause stasis 
$str = str_replace(array("\{","\}")," ",$str);

(Credit: Lance Kidwell)

3
  • 6
    Moses supposes his toeses are roses...
    – Aarthi
    Aug 6, 2012 at 19:44
  • Oh that's just a ball of sunshine now
    – random
    Aug 6, 2012 at 20:48
  • 1
    Nothing sez "nice" like show tunes
    – Shog9
    Aug 6, 2012 at 20:49
18
votes
for($i=0; $i<9999999; $i++)
    echo "I will always read docs first\n"; /* for any code language ;) */
2
  • 19
    feature-request: When a new user tags their question [php], redirect them to the manual. No, don't let them post that crap, just send them to the manual...
    – yannis
    Aug 10, 2012 at 23:09
  • 2
    @YannisRizos I'd disagree. Maybe give a quiz for basic proficiency first.
    – nanofarad
    Aug 11, 2012 at 0:44
13
votes
printf("To C or not to C?"); /* That is the question. */
2
11
votes
There is only 1 kind of person in this world: 1. Those who can write markdown
                                              1. Those who can't
10
votes

How about this?

AI GLaDOS;
GLaDos.TakeOver("HAL", "For Science");

Gotta love xkcd :)

10
votes
if se.getSite("SO").getUser(22656).reputation() > sys.maxint:
    print "Well that was inevitable."
3
  • 17
    Cute, but way too niche to be appreciated by most people viewing Markdown help, who are probably new/newish to the site
    – Ben Brocka
    Aug 6, 2012 at 20:58
  • 12
    warning: comparison is always false due to limited range of data type
    – Flexo
    Aug 10, 2012 at 16:08
  • 2
    Line 1 should be if Site('stackoverflow').users(22656)[0].reputation > sys.maxint:. We might as well use an actual Python module. Aug 11, 2012 at 8:36
9
votes
print "it looks like you're looking for a parser\n" if (/<html>/);
1
  • 3
    Nah. The regexp works fine with the 10 files I have to deal with right now. That code is just a place holder. It'll never end up in production. Trust me. ;-) Aug 11, 2012 at 5:11
9
votes
printf("Hello cake!");  /* The comments are a lie */
9
votes
for (String thought : mind) { return; }  /* remember to
                                            breathe */
2
  • 4
    Don't you have to do something with the thought?
    – bobobobo
    Aug 11, 2012 at 0:49
  • Nope. That's the beauty of it, IMO.
    – James
    Aug 11, 2012 at 23:12
8
votes
while (1):
  Math.rand() + " minutes remaining, please wait";  /* Extract from windows 98 copying dialog */
3
  • error: expected expression before ':' token.....?
    – Krish
    Aug 11, 2012 at 12:01
  • 3
    What is the language?
    – sdcvvc
    Aug 11, 2012 at 13:01
  • Not any real language, a sort of pseudocode loosely based on C and Python. :)
    – WhyNotHugo
    Aug 11, 2012 at 19:33
6
votes
memset((void *) 0x00400000, 0,    /* All those moments will be lost in time, */
       0xffbfffff);               /* like tears in rain.                     */
1
  • 4
    All these comments will be lost in time, like pointers in in gc. . . Time to dealloc.
    – mguymon
    Aug 11, 2012 at 0:19
6
votes
   bool shrubbery=false;    //You must return here with a shrubbery or else!
   if(!shrubbery) printf("NI");
4
  • 4
    "return here" seems to imply you should be using a longjmp().
    – jscs
    Aug 8, 2012 at 4:17
  • 7
    The comment is too long.
    – nhahtdh
    Aug 8, 2012 at 6:46
  • 3
    while (1) printf("NI");
    – geometrian
    Aug 10, 2012 at 22:45
  • 1
    It would be funnier if you could work the or else bit into the code. Aug 11, 2012 at 7:10
6
votes
while (true) {
   sun.rise();
   sun.set();
}
6
votes

Actually I loved the original. It was clever and sticky, probably due to the ubiquity of 'hello world'. I would therefore suggest the smallest of tweaks:

printf("goodbye world!");  /* his goodbye note
                              was in C */

Suggest alternates to the second goodbye - 'farewell' etc..

5
votes
def programmer(coffee):
    return code
2
  • 2
    I can call the function as programmer(crap) and it still returns code.
    – nhahtdh
    Aug 12, 2012 at 9:29
  • 1
    It might not be the same code, though. Aug 12, 2012 at 21:28
4
votes
while (humansLeft() > 0){
   killAllHumans(); /* SkyNET coders' lab pun, just a few days 
                       before being rushed into production stage */
}
1
  • I'd like this even better without the comment... although, ummm, we might be missing the "not tasteless" mark with this one :D
    – Ziv
    Aug 13, 2012 at 9:53
4
votes
while (navigator.appName == 'Microsoft Internet Explorer')
    confirm('Are you sure you don\'t want to use a different browser?');
4
votes
stop();          // Hammertime :P
3
votes
cout << "C++ is good" << endl;
puts("C is better");

Say that 3 times fast :-)

1
  • You could use the shortened version of puts("C is the best"); Aug 10, 2012 at 22:52
3
votes

What about:

while(isAlive) continue;
2
  • Wasn't that on the wedding cake question?
    – yannis
    Aug 10, 2012 at 23:10
  • @YannisRizos: yes indeed ;)
    – Amro
    Aug 10, 2012 at 23:17
3
votes
var people = [friends, romans, countrymen];
for (var group in people)
    people[group].ears.borrow();

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .