RSS The Daily WTF

http://thedailywtf.com/

Thursday December 25th, 2008

5.3

CodeSOD: Classic WTF: Now That's A Neat Trick

The Daily WTF From The Daily WTF, 15 days ago, 0 comments Comment

Now That's A Neat Trick was originally published on September 9th, 2006.


Brian was excited to join an organization that boasts managing data for "93% of all health care facility inspections." That's important stuff, after all: inspections are essential to maintaining the integrity of facilities and can make the difference between life and death of its patients. But after eight months working there, Brian now looks for facilities in the "other 7%" for his personal health care needs.

While most companies measure the quality of their product with the ratio of bugs to lines-of-code, Brian's employer uses their own, unique metric called The Cleverness Scale. Utilized primary by upper management (also known as, the Original Coders of the system), code and design techniques are rated as follows:

1 - The Shrug-- Gets the job done, efficient, all that; but just plain boring.
2 - The Nod -- Creative, as in, using a single 32-bit integer variable to store two 16-bit integers.
3 - The Raised Left-Eyebrow -- Very creative, as in, combining all function arguments into a single pipe-delimited string
4 - The "Now That's a Neat Trick!" -- The ultimate in cleverness, as in, code that rewrites itself but maintains the original using generated comments

Despite this scale, most of the developers have actually learned to write code that scores only a 1; it turns out that there's some sort of relationship between clever code and incredibly painful maintenance. Actually, the real problem is when the CTO decides to "take the day off" and join the developers to "show 'em how it's done."

Admittedly, the CTO is able to crush objects and goals in a matter of hours. Granted, his solutions are chock full of bugs, implement a fraction of the requirements, and are generally completely unusable. But as this next example shows, his code always employs "A Neat Trick" ...

$sql = "
  SELECT 
    CONCAT(
       '<a href=\"javascript:;\" onclick=\"window.open'
         + '(\'site_info.php?siteid='
       ,site_id
       ,'\',\'siteW',\'height=480,width=550,status=no,'
         + 'toolbar=no,menubar=no,location=no,scrollbars=yes,'
         + 'resizable=yes\');\" class=\"siteInfoLink\">'
       ,DATE_FORMAT(insp_date, '%c/%e/%Y')
       ,'</a>'
       ) AS `Inspection Date`
    ,insp_date AS `_realInspectionDate`
    ,CONCAT(
       '<NOBR>'
       ,DATE_FORMAT(insp_date, '%H:%i')
       ,'</NOBR>'
       ) AS `Inspection Time`
    ,insp_date AS `_realInspectionTime`
    ,insp_requestor AS `Requestor`
    ,insp_originator AS `Originated By`
    ,site_status AS `Status`
    ,site_loc AS `Location`
    ,IF (job_priority IN ('Important', 'ASAP')
       ,job_priority
       ,''
       ) AS `Job Notes`
    ,insp_type AS `Inspection Type`
    ,IF (job_priority = 'Important'
       ,'#990000'
       ,IF (o_priority='ASAP'
          ,'#330000'
          ,'#000000'
          )
       ) AS `_rowColor`
  FROM tbl_site_inspections
    INNER JOIN tbl_sites
       ON site_id = insp_site_id
";  

The CTO managed to avoid the Stored Procedures, the Data Access components, the Business Logic components, and smooch SQL, PHP, HTML, and JavaScript into a single statement. A neat trick indeed.

Note to RSS subscribers: to save on bandwidth, I'm moving the RSS Feed to FeedBurner. Please let me know if you experience any disruptions.




Brought to you by the Non-WTF Job Board:



Wednesday December 24th, 2008

6.5

Classic WTF: Diary of a Third-Class Programmer

The Daily WTF From The Daily WTF, 16 days ago, 0 comments Comment

Diary of a Third-Class Programmer was originally published on September 27th, 2007.


Most first-class (consultants & employees) and second-class (contractors) programmers don’t realize that there’s an entire class of programmers below them. These programmers – the third-class programmers – work in Developer Purgatory with far less responsibilities, no latitude to make any decision at any level, and always get assigned the “dirty work.” In fact, some even consider it an act of charity to call these poor folks “programmers” at all.

Most third-class programmers are third-class for a reason. There is simply no way they could ever get a job anywhere else. Occasionally, recent graduates get sucked in to Developer Purgatory by the allure of a “real programming job,” never realizing the stigma that goes along with it. Andrew is one of these poor souls, desperately trying to get out. And this is his diary.

May-20: First day on the job! I guess the department is officially titled “Internet Administration” (whatever that means), and has some fun people it. Not at all what I expected from The Bank!

May-22: Met Diane today, she just started working on the “Repo” database project. She said she’ll definitely be asking for my help on it soon.

May-23: I met April today. She seemed nice, though it was a bit odd that her entire desk was covered with Pokemon merchandise and stickers. Her other passion, so she said, was playing First Person Shooter games online. Other than that, it’s been a slow first few days with nothing to do.

May-24: Met Steven today. He’s an ASP programmer for some internal sites. Later in the afternoon, he stopped by cube, worried. To quote: “You're going to have to help me on this, because I know absolutely nothing about ASP.”

May-27: Diane said she might need some help on the “Repo” database. She’ll let me know. I don’t have anything else going on.

Jun-04: Chatted with April (Pokemon girl) about Unreal Tournament. She’s in a “clan.” It is her mission, apparently, to run out into the middle of an open area and get shot down so her teammates could spot the enemy.

Jun-18: Don (our manager) got really peeved today. We were playing foursquare between cubes again, and the ball bounced twice in his. He should have been out, but he kept insisting that a desk-bounce doesn’t count as a bounce. Anyway, he stormed out of the office, saying he’ll never play again, and went home early.

July-08: Diane asked if I had free time to help her on the “Repo” database. I did, she said she’ll let me know soon how I can help.

