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.

May 2009

All Pain, No Gain

by in CodeSOD on

"My company has very strict policy on direct access to the database," Steve writes, "no hand-built SQL in the front-end code and always use a stored procedure to access the data. The reasoning behind this was simple and sound: Avoid SQL injection attacks and increase database performance. "

"The execution, however, was not so simple and sound. They went through all the pain of needing to use stored procs, but none of the gain. I'll leave it as an exercise to the reader to see why."


Plain Old Regexs

by in CodeSOD on

Net 10Unlike just about all of his friends, family, and coworkers, Jack doesn’t have a fancy cell phone. No streaming video, no Bluetooth, and certainly no “apps”. Heck, it doesn’t even have a camera. It’s just a plain old phone with plain old service that can only dial and receive plain old calls. And it’s exactly the type of phone that Jack wants.

Because Jack hardly ever uses his cell phone, the whole monthly bill with annual commitments didn’t make a whole lot of sense, so he went the prepaid route with a company called Net10. Like all wireless providers, Net10 provides online account maintenance and – going along with the “plain old” model – their web app is barebones and a bit clunky at times.


Can You Say Your $a, $b, $c's?

by in CodeSOD on

For as long as he could remember, one Millan C's clients had always bragged about having their very own, in-house PHP Guru. "You could really learn something from this guy," they would often tell him, "he's brilliant, you know! And a guru!" Not being a particularly big fan of PHP, nor really interested in meeting the guru, Millan always put it off for "some day."

One day, however, it was pretty clear that "some day" would never happen, as the guru left for greener pastures. "It couldn't have been worse timing," Millan's client said frantically, "our website's traffic exploded, and everything is slowing to a crawl! The guru's consulting rate is just too high for us... can you fix it?"