Jake Vinson

Nov 2008

nice_num, mean_programmer

by in CodeSOD on

When 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;
}

I Can't See What You're Saying

by in Feature Articles on

"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 year was 1984, and the PC was finally moving out of the "early adopter" range and companies started sending them out into the field. Ricky happened to be working at a help desk during this exciting time, aiding in the rollout of the shiny new PCs to various teams in the company. Unfortunately for him, one of the first teams that needed the PCs most desperately was also one of the departments least able to understand and use them – sales.


The Mandatory Three, The Easy Road to Success, and Relevant Inexperience

by in Tales from the Interview on

The Mandatory Three (from Jim)
After the dot com bust, I spent a lot of time interviewing. It was mostly dead ends or companies that were only willing to hire one person to do the job of four (specifically, the four that they had just laid off). A friend of mine who worked at a school, told me about an IT position there. Being out of work for so long, I was very eager to get in for an interview, and figured I might have an "in" since he was working there already.

When I arrived at the interview, there were two other candidates waiting. I was to go in first, and I was informed that all three of the interviews would be done in "rapid fire" succession, and each would take just 30 minutes. I went into their conference room, and was a bit startled by the fifteen people sitting around the table. This was known as "The Gauntlet." This group of people only asked a few, fairly non-technical questions. Most seemed bored, and some occasionally looked at their watches and yawned! Now, I am not the most exciting person in the world, but I am certainly not that boring. I finished the interview and left feeling quite confused. What the hell just happened?


DOLLARS and SENSE

by in Feature Articles on

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.

Kent had earned his reputation by making a simple but dramatic improvement in another application's performance. A database server had been set up with the default cache size, 64KB. Seeing that it could have been using a full 16MB, he changed the setting and performance improved considerably. Simple as it was, he was immediately hailed as a hero, and because of that, the powers that be wanted to put him on the billing application.


Hidden Tax Moves

by in Feature Articles on

It was fall of 1995 and everyone was gearing up for the 1996 tax season. After years of maintenance of a DOS-based tax application, TaxQuik -- as we'll call the company -- had to get with the times. New, spunky companies were building tax software for Windows with fancy GUIs, integrated help and even Internet-enabled features, while TaxQuik was still in the text-based stone age of DOS.

The one thing that the new companies all lacked was the name recognition and brand loyalty of TaxQuik's customers. The company developed an aggressive plan to continue to support the DOS version, while simultaneously building a Windows version of the software. And by all accounts, the plan worked like a charm.


Act Fast!

by in Error'd on

Go ahead Michael Fulker, make your move. I'll count to one.


Keep it Simple and Stupid

by in CodeSOD on

Diego G. lives in Argentina and is working with a developer from the USA on a PHP project. Recently they were discussing the merits of handling the communication from the backend to the frontend via XML or JSON. The system used XML elsewhere already, but for the new work it looked like it'd be quicker and easier to work with JSON in the PHP pages.

The contact in the US didn't like one solution more than the other, and in the interest of getting the project done quickly, sent an email with his solution.


Mini Support Stories and Shake It, Baby

by in Feature Articles on

Having worked in support for years, Ben has amassed quite the compendium of quick stories.

Double-Click on My Computer
I was on a call with a lady who was having Internet connectivity issues. I listened to her describe what was happening and was just starting to guide her through a few things to try to find the problem. I asked her to double-click on My Computer to which she replied, "How can I double-click on your computer?" I had to hit mute and collect myself because I didn't see that one coming.


The Toggle that Wouldn't

by in CodeSOD on

"I work for a software development house that creates business software, maintaining legacy MFC applications," Graf writes. "We recently received an issue where a filter-toggle wouldn't switch back and forth, never changing from its default value. It's was a small utility function, rarely used, so we were a bit surprised to see it come up. Taking a quick glance at the code revealed the following:


$50 Cash Fast

by in Error'd on

I don't know, Dexter, I don't see anything weird about getting $50 fast cash...


Now I Have Two Hundred Problems

by in CodeSOD on

-rw-r--r--. If that looks familiar to you, skip this and the next paragraph.

OK, now that it's just you and me, Bill Gates, it is an example of Unix file permissions. The example given means that the user (owner) can read/write to the file, and others can only read it. Checking these permissions in Perl is simple; just use the stat method to check its mode (the file type and permissions). For example, if you wanted to check read permissions, you'd check bits 4 (owner read), 32 (group read), and 256 (other read). This is 292 in decimal, 0444 in octal. Compare that to the mode, and you'll know whether you can read the file. In code, stat($path)->mode & 0444. Easy peasy!


If I've Said It Once, I've Said It Fifty Times

by in CodeSOD on

I can think of several ways to improve the code below from Jeff S., or at least to reduce its line count by two or three.

function submitTrap3()
{
    var n = 0;
    var f =0;
    var elementItem = "";
    if (window.event.keyCode == 13)
    {
        for (n=0;n<document.forms[0].elements.length;n++)
        {
            elementItem = document.forms[0].elements[n].name;
            if ((document.forms[0].elements[n].value != "") &&
                (elementItem == trim(document.forms[0].txtControlName.value)))
            {
                switch (elementItem)
                {
                    case "header1:SearchBox" :
                    {
                        __doPostBack('header1:goSearch','');
                        break;
                    }
                    case "Text1":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text2":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text3":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text4":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text5":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text6":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text7":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text8":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text9":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text10":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text11":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text12":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text13":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text14":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text15":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text16":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text17":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text18":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text19":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text20":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text21":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text22":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text23":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text24":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text25":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text26":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text27":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text28":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text29":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text30":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text31":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text32":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text33":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text34":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text35":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text36":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text37":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text38":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text39":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text40":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text41":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text42":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text43":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text44":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text45":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text46":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text47":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text48":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text49":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text50":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                }
            }
        }
    }
}

Circling the Solution

by in Feature Articles on

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.)

One fine Saturday morning around 11:00, Tore was sound asleep, visions of sugarplums dancing in his head – only to have his wonderful dream violently interrupted by the screech of his cell phone. Tore squinted, rubbed his eyes, and read the caller ID. Damn, it was work. He quickly practiced saying "hello" without sounding tired, and then answered.