July-18: Steven was really late today. Apparently, he was getting onto the train and his shoe got stuck in the door and left behind on the platform. He had to go back and fetch it.

Aug-20: Diane asked, again, if could help her on the “Repo” database. I said yes, again.

Aug-26: New guy, Colt, started today, transferred from Investment Banking. He moved here because he felt he was stronger in this area.

Aug-27: Colt, as it turns out, has an unhealthy obsession with firearms. Who keeps pictures of their guns in their wallet!?

Sep-16: Diane snapped at me today when I asked how she was doing. To quote: “I’m too busy working on Repo to chit-chat!”

Sep-17: Diane apologized for yelling at me. She’s been under a lot of stress with Repo.

Oct-09: Colt broke my keyboard today. I complimented his new shoes. “Thanks,” he replied. And then, he proceeded to grab a nearby glass of water and tipped it over onto my desk. This caused a large puddle of water that started dripping onto the keyboard. He then lifted up one of his legs, and put his shoe on the desk, in the middle of the water. He then grabbed his ankle, tugging at it, and said, “good grip in the wet too.” And then he walked away.

Oct-14: Another new guy, David, started today. He virtually wanted to move away from mainframes and basically move into web development. He basically got a lot more money than I did because he'd virtually been working at the bank longer. Basically though, he wasn't very good at web development. Oh, and he virtually spoke like this all the time.

Oct-22: Finally got to see the “Repo” database. It was literally three tables in an Access database and had a “form wizard” form called Form1. The form didn’t do anything. This is what Diane has been working on for six months.

Nov-04: Don asked me to review David’s code, as it was his first coding on a full-color screen. He had been working on a Budget Planner calculator that had lots of amounts the user could enter. Food, electricity, gas, etc. Next to each of these items was a drop down box with “Weekly,” “Monthly,” “Annually.”

Nov-05: I took a look at David’s code. I suggested that, instead of having twenty odd “Weekly,” “Monthly,” “Yearly” options throughout the page, he should put them into an array and reference that. He was happy to learn a better way of doing things.

Nov-08: David showed me his revised code. In the code now, there was not just one array, but about 20 arrays declared, each array containing “Weekly,” “Monthly,” and “Yearly,” with each drop down box pointing to a different array. I told him he should just be using one array, as they are all the same.

Nov-13: David let me know that he fixed the code again, so I took a look. This is exactly what I found:

arrayOne = "Weekly", "Monthly", "Yearly"
arrayTwo = arrayOne
arrayThree = arrayOne
arrayFour = arrayOne
...



Brought to you by the Non-WTF Job Board:



6.3

CodeSOD: Classic WTF: Journey to the Center of the Database

The Daily WTF From The Daily WTF, 16 days ago, 0 comments Comment

Journey to the Center of the Database was originally published on June 5th, 2006.


It'll be a long while before Donnie will forget about March 5th, 2004. Early that morning (during one of the ungodly hours), Donnie received his first off-hours support call. Naturally, one of the "mission critical" applications (more specifically, one that Donnie knew only by name) was completely broken and needed to be fixed right away. With the primary and secondary support guys unavailable, Donnie was on his own.

After waking up and reading the sparse documentation available, Donnie looked at the errors and noticed that most seemed to originate in the database. A bit more digging and Donnie found that the problem was at the apparent center of the database, the Date Table:

As it turns out, the system "abstracted" out dates into a separate table and every table requiring a date field used the DateId instead of the real date. The application didn't cope so well when the Date Table ran out of dates. Donnie inserted ten year's worth of dates into the Date Table and, after filing his report, the primary support guy thanked him and mentioned "yeah, this happened last year; we probably should have put more than a year's worth in there."




Brought to you by the Non-WTF Job Board:



Tuesday December 23rd, 2008

4.4

What the Ad? - Executives So Cra-zay

The Daily WTF From The Daily WTF, 17 days ago, 0 comments Comment

Here at work, we use a Lanier Multi-Function Printer/Scanner/Fax/Toaster the size of a small car that does tons of things and does them pretty well. However, back in 1981, Lanier was in the business of selling systems, and if you think that their EZ-1 was simply a word processor, you'd best think again.

Billed as being the Work Processor, even the most smugly drawn board chairman in Toon Town could handle it. Through the magic of its TV-like screen it can be used to generate literally several dozen pages that can be stored on a SINGLE disc. Paired with its dot matrix hover-printer, it could print output at a blazing 30 seconds per page. Franklin Covey would definitely consider the EZ-1 to be a "Win-Win".

 

As for this next ad, TRWTF is that…well…I can't tell how the company is selling their computer:

I think it goes one of two ways:

See this guy? Good - Remember his face. He's the reason why you're going to switch to Quasar Data Products' budget-priced QDP-100. The poor IBM in pieces at his feet? Yeah, that's his latest victim. When you switch over to the versatile QDP-100 with its simplicity and FULL-SCALE 8-bit computing power, you're joining a FAMILY, capuche?

—OR—

The VP of Finance, being the helpful guy that he is, showed up to help with the data center move. He ended up dropping the company's payroll server and is contemplating who in the server group he can pin the blame on for this. A jerk like this should never be allowed to touch a computer or anything electronic. Ever. When you're considering your next IT purchase, don't be stupid – buy the QDP-100 – it's the one built into a freakin' desk.

 

And if that one isn't confusing enough, consider the following:

They're selling a satellite "something" to do with a TV, but is that...an alarm clock?




Brought to you by the Non-WTF Job Board:



Monday December 22nd, 2008

2.8

CodeSOD: The 8 Report and Other Gems

The Daily WTF From The Daily WTF, 18 days ago, 0 comments Comment

Peter Korsten used to work with a truly brilliant and exceptional individual. Before leaving for greener pastures and better pay, one of his former co-workers left an indellible mark on their system via his rather unique approach to programming.

