
The Daily WTF | Curious Perversions in Information Technology
2,215 FOLLOWERS
The Daily WTF (also called Worse Than Failure from February to December 2007) is a humorous blog dedicated to "Curious Perversions in Information Technology". Subscribe to keep up with latest updates from this blog.
The Daily WTF | Curious Perversions in Information Technology
22h ago
Daniel recently found this pair of stored procedures. While the code within them is simple, they hint at horrors just beyond the edge of the stage, the kinds of things that might drive one mad.
CREATE PROCEDURE [dbo].[sp_SomeProc]
@ID VARCHAR(6)
AS
IF @ID = '109369'
BEGIN
DELETE FROM table1
WHERE ID = '109369'
END
IF @ID = '100976'
BEGIN
DELETE FROM table1
WHERE ID = '100976'
END
GO
CREATE PROCEDURE [dbo].[sp_SomeOtherProc]
@ID VARCHAR(6)
AS
IF @ID = '109369'
BEGIN ..read more
The Daily WTF | Curious Perversions in Information Technology
2d ago
"The Colonial" was trawling through some code they inherited, and found this approach to doing exceptions in C#:
public enum ReturnCode : int
{
Success = 0,
Enum1 = 100,
Enum2 = 110,
// *snip* - LOTS of enums
// .
// .
UnknownError = 998,
Exception = 999
};
Whitespace in the original.
So, instead of using structured exception handling, we return enums from functions to represent our status codes. This almost makes me assume that this is a case of a C ..read more
The Daily WTF | Curious Perversions in Information Technology
3d ago
As a native English speaker, I've inherited a very chaotic perspective on language: "correct" language is defined by usage, loan words are less "loaned" and more like the mandolin someone leant me 20 years ago- mine now. New words can be ginned up on the fly, and parts of speech are just a suggestion.
Many other languages don't take this approach. French, for example, is defined by the Académie Française. There is a standard, and officially correct way to use French. In programming terms, we could say that French is C, while English is Perl.
A good example of French is that, years ago, as emai ..read more
The Daily WTF | Curious Perversions in Information Technology
4d ago
It's a holiday weekend in the US, which means we dip back into the archives for a classic story. This one remembers the good old days, of greenbar paper and programs that can't handle large numbers because they don't have the memory for it. Original -- Remy
The daisy wheel stabbing at green-lined sheets could have been Satan’s fanfare, but Andy was long accustomed to tuning out ambient printer noise. It was 1982, and he spent most of his time before his Commodore PET 4032, churning out useful things in 6502 Assembly. Most of the code was for printing invoices, much like customer invoice curren ..read more
The Daily WTF | Curious Perversions in Information Technology
1w ago
Scraping the bottom of the barrel this week, we accepted a couple of submissions that aren't, by any means, Errors. But they're undoubtedly amusing to the likes of those who haunt these pages, and as such, bon appetit.
Diner Dave A. wondered "I wasn't sure if you would really accept this as an Error'd, because it only *looks* like an error, which is why it caught my eye, but it isn't! So, on with the snark: You'd think there'd be Null chance that someone would name a restaurant like this, right? But NO! (Or as YAML would say, Norway!) This really exists -- I haven't been there yet but at the v ..read more
The Daily WTF | Curious Perversions in Information Technology
1w ago
We've already picked on bad logging code this week, but we haven't picked on PHP in awhile, so let's look at some bad PHP logging code, from Kris.
$path = self::getPath();
if (file_exists($path)) {
$content = file_get_contents($path);
} else {
$content = "";
}
$content .= "\n" . date('Y-m-d H:i') . " | " . $message;
file_put_contents($path, $content);
This is the interior of the log function, which takes a logging message and outputs it to a file.
The "magic" in this code is the call to file_get_contents, which loads an ..read more
The Daily WTF | Curious Perversions in Information Technology
1w ago
Strings in C remain hard. They're complicated- they're complicated because of null termination, they're complicated because of memory management, they're complicated because of the behaviors of const. There's a lot going on in C strings.
But Alice had a simple case: convert a true or false value into the string "true" or "false". Let's see how her co-worker solved this:
char* __comps_num2boolstr(COMPS_Object* obj) {
char *ret;
char *_bool;
if (((COMPS_Num*)obj)->val) {
_bool = "true";
} else {
_bool = "false";
}
ret = malloc(sizeof(char) * (strlen(_b ..read more
The Daily WTF | Curious Perversions in Information Technology
1w ago
The list of things never to write yourself contains some obvious stars: don't write your own date handling, your own encryption, your own authentication/authorization. It's not that no one should write these things, it's that these domains all are very complicated, require a great deal of specialized knowledge, and while easy to get almost correct, they're nearly impossible to get actually correct. If you embark on these tasks, it's because you want to create a product that solves these problems, hopefully not because you've got a terminal case of NIH syndrome.
While it's not as big a star on ..read more
The Daily WTF | Curious Perversions in Information Technology
1w ago
Sami inherited some C# LINQ code. The actual behavior and purpose of this code is fairly simple. The way the code was written, however, well…
foreach (var operatingMode in ahu.CalculationData.OperatingModes) { operatingModesModel.OperatingModeNames.Add
(operatingModeNumber, operatingMode.OperatingModeName); var
innerOperatingModeNumber = operatingModeNumber; foreach (var
property in from partData in operatingMode.PartDatas.Where(p
=> p.PartGuid == partGuid) let finalOperatingModeNumber =
innerOperatingModeNumber from property in (from resultProperty
in this.GetProperties(partData).Whe ..read more
The Daily WTF | Curious Perversions in Information Technology
2w ago
We received a surfeit of submissions this week. The choices below were selected almost at random, but coincidentally two of them were sent in by regular reader Michael R. to start things off.
Said Michael "Reading CodeSOD on 2023-05-15 made me brush up my knowledge of log. Little did I know that it comes with its own defects. Thank you Google." If you were a mathematician, and wanted to build a wooden table, what else would you use?
Excited by his discovery, Michael took himself to the theatre to celebrate with a wee tipple but found himself stuck in a rounding dilemma. "So today I w ..read more