Remy Porter

Computers were a mistake, which is why I'm trying to shoot them into space. Editor-in-Chief for TDWTF.

Apr 2016

Interned Sort

by in CodeSOD on

Caleb scored his first intership at a small, family-owned print-shop. Much to his surprise, the day before he started, their primary web-developer left for a bigger, more lucrative job. His predecssor was an experienced programmer, but came at solving problems in his own unique way. This meant no comments, no functions, no classes, SQL injection vulnerabilities everywere, and cryptic 500-character one-liners stuffed into the value attribute of an input tag.

Caleb spent his first day just trying to get the code running on his dev machine. On the second day, he sat down with a more experienced co-worker to try and understand some of the queries. For example, there was one query that needed to return product details sorted in some meaningful fashion- like by name. Weirdly, though, the page wasn’t sorting them by name, except when it was- no one who used the product search understood the sort order.


Twisted Branches

by in Feature Articles on

David pulled his headphones off when he heard a loud harrumph behind him. One of his project managers loomed in the doorway, and had obviously been standing there for some time, trying to get David’s attention.

“You pulled from Staging-Core branch into the Version–2 branch and broke Liam’s changes,” the PM said.


Mysterious Mysteries of Strange Mystery

by in Coded Smorgasbord on

Code is a window into the programmer’s mind. Our thought processes are laid bare, exposed and cemented for all eternity in keywords and symbols. It’s left there, waiting for another programmer to come by and wonder: “What were they thinking?”

That’s exactly what “seebs” was wondering, when he found this PHP code.


And It's Collated

by in CodeSOD on

As anyone who’s ever written a c-style char * string knows, strings are much more complicated than they look. This is even more true in this modern era of Unicode and character encodings and multilingual applications. How does “ä” compare to “a” or “á”?

John Moore’s company sent some code to a contracting firm. They needed to strip off any diacritics and unusual characters when they were comparing strings, so that “ä” and “å” were treated as the same character when searching- a not uncommon problem. In Java, there’s a special family of classes inheriting from Collator which can be used to solve exactly that problem. Now, most developers aren’t deeply familiar with these, so seeing a contractor that turns in a more “home brewed” approach is hardly surprising.


A Testy Voice

by in Feature Articles on

“This,” Gregor said by way of introduction, “is Jack. Jack’s our new highly paid consultant.”

Rita shook Jack’s hand. Jack was the kind of person who entered a handshake with a dominant, overhand approach, and then applied too much pressure while he smiled at you. He wanted you to know, he was a take charge kind of guy.


isAlive

by in CodeSOD on

Why are we here? What is the purpose of life? What does it even mean to be alive?

No, I haven’t been hanging out in coffee shops wearing a beret and discussing philosophy. I’ve instead been puzzling over this code, from Nikolai K.


The Three Second Rule

by in CodeSOD on

The “Five Second Rule” is, of course, a myth. If you drop a food item on the ground, the bacteria living on the ground aren’t going to wait five seconds before moving in. Besides, everything you stuff in your face is already covered with all sorts of bacteria anyway. You have an immune system, you might as well use it.

Adolphus Mannz recently gave his immune system a bit of a workout. In their SalesForce system, they needed a way to determine if a record was being added to the system or updated, and perform some slightly different logic in each case. His fellow developer came up with this rather ugly solution.