The Great 8 Report

One of these artifacts was the "8" report which consisted of the following SQL query: 

  select 8 from some_table

Ok, so it didn't really select  from a table named "some_table", but the resulting output was a list of 8's, formatted into an email and sent across the organization, including the CEO. Peter figures that the original author hadn't pressed the 'Shift' key hard enough and had intended to do this instead: 

  select * from some_table

However, what Peter can't figure out is how this report has been sent out for several years an nobody has ever complained about receiving a single-column report consisting solely of the number 8.

4,000 Records Should Be Enough for Anyone

Another gem left behind was a C program that imported a text file and performed various operations on the data. Unfortunately, he didn't allocate the memory for the records dynamically and instead set the limit of the number of possible records to 4,000. As a result, it was little surprise when the data file hit 4,001 records and the program crashed hard with a segmentaiton violation.

Rather than fix the problem the right way, the Peter's former co-worker opted to increase the maximum number of records 10-fold to 40,000 and also added a "feature" to make sure that if the first program crashed, the one following it would be invoked.

What Could Possibly Go Wrong?

Finally, what tale of a programmer who did things in their own unique way be complete without their own take on searching an array? Sure, opting to do a binary search on an array of strings is a perfectly reasonable approach, but I can't think this is the best solution.

bool binsearch (char* sr[20000],char* imsi,int lo,int hi)
{
 int low, high, test, found1;

 low = lo;
 high = hi;
 test = 0;

 found1 = -1;

 if (low > high)
  return false;
 else
 {
  test = ((low + high) / 2);

  if (strcmp(sr[test],imsi) == 0 )
   return true;
  else if (atof(imsi) > atof(sr[test]))
   binsearch(sr,imsi,test+1,high);
  else
   binsearch(sr,imsi,low,test-1);
 } //end while loop
}

 




Brought to you by the Non-WTF Job Board:



Friday December 19th, 2008

5.1

Sponsor Appreciation, Kitchen Error, a Bathroom Warning, & More

The Daily WTF From The Daily WTF, 21 days ago, 0 comments Comment

It's that time again! Sponsors: we greatly appreciate your help in paying the bills here at The Daily WTF. And, dear readers, thank for support TDWTF by visiting these fine companies and checking out their products & services.

 

Infosoft Global   Infosoft Global - the developers behind the seriously impressive FusionCharts v3: interactive and data-driven charts, gauges, and maps for web applications. Reasonably priced (starting at $69), fairly licensed, and cross-platform, it's certianly worth checking out their free trial.
Dabble DB   Dabble DB - the online database tool designed for end users, empowering them to build and deploy applications in minutes. Check out the brief demo and free your users from their spreadsheet cells.
Mindfusion   MindFusion - a great source for floatcharting and diagramming components for a variety of platforms including .NET, WPF, ActiveX and Swing
Mosso   Mosso - massively scalable hosting for .NET (2,3,3.5) PHP, Ruby, etc., with unlimited sites & mailboxes, simple online provisioning, and an enterprise clustered platform that's supported by real people.
Mozy Pro   MozyPro - business-strength backup for consumer-level prices. Ideal for corporations, small businesses, independent contractors, and self-employed, MozyPro's secure online-backup provides all the professional features you would expect from a full-service backup solution.
Rails Kit   Rails Kit - developers of the Software as a Service Rails Kit, which includes well-tested modules, controllers, and utilities to handle all the billing/account/merchant legwork for your RoR application.
SlickEdit   SlickEdit - makers of that very-impressive code editor and some pretty neat Eclipse and VisualStudio.NET tools and add-ins, some of which (Gadgets) are free. Check out this short video highlighting just one of SlickEdit's Visual Studio integration features.
Splunk   Splunk - Search, navigate, alert and report on all your IT data in real time. Logs, configurations, messages, traps and alerts, script, code, metrics and more. If a machine can generate it -- Splunk can eat it.
SoftLayer   SoftLayer - serious hosting provider with datacenters in three cities (Dallas, Seattle, DC) that has plans designed to scale from a single, dedicated server to your own virtual data center (complete with racks and all)
WTF   The Non-WTF Job Board - Powered by HiddenNetwork, it features some great job opportunities like:

 

"The developers at my company produce code that is carefully thought out and well designed," Dan Morrison writes, "unfortunately we can't say as much for the guys who built our new kitchen."

 

"I found this in the bathroom of a medical building in Dallas," J.D. wrote, "Apparently they've had a few Darwin Award attempts there."

 

"At first glance, this condiment holder looked relatively normal," Eric, "well, until viewed from above..."

 

"These screws (I guess?) came with recent case purchase," Tullo notes, "I guess you get what you pay for. Incidentally, the quality of the case itself was somewhat similar."

 

"Trial closed, eh?" John K wrote, "I guess no more beta testers were needed."

 

"I saw this on a trashcan outside of Starbucks," Eric L wrote, "I'm not quite sure how a trashcan is out of order... maybe it just needs a reboot?"

 




Brought to you by the Non-WTF Job Board:



Thursday December 18th, 2008

5.5

CodeSOD: Security by Posterity

The Daily WTF From The Daily WTF, 22 days ago, 0 comments Comment

When Rory was interviewing for his position he liked what he heard. A robust data access layer, and a company policy that dictated that if you get caught writing a non-parameterized query, you're tarred, feathered, and recommended for execution. Their rigidity and adherence to the practices, as well as an interviewer asking all of the right questions regarding secure coding and good design ultimately lead to his acceptence of the position.

Once he was finally in, he cracked open the code, excited to bask in the radiance of beautiful data access layers, secure code, and well-implemented design patterns.

As he skimmed some of the classes, he learned some of the standards. [ClassName]DAL was the data access layer for [ClassName]. Database connections were handled in a singleton, ConnectionMgr.Connection, though, strangely, each consumer had a check to see if the connection was open, and if not, open it.

