nice_num, mean_programmer
by in CodeSOD on 2008-11-28When Timothy stumbled across a function that had a vague name, no comments, and variables, he took a few minutes to try to break it down in his head.
static char *nice_num(long n)
{
int neg = 0, d = 3;
char *buffer = prtbuf;
int bufsize = 20;
if (n < 0)
{
neg = 1;
n = -n;
}
buffer += bufsize;
*--buffer = '\0';
do
{
*--buffer = '0' + (n % 10);
n /= 10;
if (--d == 0)
{
d = 3;
*--buffer = ',';
}
}
while (n);
if (*buffer == ',') ++buffer;
if (neg) *--buffer = '-';
return buffer;
}
"Why won't this stupid thing just... just... graagh!" The salesman clutched the edges of his massive keyboard tightly, his knucles white. While he looked angry, he wasn't actually angry; rather he was frustrated approaching angry.
The Mandatory Three (from Jim)
The billing application was slow. And not slow in the taking-30-seconds-to-start-up sense, but slow in the ridiculously-freaking-slow sense. Loading an invoice took between ten and fifteen minutes. Updating a line item on an invoice took up to a minute. And saving the invoice back to the database took even longer than loading it in the first place. Clearly, things couldn't stay this way – a minimum of 25 minutes to update a single invoice was completely unacceptable. They needed an expert. They needed... The Optimizer.

Tore S. had it made. He landed an enviable position that many of his fellow students had been gunning for – an evening/night shift as a Unix admin and general support for a large company that let him work from home. And you know what that means: equal time given to work and dancing around in your PJ's Risky Business-style. He could sleep and get paid for it, so long as he kept his cell phone on and would wake up and answer if/when it rang. Then he'd have to VPN into the network, do his thing, and then carefully weigh the decision to have another one-man dance party or go back to sleep. (Sleep usually won.)