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 2015

The Apple Genius

by in CodeSOD on

Apple refers to their in-store technicians as “geniuses”. Everyone on Earth knows that it’s nothing more than cute marketing and is a meaningless title.

Well, almost everyone. Derick worked for a company where the CIO worked at Apple’s HQ at some point. Said CIO was quite proud of this achievement, and made sure everyone knew it. He wasn’t happy that his new startup had decided to use C#, but it was okay: he was ready to reinvent core pieces of the .NET framework to avoid having to deal with whatever bombs Microsoft had snuck in.


Leaving an Honest Comment

by in CodeSOD on

Apo’s workplace just recently migrated their code into source control. They have eight years of code that’s been written and maintained by developers using a network share as their central repository.

// Special treatment for Attribute "weight unit"
// Needs to be mapped to more readable values for display because SAP is using some ISO codes that are not understandable
// by normal users. Hence, if we encounter this attribute, we map it to resemble an easier understandable unit
// Yes, this is all hardcoded, yes "one" should not do that
// Please redirect any complaints to the peeps who do budgeting and the customer who is not paying to do this properly
if (idAttribute_ == 18500) {
        if (textblock_ == "KGM") {
                textblock_ = "KG";
        }
        if (textblock_ == "MGM") {
                textblock_ = "MG";
        }
        if (textblock_ == "GRM") {
                textblock_ = "G";
        }
}

Collated Performance

by in CodeSOD on

Eliza had a co-worker who had a problem. There were users with names like “René”. Other users, using standard keyboards, wanted to search for “René”, but couldn’t be bothered to figure out how to type that accent, so they just searched for “Rene”.

The co-worker came up with this solution:


Elliptical Curveball

by in CodeSOD on

Why is it that you hear people saying, “don’t roll your own crypto”? It can’t be that bad, right? I mean, if the code gives the correct outputs when given the correct inputs?

Everything in cryptography depends upon “high quality” random numbers, and lots of them. People get into semi-informed flamewars about what “entropy” means, government agencies sneak backdoors into algorithms, performance matters, secrecy matters, and unpredictability matters. The standard which defines four randomness generators is NIST Special Publication 800–90. One of the four raised suspicions because it (Dual_EC_DRBG) was three times slower than any of the others.


Hang On…

by in CodeSOD on

Once upon a time, there was a small logistics company that did most of their software development in house. In the early 2000s, they decided to get ahead of the curve, and started building software to work on mobile devices. At the time, it was risky and uncertain, but over the next few decades, the idea of using commodity mobile phones to run their warehouse management software saved the company piles of money.

They grew so big that they cut the company into two parts- Inilogic, the big giant logistics company, and Initech, which made their mobile phone software. In the split, some developers went to Initech, while a few- like Mr. A- stayed with Inilogic.