Subscribe: The Daily WTF
Added By: Feedage Forager Feedage Grade B rated
Language: English
candidate  code  data  district  electoral district  file  micah  might  party  read  samuel  variable } if  variable  write  } if variable  } if 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: The Daily WTF

The Daily WTF

Curious Perversions in Information Technology

Last Build Date: Thu, 27 Jul 2017 22:59:47 GMT


Table 12

Thu, 27 Jul 2017 10:30:00 GMT

We've all encountered database tables that look like this: ID Data ----- -------------------------------------------- 00001 TRUE, FALSE, FILE_NOT_FOUND 00002 MALE|FEMALE|TRANS|EUNUCH|OTHER|M|Q|female|Female|male|Male|$ 00003 ... 00004 1234|Fred,Lena,Dana||||||||||||1.3DEp42| Oh the joy of figuring out what each field of each row represents. The fun of deciphering the code that writes and reads/parses each row of data. In a moment, you will fondly look back on that experience as the Good-Old-Days. The task of administering elections in the Great White North is handled by the appropriately-named agency Elections Canada. As part of their mandate, they provide the results of past elections in granular detail, both as nicely formatted web pages and as downloadable raw files. The latter are meant to be used by researchers for studying how turnout varies across provinces, ages, races, etc., as well as arguing about the merits of proportional representation versus single transferable votes; and so forth. One of the more comprehensive data files is descriptively known as Table-Twelve, and it contains a record for every candidate who ran in the election. Each record contains how many votes they got, the riding (electoral district) in which they competed, their affiliated party, home town, occupation, and hundreds of other details about the candidate. This file has been published for every election since the 38th general in 2004. Vicki was charged with creating a new parser for this data. Table-Twelve is a CSV file in the same way that managers describe their new agile process as
. While parsing a CSV file in general is no big deal, writing a function to parse this data was far harder than she expected. For one thing, the column titles change from year to year. One might think Who cares, as long as the data is in the same sequence. One would be wrong. As an example, depending upon the year, the identifier for the electoral district might be in a column named "Electoral District Name", "Electoral District" or "District", and might contain a string representing the district name, or a numeric district identifier, either of which may or may not be enclosed in single or double quotes. Just to make it interesting, some of the quoted strings have commas, and some of the numbers are commafied as well. Further inspection revealed that the columns are not only inconsistently named, but named so as to be completely misleading. There's a column labeled "Majority". If you're thinking that it contains a boolean to indicate whether the candidate got a majority, or 50%+1 of the number of cast votes (i.e.: "How many votes do you need for a majority?"), you'd be mistaken. Nor is it even a slight misuse (where it should have been "Plurality"). Instead, it's the delta between the winning candidate and the second-place candidate in that riding. They also helpfully give you the quotient of this delta to the total cast votes as the "Majority Percentage". Canada has a parliamentary system; it's also important to know how many candidates of each party won, so the party designation is obviously going to be easy to access, right? Or maybe you'd like to sort by surname? Well, it turns out that the party is appended to the field containing the candidate's name, delimited with a single space (and possibly an asterisk if they were incumbent). But the candidate's name and the party are already each a variable number of words (some have middle names or two surnames) delimited by single spaces. The party name, however, must be given in both English and French, separated by a forward slash. Of course, some parties already have a slash in their name! Oh, and if the candidate didn't run as a member of a party, they might be listed as "Independent" or as "No affiliation"; both are used in any given file. Above and beyond the call of making something difficult to parse, the files are f[...]

CodeSOD: The Nuclear Option

Wed, 26 Jul 2017 10:30:00 GMT

About a decade ago, Gerald worked at a European nuclear plant. There was a “minor” issue where a controller connected to a high-voltage power supply would start missing out on status messages. “Minor”, because it didn’t really pose a risk to life and limb- but still, any malfunction with a controller attached to a high-voltage power supply in a nuclear power plant needs to be addressed. So Gerald went off and got the code. It was on a file share, in a file called Or, wait, was it in the file called Or Or, It took a few tries, but eventually he picked out the correct one. To his surprise, in addition to the .c and .h files he expected to see, there was also a mysterious .xls. And that’s where things went bad. Pause for a moment to consider a problem: you receive a byte containing an set of flags to represent an error code. So, you need to check each individual bit to understand what the exact error is. At this point, you’re probably reaching for a bitshift operator, because that’s the easiest way to do it. I want you to imagine, for a moment, however, that you don’t really know C, or bitwise operations, or even what a bit is. Instead, you know two things: that there are 255 possible error codes, and how to use Excel. With those gaps in knowledge, you might perhaps, just manually write an Excel spreadsheet with every possible option, using Excel's range-drag operation to fill in the columns with easily predictable values. You might do this for 254 rows of data. Which, as a note, the range of possible values is 255, so guess what was causing the error? if (variable== 0 ) { a= 0 ; b= 0 ; c= 0 ; d= 0 ;e= 0 ;f= 0 ;g= 0 ;h= 0 ;} if (variable== 1 ) { a= 1 ; b= 0 ; c= 0 ; d= 0 ;e= 0 ;f= 0 ;g= 0 ;h= 0 ;} if (variable== 2 ) { a= 0 ; b= 1 ; c= 0 ; d= 0 ;e= 0 ;f= 0 ;g= 0 ;h= 0 ;} if (variable== 3 ) { a= 1 ; b= 1 ; c= 0 ; d= 0 ;e= 0 ;f= 0 ;g= 0 ;h= 0 ;} if (variable== 4 ) { a= 0 ; b= 0 ; c= 1 ; d= 0 ;e= 0 ;f= 0 ;g= 0 ;h= 0 ;} if (variable== 5 ) { a= 1 ; b= 0 ; c= 1 ; d= 0 ;e= 0 ;f= 0 ;g= 0 ;h= 0 ;} if (variable== 6 ) { a= 0 ; b= 1 ; c= 1 ; d= 0 ;e= 0 ;f= 0 ;g= 0 ;h= 0 ;} if (variable== 7 ) { a= 1 ; b= 1 ; c= 1 ; d= 0 ;e= 0 ;f= 0 ;g= 0 ;h= 0 ;} if (variable== 8 ) { a= 0 ; b= 0 ; c= 0 ; d= 1 ;e= 0 ;f= 0 ;g= 0 ;h= 0 ;} if (variable== 9 ) { a= 1 ; b= 0 ; c= 0 ; d= 1 ;e= 0 ;f= 0 ;g= 0 ;h= 0 ;} if (variable== 10 ) { a= 0 ; b= 1 ; c= 0 ; d= 1 ;e= 0 ;f= 0 ;g= 0 ;h= 0 ;} if (variable== 11 ) { a= 1 ; b= 1 ; c= 0 ; d= 1 ;e= 0 ;f= 0 ;g= 0 ;h= 0 ;} if (variable== 12 ) { a= 0 ; b= 0 ; c= 1 ; d= 1 ;e= 0 ;f= 0 ;g= 0 ;h= 0 ;} if (variable== 13 ) { a= 1 ; b= 0 ; c= 1 ; d= 1 ;e= 0 ;f= 0 ;g= 0 ;h= 0 ;} if (variable== 14 ) { a= 0 ; b= 1 ; [...]