The query situation was a little odd, since they were stored as a collection of strings in one big class called "Queries." Still, it was reassuring to see parameter references in the strings.

Moving on, he discovered how they did their own custom parameterization:

insertQuery = Queries.InsertForumSignUp;
insertQuery = insertQuery.Replace("@Name", "'" + signUpEntity.Name + "'");
insertQuery = insertQuery.Replace("@Email", "'" + signUpEntity.Email + "'");
insertQuery = insertQuery.Replace("@Type", "'" + signUpEntity.Type + "'");
insertQuery = insertQuery.Replace("@ForumsOption", signUpEntity.ForumsOption.ToString());

Really? Really? So if you really want to make Rory have a miserable day, all it takes is turning off JavaScript (to bypass client-side data validation), some basic SQL knowledge, and a bad attitude.

The kicker? This next snippet immediately followed the Replace statements:

#region OdbcParameter

//OdbcParameter paramName = new OdbcParameter("?Name", OdbcType.VarChar, 50);
//paramName.Value = signUpEntity.Name;
//cmd.Parameters.Add(paramName);

//OdbcParameter paramEmail = new OdbcParameter("?Email", OdbcType.VarChar, 75);
//paramEmail.Value = signUpEntity.Email;
//cmd.Parameters.Add(paramEmail);

//OdbcParameter paramType = new OdbcParameter("?Type", OdbcType.Char, 5);
//paramType.Value = signUpEntity.Type;
//cmd.Parameters.Add(paramType);

//OdbcParameter paramForumOption = new OdbcParameter("@ForumOption", OdbcType.Int, 1);
//paramForumOption.Value = signUpEntity.ForumOption;
//cmd.Parameters.Add(paramForumOption);

#endregion

So at some point they had done it the right way, but later changed it to the wrong way, but preseved the correct method for posterity, I guess.




Brought to you by the Non-WTF Job Board:



7.0

Error'd: Unhelpful Help

The Daily WTF From The Daily WTF, 22 days ago, 0 comments Comment

"I came across a device on the network running on our old IP range," Landy Bible writes, "since we are still trying to migrate things, I decided to try and figure out what was. After running NMAP, I discovered that telnet was open. I opened up a telnet session hoping to find clues as to what the device was. Following is the output from that session."

- IBM Network Card for Fast Ethernet 10/100BaseTX AppleTalk/NetWare/TCP Printer Server -

                    Copyright IBM Corp. 1995 - 1998.
                           All Rights Reserved.

-------------------------------------------------------------------------

Welcome to IBM Network Card for Fast Ethernet 10/100BaseTX

Enter username, or HELP> help

Enter username, or HELP> HELP

Enter username, or HELP> admin

Server> HELP
Please refer to your User Manual

Server>

 

"No wonder Circuit City has found it self in such financial troubles," D.H. commented, "it's probably not a good idea to mark things down by 98%."

 

In fact, it's probably best to make up "deals" like this one that Erik found at a local Super One: 10/$10 or 49 cents each.

 

"I saw this in Google Reader," Noah writes, "I'm pretty sure it's not the right picture..."

 

"I got this error message on my Lenovo X60 tablet PC while going from the normal to tablet mode," James Johnston wrote. "It left me wondering, (1) What does the display have to do with the WAN card?, (2) why is the display mode prevented from changing when the WAN card is active? (3) I don't have a WAN card; why is this appearing, claiming I have an active WAN card? (4) why is secondary landscape in particular the impossible mode when a WAN card (if it only existed in my tablet) is active? I'm confused."

 

"When I wanted to delete a document from our internal Forge system," wrote T.F., "I was confronted with this nice choice. "

 




Brought to you by the Non-WTF Job Board:



Wednesday December 17th, 2008

3.9

Your Glitch Has Been Reserved

The Daily WTF From The Daily WTF, 23 days ago, 0 comments Comment

Photo credit: 'Rob React' at Flickr When Nick Martin arrived at work at 8:30am, it seemed like he was in for a good day. Warm bagel and coffee in hand, he strolled into the IT office ready to fire up his email and maybe do a little recreational surfing before jumping into a day's worth of work. However, this was not meant to be as he was greeted by a support issue already in progress. And by "greeted", I mean "a dreary mess of a woman in a pinstripe suit was storming his way". It was Darlene, a manager from the university's financial department and conveniently, he was the only warm body in the office.

"Do you NOTICE any DIFFERENCE between these two printouts, Nick?"

Holding back his temptation to mention that one printout was fresh off the printer and the other looked like it had been on the business end of a day's worth of coffee grounds, he sheepishly started "W-Well..." before being cut off.

"YOUR daily conference room reservation report is SERIOUSLY flawed and is impacting our ability to know where we can hold meetings. "

Nick tried to interject, but it was no use.

"The facilities planning commission is convening tomorrow morning to discuss budgeting for the coming Quarter, and they need to know how much we utilize our building's resources. If you don't resolve this immediately, I will enlist the help of the comptroller and YOUR JOB WILL BE HIS!"

Later, after picking off dried grounds from the one printout and a few phone calls to Darlene's subordinates, Nick discovered the perceived glitch. Unknown to the developers of the reserveation system, tracking total usage of the conference rooms involved printing the daily reservation sheet at 8:00 every morning and placing the printouts in a folder.

As fate would have it, yesterday morning’s printout had been temporarily "misplaced", and a new copy was generated this morning. However, when yesterday’s printout was rediscovered, it had fewer reservations than the new copy. Darlene was concerned because she found that this anomalous "glitch" recurred almost daily, subverting a procedure that had been the data collecting practice for over five years.

