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 2008

The Lesser Date

by in CodeSOD on

Generally when Jared has to compare two dates, he'll do something simple like "if (date1 < date2) ..." A contractor no longer under his company's employ had his own unique approach...


A Bit of Closure

by in CodeSOD on

"After our UI developer left," Danny writes, "I was tasked with figuring out why one of our admin pages would get stuck in the middle of the loading screen."

"I know creating named functions for every callback can be a pain, but this a little ridiculous...


tblTimesheet

by in CodeSOD on

Not too long ago, Erik was hired to do extend and maintain a timesheet application for an employment agency. It was an ASP/VBScript web-app with data that lived in the Everything Database: a single SQL Server database filled with random tables from all sorts of various applications.

After paging through the tables, Erik found a few that seemed to be for the timesheet application. The first one he opened up was tblTimesheet.


I'm Dave, Oh Yeah!

by in CodeSOD on

Originally posted in the sidebar, "Throgdor the Bold" was having a few JavaScript issues on Houston Chronicle's site and took a peek at the source code. At the bottom of their utils.js, he noticed this...

setTimeout(check4Dave,2000);
function check4Dave() {
  if (document.cookie.match('ImDaveOhYeah')) {
    s=document.body.appendChild(document.createElement('script'));
    s.id='fs';
    s.language='javascript';
    s.src='http://www.chron.com/apps/emdjcs/specialDave.js';
  }
}

Yes, the Table is Still There

by in CodeSOD on

"Having recently upgraded my forum software," Kinta wrote, "I noticed that my site had been running incredibly slow."

"Upon further investigation, I found that that the following code was being run once for each and every comment on a page, whenever ever a forum thread was opened.


Document Dis & Naked in the CIA?

by in CodeSOD on

Document Dis (from Lawrence)

When I was working at my first job, we had gotten the display code worked on by one of our subcontractors. When perusing the codebase, I came across one small source file which had the following near the top of the file: