OR 

CodeSOD: What a Happy Date

As is the case with pretty much any language these days, Python comes with robust date handling functionality. If you want to know something like what the day of the month is? datetime.now().day will tell you. Simple, easy, and of course, just an invitation for someone to invent their own. Jan was witness to a little date-time related office politics. This particular political battle started during a code review. Klaus had written some date mang

favicon of http://thedailywtf.com

CodeSOD: Bunny Bunny

When you deploy any sort of complicated architecture, like microservices, you also end up needing to deploy some way to route messages between all the various bits and bobs in your application. You could build this yourself, but you‘ll usually use an off-the-shelf product, like Kafka or RabbitMQ. This is the world Tina lives in. They have a microservice-based architecture, glued together with a RabbitMQ server. The various microservices

favicon of http://thedailywtf.com

Internship of Things

Mindy was pretty excited to start her internship with Initechs Internet-of-Things division. Shed been hearing at every job fair how IoT was still going to be blowing up in a few years, and how important it would be for her career to have some background in it. It was a pretty standard internship. Mindy went to meetings, shadowed developers, did some light-but-heavily-supervised changes to the website for controlling your thermostat/camera/refrige

favicon of http://thedailywtf.com

This Process is Nuts

A great man once said I used to be over by the window, and I could see the squirrels, and they were merry. As pleasing of a sight as that was, what if the squirrels werent merry? Grady had an unpleasant experience with bushy-tailed rodents at a former job. Before starting at the Fintech firm as a data scientist, he was assured the Business Intelligence department was very advanced and run by an expert. They needed Grady to manipulate large dat

favicon of http://thedailywtf.com

CodeSOD: A Truly Painful Exchange

Java has a boolean type, and of course it also has a parseBoolean method, which works about how youd expect. Its worth noting that a string true (ignoring capitalization) is the only thing which is considered true, and all other inputs are false. This does mean that you might not always get the results you want, depending on your inputs, so you might need to make your own boolean parser. Adam H has received the gift of legacy code. In this case,

favicon of http://thedailywtf.com

Error‘d: What About the Fish?

On the one hand, I dont want to know what the fish has to do with Boris Johnsons love life...but on the other hand I have to know! Mark R. writes. Not sure if thats a new GDPR rule or the Slack Mailbots weekend was just that much better then mine, Adam G. writes. Connor W. wrote, You know what, I think Ill just stay inside. Its great to see that an attempt at personalization was made, but whatever happened to trust but verify? writes Rob H.

favicon of http://thedailywtf.com

CodeSOD: Some Kind of Magic

We all have our little bits of sloppiness and our bad habits. Most of us have more than one. One place Im likely to get lazy, especially as Im feeling my way around a problem, is with magic numbers. I always mean to go back and replace them with a constant, but sometimes theres another fire you need to put out and you just dont get back to it till somebody calls it out in a code review. Then, of course, there are the folks who go too far. I once

favicon of http://thedailywtf.com

CodeSOD: A Devil With a Date

Jim was adding a feature to the backend. This feature updated a few fields on an object, and then handed the object off as JSON to the front-end. Adding the feature seemed pretty simple, but when Jim went to check out its behavior in the front-end, he got validation errors. Something in the data getting passed by back his web service was fighting with the front end. On its surface, that seemed like a reasonable problem, but when looking into it

favicon of http://thedailywtf.com

Error‘d: Intentionally Obtuse

Normally I do pretty well on the Super Quiz, but then they decided to do it in Latin, writes Mike S. Uh oh, this months AWS costs are going to be so much higher than last months! Ben H. writes. Amanda C. wrote, Oh, neat, Azure has some recommendations...wait...no...just kidding I guess? Here I never thought that SQL Server log space could go negative, and yet, here we are, Michael writes. I love the form factor on this motherboard, but I

favicon of http://thedailywtf.com

CodeSOD: A Loop in the String

Robert was browsing through a little JavaScript used at his organization, and found this gem of type conversion. //use only for small numbers function StringToInteger (str) { var int = -1; for (var i=0; i=100; i++) { if (i+ == str) { int = i; break; } } return int; } So, this takes our input str, which is presumably a string, and it starts counting from 0 to 100. i+ coerces the integer valu

favicon of http://thedailywtf.com

Error‘d: Choice is but an Illusion

If you choose not to decide which button to press, you still have made a choice, Rob H. wrote. If you have a large breed cat, or small dog, the name doesnt matter, it just has to get the job done, writes Bryan. Mike R. wrote, Thanks Dropbox. Becuase your survey cant add, I missed out on my chance to win a gift card. Way to go guys... There was a magnitude 7.1 earthquake near Ridgecrest, CA on 7/5/2019 at 8:25PM PDT. I visited the USGS ear

favicon of http://thedailywtf.com

CodeSOD: Swimming Downstream

When Java added their streams API, they brought the power and richness of functional programming styles to the JVM, if we ignore all the other non-Java JVM languages that already did this. Snark aside, streams were a great addition to the language, especially if we want to use them absolutely wrong. Like this code Miles found. See, every object in the application needs to have a unique identifier. So, for every object, there‘s a method mu

favicon of http://thedailywtf.com

CodeSOD: Nullable Knowledge

You‘ve got a decimal value- maybe. It could be nothing at all, and you need to handle that null gracefully. Fortunately for you, C# has ‘nullable types‘, which make this task easy. Ian P‘s co-worker made this straightforward application of nullable types. public static decimal ValidateDecimal(decimal? value) { if (value == null) return 0; decimal returnValue = 0; Decimal.TryParse(value.ToString(), out returnValue); return

favicon of http://thedailywtf.com

Error‘d: Nice Day for Golf (in Hades)

A coworker was looking up what the weather was going to be like for his tee time. He said he‘s definitely wearing shorts, writes Angela A. I guess whenever a company lists welding in their LinkedIn job posting you know that theyre REEAALLY serious about computer hardware, Andrew I. writes. Chris A. wrote, It was game, set, and match, but unfortunately, someone struck out. Bruce C. writes, Im not surprised that NULL is missing some dea

favicon of http://thedailywtf.com

CodeSOD: Close to the Point

Lena inherited some C++ code which had issues regarding a timeout. While skimming through the code, one block in particular leapt out. This was production code which had been running in this state for some time. if((pFile) (pFile != (FILE *)(0xcdcdcdcd))) { fclose(pFile); pFile = NULL; } The purpose of this code is, as you might gather from the call to fclose, to close a file handle represented by pFile, a pointer to the handle. This co

favicon of http://thedailywtf.com

CodeSOD: Seven First Dates

Your programming language is PHP, which represents datetimes as milliseconds since the epoch. Your database, on the other hand, represents datetimes as seconds past the epoch. Now, your database driver certainly has methods to handle this, but can you really trust that? Nancy found some code which simply needs to check: for the past week, how many customers arrived each day? customerCount = array(); result2 = array(); result3 = array(); result4

favicon of http://thedailywtf.com