Now confident, Nick approached Darlene with the cause of the discrepency - while the rules forbade it, the room reservation system permitted new reservations to be made by users after 8:00 in the morning for that day and the problem was not the result of a system gone haywire with preumably phantom room reservations. Nick presented alternatives for determining the total number of room checkouts much more accurately, and with only a couple of clicks and a few seconds, rather than reams of paper and several man-hours.

"Well, all of your ideas sound good, but unfortunately any change in our process would compromise...job security of our clerical staff. Thank you for your time."

And with that, the meeting, and the crisis, was forever gone. It wasn't until later when he spoke about his confrontation with Darlene to his supervisor that Nick learned that this was not the first time she had graced their office breathing fire. About every other month, Darlene appeared, threw a fit and left. Nick was simply the poor soul who got to her first. Apparently, nobody had actually taken the time to explain any kind of solution as each time the reply from the IT office was that the new entries during working hours are to be discarded as "glitches" …without reservation.




Brought to you by the Non-WTF Job Board:



4.6

Representative Line: The Backup Snippet

The Daily WTF From The Daily WTF, 23 days ago, 0 comments Comment

Generally speaking, Andrew tries his best to avoid the DBA team. It's not just because database administrators tend to be a unique breed (his colleagues were certainly no exception), but because of the "things" that he'd heard about the team. The sort of "things" that keep developers up at night and make them regret not becoming an accountant.

One day, while debugging an issue with their monitoring scripts, Andrew had no choice but to check with Thom, a member of Team DBA. It turned out that one of DBA's had recently updated their database backup script, but Thom wasn't really sure who did it, why it was done, or what it looked like before. So, he just sent Andrew the entire backup script.

Following is a single line of code, line-wrapped by yours truly, that should give a fair idea of what the script was like.

file=$WORKSPACE/ewprd1_$DATECODE.dmp,$WORKSPACE/ewprd2_$DATECODE.dm
p,$WORKSPACE/ewprd3_$DATECODE.dmp,$WORKSPACE/ewprd4_$DATECODE.dmp,$
WORKSPACE/ewprd5_$DATECODE.dmp,$WORKSPACE/ewprd6_$DATECODE.dmp,$WOR
KSPACE/ewprd7_$DATECODE.dmp,$WORKSPACE/ewprd8_$DATECODE.dmp,$WORKSP
ACE/ewprd9_$DATECODE.dmp,$WORKSPACE/ewprd10_$DATECODE.dmp,$WORKSPAC
E/ewprd11_$DATECODE.dmp,$WORKSPACE/ewprd12_$DATECODE.dmp,$WORKSPACE
/ewprd13_$DATECODE.dmp,$WORKSPACE/ewprd14_$DATECODE.dmp,$WORKSPACE/
ewprd15_$DATECODE.dmp,$WORKSPACE/ewprd16_$DATECODE.dmp,$WORKSPACE/e
wprd17_$DATECODE.dmp,$WORKSPACE/ewprd18_$DATECODE.dmp,$WORKSPACE/ew
prd19_$DATECODE.dmp,$WORKSPACE/ewprd20_$DATECODE.dmp,$WORKSPACE/ewp
rd21_$DATECODE.dmp,$WORKSPACE/ewprd22_$DATECODE.dmp,$WORKSPACE/ewpr
d23_$DATECODE.dmp,$WORKSPACE/ewprd24_$DATECODE.dmp,$WORKSPACE/ewprd
25_$DATECODE.dmp,$WORKSPACE/ewprd26_$DATECODE.dmp,$WORKSPACE/ewprd2
7_$DATECODE.dmp,$WORKSPACE/ewprd28_$DATECODE.dmp,$WORKSPACE/ewprd29
_$DATECODE.dmp,$WORKSPACE/ewprd30_$DATECODE.dmp,$WORKSPACE/ewprd31_
$DATECODE.dmp,$WORKSPACE/ewprd32_$DATECODE.dmp,$WORKSPACE/ewprd33_$
DATECODE.dmp,$WORKSPACE/ewprd34_$DATECODE.dmp,$WORKSPACE/ewprd35_$D
ATECODE.dmp,$WORKSPACE/ewprd36_$DATECODE.dmp,$WORKSPACE/ewprd37_$DA
TECODE.dmp,$WORKSPACE/ewprd38_$DATECODE.dmp,$WORKSPACE/ewprd39_$DAT
ECODE.dmp,$WORKSPACE/ewprd40_$DATECODE.dmp,$WORKSPACE/ewprd41_$DATE
CODE.dmp,$WORKSPACE/ewprd42_$DATECODE.dmp,$WORKSPACE/ewprd43_$DATEC
ODE.dmp,$WORKSPACE/ewprd44_$DATECODE.dmp,$WORKSPACE/ewprd45_$DATECO
DE.dmp,$WORKSPACE/ewprd46_$DATECODE.dmp,$WORKSPACE/ewprd47_$DATECOD
E.dmp,$WORKSPACE/ewprd48_$DATECODE.dmp,$WORKSPACE/ewprd49_$DATECODE
.dmp,$WORKSPACE/ewprd50_$DATECODE.dmp,$WORKSPACE/ewprd51_$DATECODE.
dmp,$WORKSPACE/ewprd52_$DATECODE.dmp,$WORKSPACE/ewprd53_$DATECODE.d
mp,$WORKSPACE/ewprd54_$DATECODE.dmp,$WORKSPACE/ewprd55_$DATECODE.dm
p,$WORKSPACE/ewprd56_$DATECODE.dmp,$WORKSPACE/ewprd57_$DATECODE.dmp
,$WORKSPACE/ewprd58_$DATECODE.dmp,$WORKSPACE/ewprd59_$DATECODE.dmp,
$WORKSPACE/ewprd60_$DATECODE.dmp,$WORKSPACE/ewprd61_$DATECODE.dmp,$
WORKSPACE/ewprd62_$DATECODE.dmp,$WORKSPACE/ewprd63_$DATECODE.dmp,$W
ORKSPACE/ewprd64_$DATECODE.dmp,$WORKSPACE/ewprd65_$DATECODE.dmp,$WO
RKSPACE/ewprd66_$DATECODE.dmp,$WORKSPACE/ewprd67_$DATECODE.dmp,$WOR
KSPACE/ewprd68_$DATECODE.dmp,$WORKSPACE/ewprd69_$DATECODE.dmp,$WORK
SPACE/ewprd70_$DATECODE.dmp,$WORKSPACE/ewprd71_$DATECODE.dmp,$WORKS
PACE/ewprd72_$DATECODE.dmp,$WORKSPACE/ewprd73_$DATECODE.dmp,$WORKSP
ACE/ewprd74_$DATECODE.dmp,$WORKSPACE/ewprd75_$DATECODE.dmp,$WORKSPA
CE/ewprd76_$DATECODE.dmp,$WORKSPACE/ewprd77_$DATECODE.dmp,$WORKSPAC
E/ewprd78_$DATECODE.dmp,$WORKSPACE/ewprd79_$DATECODE.dmp,$WORKSPACE
/ewprd80_$DATECODE.dmp,$WORKSPACE/ewprd81_$DATECODE.dmp,$WORKSPACE/
ewprd82_$DATECODE.dmp,$WORKSPACE/ewprd83_$DATECODE.dmp,$WORKSPACE/e
wprd84_$DATECODE.dmp,$WORKSPACE/ewprd85_$DATECODE.dmp,$WORKSPACE/ew
prd86_$DATECODE.dmp,$WORKSPACE/ewprd87_$DATECODE.dmp,$WORKSPACE/ewp
rd88_$DATECODE.dmp,$WORKSPACE/ewprd89_$DATECODE.dmp,$WORKSPACE/ewpr
d90_$DATECODE.dmp,$WORKSPACE/ewprd91_$DATECODE.dmp,$WORKSPACE/ewprd
92_$DATECODE.dmp,$WORKSPACE/ewprd93_$DATECODE.dmp,$WORKSPACE/ewprd9
4_$DATECODE.dmp,$WORKSPACE/ewprd95_$DATECODE.dmp,$WORKSPACE/ewprd96
_$DATECODE.dmp,$WORKSPACE/ewprd97_$DATECODE.dmp,$WORKSPACE/ewprd98_
$DATECODE.dmp,$WORKSPACE/ewprd99_$DATECODE.dmp,$WORKSPACE/ewprd100_
$DATECODE.dmp,$WORKSPACE/ewprd101_$DATECODE.dmp,$WORKSPACE/ewprd102
_$DATECODE.dmp,$WORKSPACE/ewprd103_$DATECODE.dmp,$WORKSPACE/ewprd10
4_$DATECODE.dmp,$WORKSPACE/ewprd105_$DATECODE.dmp,$WORKSPACE/ewprd1
06_$DATECODE.dmp,$WORKSPACE/ewprd107_$DATECODE.dmp,$WORKSPACE/ewprd
108_$DATECODE.dmp,$WORKSPACE/ewprd109_$DATECODE.dmp,$WORKSPACE/ewpr
d110_$DATECODE.dmp,$WORKSPACE/ewprd111_$DATECODE.dmp,$WORKSPACE/ewp
rd112_$DATECODE.dmp,$WORKSPACE/ewprd113_$DATECODE.dmp,$WORKSPACE/ew
prd114_$DATECODE.dmp,$WORKSPACE/ewprd115_$DATECODE.dmp,$WORKSPACE/e
wprd116_$DATECODE.dmp,$WORKSAPCE/ewprd117_$DATECODE.dmp,$WORKSPACE/
ewprd118_$DATECODE.dmp

