Recent CodeSOD

Code Snippet Of the Day (CodeSOD) features interesting and usually incorrect code snippets taken from actual production code in a commercial and/or open source software projects.

Jul 2013

The Page at Fault

by in CodeSOD on

Long before humans walked the Earth, dinosaur network engineers noticed that networks could be slow sometimes. Sending thousands and tens of thousands of lines across a network could be a serious performance problem. A particularly clever Tyrannosaur used its stubby arms to type out the first paging algorithm.

This ancient technology is well understood. So this particular bug report perplexed Kamen:


It's Nobody's Baby

by in CodeSOD on

Daan O. arrived at work only to find all of his peers sitting in the conference room, looking scared; very scared! The salesman had snagged a new client by promising that all of their data from their current application could be trivially imported into Daan's company's primary product - no problem-o! Unfortunately, the salesman had not bothered to ask the new customer what the data looked like. Or in what format it existed. Or how much of it was there. Or if it was in any way consistent. He had just made the promise. Now it was their problem to make it all work. Unfortunately for Daan, he had been victimized assigned with the task of making the magic happen.

First, the data was delivered as a plethora of Excel spreadsheets, each one representing a table in the client database. Perhaps job-one should be to dump it all into scratch tables and try to work from there.


Ubertrim

by in CodeSOD on

Nav was not having a great day. He was remotely managing servers in the datacenter using Dell's iDRAC interface but the time it was taking to load was worse than an old lady with a walker trying to cross an intersection.

Nav checked the obvious spots - Were there any problems with the corporate Intranet? Email? Network drive? Ping? A little slow, maybe, but all were certainaly usable. So, he thought, What the heck could it be?


1 or 2 or 3 or 4

by in CodeSOD on

Brian knew his assignment for Software Engineering class would be trouble when he was put in a group with That Guy.

That Guy, as anyone could attest, was the one who burned down the chemistry lab. . . twice. He was That Guy who dropped a brick on the Dean’s sandal-clad foot in a failed physics experiment. He was That Guy whose actions led to a complete ban of aluminum foil in the campus cafeteria.


SQL Injection Not Found

by in CodeSOD on

The bug ticket complained, “When I try and update a certain page in the CMS, I get a ‘file not found’ error.” It included more details, explaining what page in specific was the culprit, but Michael was still confused. This application had been in use for over a decade, and no one had ever had a complaint like this. He also couldn’t replicate it, at least, not until he got the user to provide the specific text they were trying to use in the update.

As soon as he noticed the sentence: “Stop; declare your intent!”, he realized it must have something to do with their SQL injection protection .


PHP Doesn't Have Date Functions Either

by in CodeSOD on

We recently brought you the touching story of Shaun, and his coworker's mistaken belief that Perl has no built-in methods for working with dates. Well, Shaun can rest easy: he's not alone.

Apparently, PHP can't handle dates either.


Stringing a Replacement

by in CodeSOD on

Philip inherited a large Java application. It was the sort of application that needed to solve a clear business problem, so the original programmer started by building his own “template engine”, to simplify the process of generating output.

A template engine needs a simple way to do string replacements, but unfortunately, Java doesn’t offer a String class with a variety of “replace” methods for different situations. No, this Architect had to invent this wheel, using nothing but used chewing gum and his own wits.


Epoch Fail

by in CodeSOD on

One of Michael's employer's clients wanted a system to catalog and retrieve security videos. The resulting product was partly written in C++, partly written in PHP. The code is like poetry...really, really bad poetry.

One day, the client complained that the dates and times weren't being recorded right. Michael took a look in the database and double-checked the UNIX timestamps of a few on the web page. He confirmed that yes - they were recorded just fine. Surely the client must have been imagining things, Michael thought as he closed the bug as 'couldn't reproduce'.


May the Sad Force Be With You

by in CodeSOD on

A long, long time ago, in a software shop far, far away, clouds of bad management began to gather. The evil CEO, in his hooded shroud, commanded a dearth of Darth's that a powerful sphere-of-influence be built to help enforce His will. Rules and regulations would abound. Roles would be restricted. The twin suns were obscured and darkness covered the land.

It was the beginning of a period of Great Sadness.