Recent Articles

25 Nov 2015

Mid-Stream Switch

by Ellis Morning in CodeSOD on 2015-11-25

Submitter James writes: "I'm working on a project that has as one of its components a Microsoft App for Excel 2013. My team lead wrote most of the app up to this point, and I'm adding features. While exploring her code, I ran into this little gem (in JavaScript):"

function ClearData() {
    var spn = document.getElementById("spntest");
    spn.innerHTML = "";
    var def = $.Deferred();

    var arBlankMiddle = new Array();
    var arNull = new Array();
    spn.innerHTML = "";
    for (var i = 1; i <= 50; i++) {
    spn.innerHTML = "";
    var arBlank = new Array();
   // arBlank.push(arBlankMiddle);

    arBlank = [[""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""]];
    spn.innerHTML = "";
    $.when(writeData("A1:A50", arBlank), writeData("B1:B50", arBlank), writeData("C1:C50", arBlank), writeData("D1:D50", arBlank), writeData("E1:E50", arBlank), writeData("F1:F50", arBlank), writeData("G1:G50", arBlank), writeData("H1:H50", arBlank), writeData("I1:I50", arBlank), writeData("J1:J50", arBlank), writeData("K1:K50", arBlank), writeData("L1:L50", arBlank), writeData("M1:M50", arBlank), writeData("N1:N50", arBlank)).done(function (res1, res2, res3, res4, res5, res6, res7, res8, res9, res10, res11, res12, res13, res14) {
        spn.innerHTML = "";

    //$.when(writeData("A1:A50", arBlank)).done(function (res1) {
    //    def.resolve();

    return def.promise();

10 Comments - Last Comment @ 18:50
24 Nov 2015
23 Nov 2015

Confession: The Coin-Flip Hash

by Remy Porter in CodeSOD on 2015-11-23

There are certain problems in computing that you generally shouldn’t tackle unless you’re planning to make it your life’s work. Don’t write your own date handling logic. Don’t write your own encryption. If you do, you’ll probably screw it up, so use something developed by someone who knows what they are doing.

Handling passwords is a subset of encryption, in many ways. Samuel sends this to us as a confession- he hopes to unburden himself of his sins. It’s bad enough that he’s passing passwords in the clear, but he goes a step farther:

48 Comments - Last Comment @ 17:29
20 Nov 2015

End User Experience May Vary by Region

by Mark Bowytz in Error'd on 2015-11-20

"I guess eight of the ports are English-only," Andrew G. wrote.

54 Comments - Last Comment @ 2015-11-23
19 Nov 2015

The Cleaner

by Remy Porter in CodeSOD on 2015-11-19

In software development, there are people who get the unenviable task of being the cleaner. Somebody makes a mess, and the cleaner comes in to take care of it. And that brings us to Tina.

I'm Winston Wolf. I solve problems.

Tina was brought in as a cleaner. There was an application that was a mess , and the powers-that-be wanted it taken care of. Tina took a look, and she noticed that there were a lot of round trips to the database. In fact, after profiling, it almost looked like every query ran at least twice. She saw code following this pattern everywhere:

56 Comments - Last Comment @ 2015-11-23
18 Nov 2015
17 Nov 2015

A Hardware Switch

by TJ Mott in CodeSOD on 2015-11-17

Michele S. had recently worked on code for an engine-controlled device. Since the device had physically-moving parts operated by servos, the software had to be careful to not move anything out of bounds because it could actually break a physical piece of equipment.

Michele had written the low-level function which sets the position of a component.

145 Comments - Last Comment @ 11:50
16 Nov 2015
13 Nov 2015

Who Stole the Search Box?!

by Mark Bowytz in Error'd on 2015-11-13

"Why, thank you, Microsoft, I do need assistance with... wait a minute!" Steve L. writes.

48 Comments - Last Comment @ 2015-11-16
12 Nov 2015
11 Nov 2015

Confession: rect.Contains(point)

by Remy Porter in CodeSOD on 2015-11-11

A few years ago, Josip M decided to try his hand at building games using C# and the XNA framework. He started implementing the classic board game, Nine Men’s Morris, but like most side projects, he lost interest and mostly forgot about it…

…until a few months ago, when he started cleaning up his hard drive, and found the code again. Then he remembered why he lost interest and abandoned the project:

32 Comments - Last Comment @ 2015-11-17
10 Nov 2015
09 Nov 2015

Bonus WTF: Karmic Cascade

by Remy Porter in Announcements on 2015-11-09

Our sponsors at Infragistics have a special treat over on their blog: an extra feature for today. It's a story of teamwork and "teamwork", and of course- disaster.

Infragistics Check it out.

43 Comments - Last Comment @ 2015-11-12
09 Nov 2015

All Wrapped Up

by Remy Porter in CodeSOD on 2015-11-09

PHP has a lot of warts, and one of those warts is its approach to database interactions. If you want to talk to a MySQL database, every function for doing it is prefixed mysql_, and for say, Postgres, you’d use functions prefixed pg_. On the other hand, it uses an object oriented approach for talking to SQLite3, while Oracle not only has a set of oci_ prefixed functions, but has to add a bunch of important functions that make it just different enough as to be difficult to switch to.

It’s a bit of a mess, is the point, and the result is that a lot of developers will write some wrapper functions to make it easier to write generic code that’s not tied to a specific database engine. That is, presumably, what Scott’s co-worker had in mind when building this library of wrapper functions:

90 Comments - Last Comment @ 2015-11-11
06 Nov 2015

In Memoriam

by Mark Bowytz in Error'd on 2015-11-06

"I went to get my stuff off the printer at work but it appeared to have passed," writes Kelly B..

51 Comments - Last Comment @ 2015-11-10
05 Nov 2015
04 Nov 2015

Circle Space

by Jane Bailey in CodeSOD on 2015-11-04

Are you satisfied with your service today?

Answer a brief survey and enter to win a New* IPAD!!!!**


21 Comments - Last Comment @ 2015-11-05
03 Nov 2015
02 Nov 2015

Bonus WTF: Happy Birthday, George Boole

by Alex Papadimoulis in CodeSOD on 2015-11-02

Today is George Boole's 200th Birthday. We've rerun this classic many times, but I can't think of a better time to reshare it! - Remy

The problem with "logic" is that it makes things out to be nothing but simple dualities. Proponents of logic want us to believe that everything is true or false, black or white, yes or no, paper or plastic, etc. Thankfully, there are some among us, like Mark Harrison's colleague, who are not afraid to stand up to these logic advocates and shout "no, I will not succumb to your false dichotomies!" Today, I think we all should salute those few brave people ...

35 Comments - Last Comment @ 2015-11-10
02 Nov 2015

Shadow Over XML

by Remy Porter in CodeSOD on 2015-11-02

Halloween may be over, but it’s always a good time for a horror story.

Like many horror stories, Nick’s starts with a mysterious inheritance from a long-gone predecessor. This tool manages student data, and it needs to pull data from documents in Microsoft Word XML, using C#.

59 Comments - Last Comment @ 2015-11-11