Andrew eventually found the problem, and offered a helpful tip to Thom for shortening up their script:

file="$WORKSPACE/ewprd1_$DATECODE.dmp";
for ((i=2;$i<119;i++)); do {
   FILE="$FILE,$WORKSPACE/ewprd$i_$DATECODE.dmp";
}; done

It accomplished the exact same thing in four little lines. Thom passed on the suggestion, however, perhaps because it would have increased the line count... or, most likely, to keep the developers out.




Brought to you by the Non-WTF Job Board:



Tuesday December 16th, 2008

10

Open Sesame

The Daily WTF From The Daily WTF, 24 days ago, 0 comments Comment

Emmanuel Florac and the rest of his officemates had a bit of a problem: while they could freely leave the office as they pleased, none of them could get back in. Undoubtedly, it had something to do with the new ironclad door and accompanying electronic locking mechanism that was recently installed. Try as they might, no one’s keycard would open the door.

Throughout the day, the office manager could not get a hold of the locksmith. Call after call after call ended with a simple, “we’re sorry, this voicemail box is full; please try your call again later!” As afternoon grew shorter and the evening approached, the jokingly-proposed “someone’s going to have to sleep at the office tonight” became more and more a reality.

Fortunately, Emmanuel had a better idea. All it took to open the door from the inside was a light tap on the switch, so all he’d need to do is find something that could lightly touch the door switch. Unable to find any robot-building components in the office, he sprung for the best alternative: a few cardboard boxes and an unused office PC. This is what he came up with:

The following morning at 8:00AM, one of his coworkers called him up to open the door. Emmanuel put down his cup of coffee, went upstairs to my computer, and then
1) VPN to the office
2) SSH to the machine in the hall
3) Ran ~# eject /dev/scd0

And, click, the door was opened.

The locksmith did end up fixing the door later that day, putting the door-opening robot out of service just as quickly as it came in.




Brought to you by the Non-WTF Job Board:



1.6

Error'd: Insider Secret

The Daily WTF From The Daily WTF, 24 days ago, 0 comments Comment

