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

  • 3
    That's a bit flat. – random Aug 3 '12 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 '12 at 6:56
  • 3
    @Benjol Check the revision history, and blame Shog for everything ;) – yannis Aug 3 '12 at 8:39
  • 6
    " ... and thanks for all the fish" ? – Remou Aug 3 '12 at 14:23
  • 4
    I first read "temporary immorality". Your pun is better. – Gert Arnold Aug 3 '12 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 '12 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 '12 at 21:59
  • 1
    I'm quite sure we can get something nice from here. – Matteo Italia Aug 10 '12 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 '12 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 '12 at 0:41
  • 3
    45 answers, and I got notified for each one... Frak! – yannis Aug 11 '12 at 1:59
  • 1
    @DavidHyogo This is CW, votes neither earn or cost reputation (not to mention that Meta reputation is pointless). – yannis Aug 11 '12 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 '12 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.) – BoltClock's a Unicorn Aug 11 '12 at 3:38
  • 4
    @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 crazy 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 '12 at 3:46

63 Answers 63

2
votes

Perhaps we should go with the classics.

                 /* β */
write(1, "values of \xCE\xB2 will give rise to dom!\n", 36);

[citation: "Odd Comments and Strange Doings in Unix"]

2
votes
 Challenge challenge;
 challenge.Accepted();
2
votes
if(system("make me a sandwich") == EPERM) /* What? Make it yourself. */
    system("sudo make me a sandwich");    /* Okay. */
2
votes
printf("My God... It's full of stars."); //Ultimate out.
1
vote
for (int i = 0; i < 1; i++)
    printf("Hello universe!\n");
  • 3
    grow_horn(kHornColorPearlyWhite); – jscs Aug 6 '12 at 23:02
  • @Josh Caswell: It took me far too long, but I get it now. Thanks for the suggestion. ;-) – Jon Ericson Aug 10 '12 at 22:08
1
vote
printf("World. You don't exist.");  /* Chair, World Solipsist Society, 
                                       IT Section*/
1
vote
if (has_coffee(programmer))
    programmer.can_write_code = 1;
1
vote

A little ruby?

if desire == clarity
   puts inline ? "`" + code + "`" : (" " * 4) + code
1
vote
char* format_haiku[] = {"Indent as you please," "We optimize for code blocks"
                                                            "and beat poetry"};
1
vote
for f in `ls /your/base`; do 
    test `stat -f %Su "/your/base/${f}"` != "us" && chown -fLR us "/your/base/${f}"
done
0
votes
PRINT *,"Get off my lawn" !darn kids don't know a good language when they see one...
0
votes
for (score = 20; years == 7; ) { … }
  • I love this! Being a big Lincoln fan I am surprised I never heard/seen this one. +1 – John Riselvato Aug 11 '12 at 3:50
0
votes
while (1) 
    printf("Please Wait, it will take a second or two\n");
0
votes
my_love = "I YOU".split(" ") # split by SPACE
my_love.join(" LOVE ") # Joint by love
  • joint by love at the end?:-) – F.I.V Aug 12 '12 at 10:15
  • @AliFakoor yeah ;) – Pritesh Jain Aug 12 '12 at 11:56
0
votes
printf(4711 + ""); /* this code 
                    seems to smell */
-1
votes
Label1.Caption := 'Yes I am using Delphi and proud of that';
-1
votes
puts("Too many C programmers use printf for plain text strings!") ;
  • 8
    printf("Not enough C programmers use %s for plain text strings!", "puts"); – David X. Random Aug 11 '12 at 0:45
  • 3
    @DaveRandom printf( "%s", "printf - the only way to print!" ) ; – bobobobo Aug 11 '12 at 6:18
  • @bobobobo : Seems like a security tip , haha: use printf_s instead, nah? – F.I.V Aug 12 '12 at 10:25
  • puts() is shorter, and inserts a line ending at the end. puts(""); is equivalent to printf("\n");. But people tend to not use it. – bobobobo Aug 12 '12 at 14:09
-1
votes
if(alpha_checksum("xkcd") == 42) // Testing alpha_checksum implementation
    printf("[PASS] -- %s succeeded","xkcd");

Can never have too much xkcd, right?

-1
votes
def more_lovely_and_more_temperate(thee):
    return thou(thee) if thee > A_SUMMERS_DAY else A_SUMMERS_DAY
-1
votes
public void DoOrDoNot() { Try(); }
[Obsolete()] public void Try() { }
-1
votes
indent = is_code ? 4 : 0; // you can also use a tab space
-1
votes
for (unsigned int i = 10; i >= 0; i--)
    char *foo = alloca(42);
-3
votes

A silly meta-entry:

    std::string t, c; getline(getline(std::cin, t), c); std::cout << std::endl 
        << "    printf(\"" << t <<"\");\n        " << "/* " << c << " */\n";
-3
votes
printf("So Long and thanks for all the fish!"); // see you at the Restaurant at the end of the Universe
  • A down vote on a Douglas Adams reference? WTH is wrong with you people? – Grixxly Aug 11 '12 at 7:36
  • 1
    The top voted (so far) answer is a HHGG reference, and there are a few others as well - also "So Long and thanks for all the fish!" was posted as a comment to the question. Although I didn't down vote, I imagine seeing the same references all over the place it gets old soon. – yannis Aug 11 '12 at 8:55
-3
votes

For introduction to static methods...

Mythical ChuckNorris = null;
ChuckNorris.Method("My name evades NPEs");
  • 11
    Chuck Norris doesn't point to anything... Everything points to Chuck Norris.. – chown Aug 10 '12 at 23:44
-4
votes
if (i % 15 == 0) printf("FizzBuzz");  // think about why we have to ask 
                                      //     people to write FizzBuzz.
-4
votes

Cue groaning...

while(true) 
     points += answerQuestion();   // Symbolic gesture                  
-4
votes
for (int i = 0; i < 2; i += 1) { /* Cause two is
  a[i].aye();                       one two many */
}
  • 8
    You’ve commented out your own code. – tchrist Aug 11 '12 at 13:42
-5
votes

Technically a one-liner

array_walk(
    array('your mom\'s bedroom', 'a bar with a lawyer and a clown', 'kansas'),
    function (&$mordor) { 
        echo 'One does not simply walk into '.$mordor.".\n"; // OH YEAH!?
    }
);
-6
votes
my_problem=["stuck","under","flow"]
print '! '.join(my_problem)+ "! " # if you are pitying
  • 3
    I'm discovering my reputation cannot be negative. Good news!! – LostInTranslation Aug 11 '12 at 0:20

You must log in to answer this question.

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