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.

Dec 2010

Classic WTF: A Date of Infamy

by in CodeSOD on

A Date of Infamy was originally published on January 11, 2006


Without many of the built-in date/time functions found in other languages, some Perl users can find themselves having to write some interesting code in order to get the results they want. Sure, it's pretty easy to reference the DateTime module, or a whole host of other modules to help with this, but who wants to use code that someone else invented? Some resort to fiddling with the number of seconds since epoch returned by the time() function. Others, such as Mike's predecessor, issue an operating system command to write the date out to text file, read the file back in, parse it, and use the result ...


WasDogKicked?

by in CodeSOD on

"Recently," Jon Beebe writes, "I was asked to bid a mobile version of an existing web site for a Credit Union."

"I started by inspecting their current site to see how much could be reused, and was instantly greeted by embeded javascript on the page"


Thorough Letter Checking

by in CodeSOD on

"I'm a network admin by day and a PHP freelancer by night," Jarod writes. "It works pretty well. My clients (all two of them) assign me low-priority, get-it-done-whenever type projects, and I do my best to deliver 'soon' rather than 'later'. "

"During the day job, I got a handful of calls from an unrecognized number. When I finally had a chance to call back, it was a referral who was in 'very desperate' to fix his application. Apparently, they hired a graphic design shop to build them a CMS site, and it was slow as molasses. They spent weeks trying to improve things, but it just got worse. Fortunately, I was able to look at it that evening, and after digging through the project, I isolated the problem. It was coming from an addressbook view; their addressbook had 120,000 entries, and displayed 50 at a time,"


Log Everything

by in CodeSOD on

Debugging and Logging are two valuable tools for isolating problems and errors in software. While debugging allows you to step-through currently executing code and get a “behind the scenes” view of the environment, logging is used as an audit trail to help find what happened when the code was executed.

Obviously, debugging is best for tracking down problems that are easily reproducible in a development environment, whereas logging is good for intermittent or unexpected problems. That is, “obviously” to everyone but Eric Polino’s coworker, Christophe.


Confessions: rachetingDateObject

by in CodeSOD on

One of the more curious perversions in information technology I’ve come across was one that I’ve written myself. Maybe I’m biased, but it was pretty rough: a poorly-implemented, over-engineered solution to a misunderstood problem. I’ll get around to digging that up one of these days, but in the mean time I thought I’d try something new: Confessions.

Years ago, Harry Dewulf was the Javascript Guru. Not only could he work around bugs in vendor software (thanks to Javascript injection in form field labels), but he worked around bugs in Javascript itself. Consider, for example, his replacement for the defective parseInt function which frequently didn't work.


YesNo

by in CodeSOD on

“The Original Developers believed in being thorough,” writes Aaron M “they also believed that ‘thorough’ meant having a stored procedure for every possible thing.”

“One of the more bizarre stored procedures I’ve come across is this.”