"I found this in Chat Magazine's Summer Special edition," Simon Byford writes, "I can't see myself taking advantage of this insider secret any time soon."

 

"For the sake of IT consultants in Bergen, Norway," wrote Jan Tore Morken, "I hope this prediction does not come true. Especially considering it is predicted to occur at 9 in the evening."

 

"Well," an anonymous reader pondered, "I guess that's one more way you can say five."

 

"Lead paint notwithstanding," Bob N Freely notes, "I'm not sure if I should let my 2 year old son play with this toy train or not. Any advice?"

 

Eric M spotted this in the EULA for MozyHome's client software.


(MozyPro is a TDWTF sponsor)

 

"Over the past few years, I've noticed the suggested tip creep from 18% to 20% to 25%," Aaron said, "I just hope FF% doesn't become the new standard."

 




Brought to you by the Non-WTF Job Board:



Monday December 15th, 2008

1.3

CodeSOD: Validating a Date with a Sledgehammer

The Daily WTF From The Daily WTF, 25 days ago, 0 comments Comment

I think that it goes without saying that handling freeform user input, no matter the programming language, can be a tricky endeavor.  Having to work with code like today's SOD makes me appreciate the pain felt by this bit of code Catherine Palmer inherited. 

Now, I won't say that this function is necessarily terrible code, but when you consider that the field that code is intended to handle demands (in big red text) the entry of a date in a specific format (DD/MM/YYYY to be exact) and that it's meant to prevent a user from entering a date in the future, it'll leave you wondering why "TONY B" chose this exact plan of attack.

<script language="JavaScript">
<!--
function validate_futuredate(userdate)
//--- THIS DATE VALIDATION WAS DESIGNED BY ----//
//---    TONY B------- ON 02/05/2000 -----//
{
//---- get user date ---------------//
dday = userdate.value.substring(0,2)
mmnth = userdate.value.substring(3,5)
yyear = userdate.value.substring(6,10)

//--- get system date ---------------
curdate = new Date()
curyear = curdate.getFullYear()
curday = curdate.getDate()
curmonth = curdate.getMonth()
curmonth ++
//--- add one dayto curmonth as function produces zero for january ---//

strday=String(curday).length
strmonth=String(curmonth).length
//--- check that system day and month length greater 1 if not insert zero ---//
if (strday == 1)
        {
      curday = "0" + String(curday)
      }
     
  if (strmonth == 1)
        {
      curmonth = "0" + String(curmonth)
      }  
//--- create todays date to write back to input box on user input error ---//    
ddate1 = curday + "/" + curmonth + "/" + String(curyear)

//--- get length and value of user input date ---//
posit = userdate.value
poslen = posit.length
//--- check date contains 10 characters ---//
  if(poslen != 10)
    {
    alert("date contains wrong number of characters default value set")
    userdate.value = ddate1
    userdate.focus()
    return (false)
    }
//--- get first character of date make sure its less than 4 ---//
posit0 = userdate.value.charAt(0)
if (posit0 < "0" || posit0 > "3")
    {
    alert("date contains invalid DAY default value set")
    userdate.value = ddate1
    userdate.focus()
    return (false)
    }
posit1 = userdate.value.charAt(1)

if (posit1 < "0" || posit1 > "9")
    {
    alert("date contains invalid DAY default value set")
    userdate.value = ddate1
    userdate.focus()
    return (false)
    }
   
  if (posit1 == "0" && posit0 == "0")
    {
    alert("date contains invalid DAY default value set")
    userdate.value = ddate1
    userdate.focus()
    return (false)
    }
   
  if (posit0 == "3" && posit1 > "1")
    {
    alert("date contains invalid DAY default value set")
    userdate.value = ddate1
    userdate.focus()
    return (false)
    }
   
posit5 = userdate.value.charAt(5)
posit2 = userdate.value.charAt(2)
if (posit2 != "/" || posit5 != "/")
    {
    alert("date missing forward / mark default value set")
    userdate.value = ddate1
    userdate.focus()
    return (false)
    }

posit3 = userdate.value.charAt(3)
if (posit3 < "0" || posit3 > "1")
    {
    alert("date contains invalid MONTH default value set")
    userdate.value = ddate1
    userdate.focus()
    return (false)
    }
posit4 = userdate.value.charAt(4)
if (posit4 < "0" || posit4 > "9")
    {
    alert("date contains invalid MONTH default value set")
    userdate.value = ddate1
    userdate.focus()
    return (false)
    }
if (posit4 == "0" && posit3 == "0")
    {
    alert("date contains invalid MONTH default value set")
    userdate.value = ddate1
    userdate.focus()
    return (false)
    }

if (posit3 == "1" && posit4 > "2")
    {
    alert("date contains invalid MONTH default value set")
    userdate.value = ddate1
    userdate.focus()
    return (false)
    }
posit6 = userdate.value.charAt(6)
if (posit6 != "2")
{
    alert("date contains invalid YEAR default value set")
    userdate.value = ddate1
    userdate.focus()
    return (false)
    }
posit7 = userdate.value.charAt(7)

if (posit7 != "0")
{
    alert("date contains invalid YEAR default value set")
    userdate.value = ddate1
    userdate.focus()
    return (false)
    }

posit8 = userdate.value.charAt(8)
posit9 = userdate.value.charAt(9)

if (posit8 < "0" || posit8 > "9" || posit9 < "0" || posit9 > "9")
    {
    alert("date contains invalid YEAR at position9/10 default value set")
    userdate.value = ddate1
    userdate.focus()
    return (false)
    }

if (dday == "31" && (mmnth == "04" || mmnth == "06" || mmnth == "09" || mmnth == "11"))
  {
alert("wrong number of days in specified MONTH default value set")
userdate.value = ddate1
userdate.focus()
    return (false)
    }
   
  if (dday > "28" && mmnth == "02" )
  {
alert("wrong number of days in specified MONTH default value set")
userdate.value = ddate1
userdate.focus()
    return (false)
    }
    if (yyear > curyear)
    {
    alert("future dates are not allowed")
    userdate.value =ddate1
    userdate.focus()
    return(false)
    }
else if (yyear == curyear)
{
    if(mmnth > curmonth)
    {
        alert("future dates are not allowed")
            userdate.value =ddate1
            userdate.focus()
        return(false)
    }
   
    else if (mmnth == curmonth)
    {
      if (dday > curday)
      {
      alert("future dates are not allowed")
          userdate.value =ddate1
          userdate.focus()
        return(false)
      }
    }
}
 
return(true)
}
//-->
</script>
 