Rubbed Off

Mon, 10 Jul 2017 10:30:00 GMT

Early magnetic storage was simple in its construction. The earliest floppy disks and hard drives used an iron (III) oxide surface coating a plastic film or disk. Later media would use cobalt-based surfaces, providing a smaller data resolution than iron oxide, but wouldn’t change much. Samuel H. never had think much about this until he met Micah. The Noisiest Algorithm In the fall of 1980, Samuel was a freshman at State U. The housing department had assigned him Micah as his roommate, assuming that since both were Computer Science majors, they would get along. On their first night together, Samuel asked why Micah kept throwing his books off the shelf onto the floor. “Oh, I just keep shuffling the books around until they’re in the right order,” Micah said. “Have you tried, I don’t know, taking out one book at a time, starting from the left?” Samuel asked. “Or sorting the books in pairs, then sorting pairs of pairs, and so on?” He had read about sorting algorithms over the summer. Micah shrugged, continuing to throwing books on the floor. Divided Priorities In one of their shared classes, Samuel and Micah were assigned as partners on a project. The assignment: write a program in Altair BASIC that analyzes rainfall measurements from the university weather station, then displays a graph and some simple statistics, including the dates with the highest and lowest values. All students had access to Altair 8800s in the lab. They were given one 8“ floppy disk with the rainfall data, and a second for additional code. Samuel wanted to handle the data read/write code and leave the display to Micah, but Micah insisted on doing the data-handling code himself. ”I’ve learned a lot," he said. Samuel remembered the sounds of books crashing on the floor and flinched. Still, he thought the display code would be easier, so he let Micah at it. Samuel finished his half of the code early. Micah, though, was obsessed with Star Trek, a popular student-coded space tactics game, and waited until the day before to start work. “Okay, tonight, I promise,” he said, as Samuel left him in the computer lab at an Altair. As he left, he hard Micah close the drive, and the read-head start clacking across the disk. Corrupted The next morning, Samuel found Micah still in the lab at his Altair. He was in tears. “The data’s gone,” he said. “I don’t know what I did. I started getting read errors around 1AM. I think the data file got corrupted somehow.” Samuel gasped when Micah handed him the floppy cask. Through the read window in the cover, he could see transparent stripes in the disk. The magnetic write surface had been worn away, leaving the clear plastic backing. Micah explained. He had written his code to read the data file, find the lowest value, write it to an entirely new file, then mark the value in the original file as read. Then it would read the original file again, write another new file, and so on. Samuel calculated that, with Micah’s “algorithm,” the original file would be read and written to n–1 times, given n entries. Old Habits Die Hard Samuel went to the professor and pleaded for a new partner, showing him the floppy with the transparent medium inside. Samuel was given full credit for his half of the program. Micah would have to write his entire program from scratch with a new copy of the data. Samuel left Micah for another roommate that spring. He didn’t see much of him, as the latter had left Computer Science to major in Philosophy. He didn’t hear about Micah again until a spring day in 1989, after he had finished his PhD. A grad student, who worked at the computer help desk, told Samuel about a strange man at the computer lab one night. He was despondent, trying to find someone who could help him recover his thesis from a 3 1/2" floppy disk. The student offered to help, and when the man handed him the dis[...]

Error'd: Unmapped Potential

Fri, 07 Jul 2017 10:30:00 GMT

"As an Australian, I demand that they replace one of the two Belgiums with something to represent the quarter of the Earth they missed!" writes John A.



Andrew wrote, "{47}, {48}, and I would be {49} if {50} and {51}."



"Apparently, DoorDash is listening to their drivers about low wages and they 'fixed the glitch'," write Mark H.



"Advertising in Chicago's Ogilvie transportation center in need of recovery," writes Dave T.



"On the one hand, I'm interested in how Thunderbird plans to quaduple my drive space, but I'm kind of scared to click on the button," wrote Josh B.



"Good thing the folks at Microsoft put the little message in parenthesis," writes Bobbie, "else, you know, I might expect a touch bar to magically appear on my laptop."



(image) [Advertisement] Scale your release pipelines, creating secure, reliable, reusable deployments with one click. Download and learn more today!