Code read

5 October 2006

Oh sweet joy – Google have released a source code search engine. I can see many wonderfully beneficial uses for this product, the foremost being trying to find the weirdest, snidest or rudest programming out there. For example:

// ok, we advised him 3 times, we're not playing...
if ($AccessTable->check("core-exec-preban", 60, 3, 1)) {

    // creating new entry for this ip in our banlist ($banlist array is already declared)
    $banlist[getIP()] = time();

    // saving the new entry in the banlist
    $ban_fh = fopen(GEKKO_BLACKLIST, "w");
    fwrite($ban_fh, serialize($banlist));
    fclose($ban_fh);

    // showing him/her/it an non-friendly error message
    header("HTTP/1.1 403 Forbidden");
    echo "<h1>That's annoying!</h1>
    Do you have a girlfriend?

It’s also worth reading to see the measures geeks will take to gain one-upmanship in the obscurity stakes – for example, there are 200 results for “here be dragons“, but just two for “hic sunt dracones“. Oh, and it supports regular expressions, so you can do such fun searches such as “a{2,}rgh” (6000+ hits).

On a more serious note, the searches do reveal the odd moment of Anglo-American tension:

/* It's spelled COLOUR, for fuck's sake! */
if (p->term && !(p->misc_flags & SYSTEM_COLOR) &&

…and demonstrates the lengths developers go to consider the user:

/* The wanker can't remember his password */
if (login == NULL) {
	gdm_debug ("gdm_slave_wait_for_login: No login/Bad login");
	gdm_slave_greeter_ctl_no_ret (GDM_RESET, "");
	continue;
}

But the most cogent, persuasive and well-thought out comment for a block of code is surely this:

Linux egghunt implementation that searches a process'
address space for a second stage that is somewhere else
in memory.  spoonm doesn't think this is technically a
stager, but then again he also starred in that gay porno
back in the 70's.

5 Responses

Brilliant! Did these fantastic examples of programming take a lot of searching for or were you just lucky enough to happen upon them? Either way, gave me a good chuckle :D Thanks!

I particularly like the little slices of life you come across when you search for “aaaargh“.

Which I just noticed you already wrote about in the post, and I didn’t notice because my head isn’t working. In its place, I offer the related, and equally fun, “nooooooo“.

I’m guessing you don’t already read The Daily WTF then?

I do read The Daily WTF (semi-regularly) with glee, although the joy of this is that you get to see the code in its full, nasty, unexpurgated form, without the tweaks and obfuscations DWTF to protect the identities of the innocent (and the guilty…)