Thankfully, in her submission Catherine reported that this bit of of code was retired and replaced by a read-only field populated by a date-picker and a two-line if(...) alert(...) vet.




Brought to you by the Non-WTF Job Board:



Friday December 12th, 2008

1.8

What the Ad? - Portability, 1980's Style

The Daily WTF From The Daily WTF, 28 days ago, 0 comments Comment

If early 1980's marketing is to be believed, then the guy hauling around dead trees in a faux leather case is doing it completely wrong.

Sadly, the pioneering Osborne 1 didn't thrive for very long due in part to two large flaws. One being the diminutive 5" (10 cm) screen and the fact that it weighed in at a hefty 23.5 pounds (10.7kg). To put this into perspective, the weight of a single Osborne 1 is equivalent to 122 hot dogs (buns + ketchup included)

 

Need something smaller than the Takeru Kobayashi Special? Why not opt for Radio Shack's TRS-80 Pocket Computer instead.

Only slightly longer than a checkbook and weighing in at only 6oz (170g) it seems like a dream come true when compared to the Osborne 1. It is, if your dream is to have a 24x1 character display and you're ok being limited to programs written in BASIC (ok assembler too, but what kind of sadomasochist would program assembly on this thing, seriously!)

 

Aw heck, if a single line of text is all you need, why not release your inner-geek and go with the Pocket ASCII Terminal with its "Man-Sized" capabilities.

 




Brought to you by the Non-WTF Job Board:



Thursday December 11th, 2008

6.0

Java Takes Down the Network

The Daily WTF From The Daily WTF, 29 days ago, 0 comments Comment

Photo credit: 'Csaba_Bajko' at Flickr "Alright! 11:02 a.m...Another five bucks for me!"

Once again, Ricky Fine had hit it big in the network technician over/under betting pool for predicting the time of the daily network outage. It occurred around 11am, every day, but not precisely. The network would pulse on and off around 60 cycles per minute, but again, not exactly.

"Any results from the packet sniffer?" asked another technician.

"Nothing, not even so much as a stutter," replied Ricky, "You'd think for as much money as this thing costs, we'd get a hint as to what's going on."

The technician sighed, "Well, we'll just try again tomorrow. What do you say? Next one's going to be before 11 a.m.?"

"Definitely. We're due for an 'under' this time around," agreed Ricky.

Days passed and with their tools failing them, Ricky and his fellow technicians finally had to resort to brute strength analysis. This meant disconnecting different network segments every day and was by no means an easy task.

The Hardware

The thing about the hardware that Ricky and his co-workers supported was that it came from an era before CAT5 and fiber optics. Their ethernet was a swarm of coax cabling and BNC connectors, usually run haphazardly through buildings that were never designed for it. Also, as if to add insult to injury, the company exclusively used hubs for their internal network.

There’s a good reason why hubs have since been relegated as relics: unlike switches, which intelligently route packets to the appropriate destination, hubs simply repeat all packets from all connected devices to all of the other connected devices. This, along with wiring factors made the outage develop into a riddle, wrapped up in an enigma, encased within a rats’ nest of cabling.

Brute Force Pays Off

Finally, one day, they located the problem segment as the network was going down - the fifth floor. They checked every bit of cable on the line, working through the night testing impendence, frays, an even going so far as to swap out every network card on all of the PCs on the floor. Having done everything in their power, Ricky and his crew felt confident that the problem was solved.

No such luck.

The next day, 11 a.m. rolled around and a couple of minutes later, there was the regular outage. Like a pack of bloodhounds, the technicians fanned out to every cable run connected to the floor's hub.

Ricky was under a cubicle desk looking for the cable run when he heard, "Thump, thump, thump..." coming from the other side of the cubicle wall. It was about every second, but not exactly.

When he emerged and peeked around the corner, he was met with the department's resident coffee expert. He could extol the virtues or curses of every kind of coffee made and every roaster in the area. And as it happened, he had just returned from percolating his morning dose.

Carefully observing the coffee connoisseur, Ricky watched him take a large sip of coffee, set his foot on the BNC connector, and nervously roll it back and forth a few times. A few second later, he'd take another sip and tap the connector again.

It didn't take too long for Ricky to realize that, every day, he'd get hopped up on java, direct his nervousness at his work and absently roll the BNC connector like others would drum their fingers. The outage would provide enough of a break that he'd calm down a bit and leave that innocent connector alone for the rest of the day.

Ricky went ahead and moved the BNC connector out of the line of fire and the next day, no problems.

The Aftermath

After the smoke cleared and business got back to normal, the final cost of the outage was calculated, and the executives were furious. From the rented network sniffer to the hours of productivity and data lost during the outage, someone was going to have to answer how they could be so naive as to not be able to find that the problem was caused by the nervous gyrations of the local caffeine junkie.

Ricky's group did their best to emphasize that their infrastructure was at fault rather than the competence of the technicians. The execs scoffed at their explanation but, when the cost of new cable runs and upgraded network equipment was compared to the cost of the outage, they relented and agreed to upgrade the infrastructure. After all, there were a lot of coffee drinkers in the company.




Brought to you by the Non-WTF Job Board:



« older items