-Поиск по дневнику

Поиск сообщений в rss_thedaily_wtf

 -Подписка по e-mail

 

 -Постоянные читатели

 -Статистика

Статистика LiveInternet.ru: показано количество хитов и посетителей
Создан: 06.04.2008
Записей:
Комментариев:
Написано: 0

The Daily WTF





Curious Perversions in Information Technology


Добавить любой RSS - источник (включая журнал LiveJournal) в свою ленту друзей вы можете на странице синдикации.

Исходная информация - http://thedailywtf.com/.
Данный дневник сформирован из открытого RSS-источника по адресу http://syndication.thedailywtf.com/thedailywtf, и дополняется в соответствии с дополнением данного источника. Он может не соответствовать содержимому оригинальной страницы. Трансляция создана автоматически по запросу читателей этой RSS ленты.
По всем вопросам о работе данного сервиса обращаться со страницы контактной информации.

[Обновить трансляцию]

Error'd: Practice What You Preach

Пятница, 20 Февраля 2015 г. 14:00 + в цитатник

"I think Oracle might want to read one of their own books on how to use MySQL," writes Mike.

"While on the cruise ship Independence of the Seas, I figured that I'd quickly check my email," Mark F. wrote, "I guess that I got a little carried away!"

"At first, I thought there was more to the error than what was shown. Then, I began to think otherwise," writes Theodore.

Nicholas wrote, "On one hand, I can only imagine that someone was tricked into buying a bigger ad than they needed, however, I'm sure that only the most serious applicants would apply."

"Yes, Facebook. You've caught me. I've been away for a lonnnng time," writes Raghu.

Ishai S. wrote, "While trying to open a support ticket, IBM gave me some oddly repetitive, yet technically dissimilar, product categories."

"Until today, our employee services web portal has been picky about ONLY working in Internet Explorer," writes B.D., "Oddly enough, I fired up Chrome, changed it to an IE User Agent and it works just fine."

"Trying to find a hotel in Brussels is harder than it seems. Unless you can read Latin...you're out of luck!" Scott S. writes.

[Advertisement] BuildMaster is more than just an automation tool: it brings together the people, process, and practices that allow teams to deliver software rapidly, reliably, and responsibly. And it's incredibly easy to get started; download now and use the built-in tutorials and wizards to get your builds and/or deploys automated!

http://thedailywtf.com/articles/practice-what-you-preach


Метки:  

The ShaoLinux Monk

Четверг, 19 Февраля 2015 г. 15:00 + в цитатник

Looking at the resum'e, Paul felt like theyd found the perfect person for their data warehouse project. The resum'e had all the relevant qualifications and experience needed to make a remarkable ETL tool. Paul talked to the candidate, Brad, briefly during the interview process. It says here that youre proficient with Linux and have extensive database knowledge.

Jonny Blu Martial Arts Demo - Still Photo 1.png
by Daofengmusic - Own work

Well, yeah, Brad scoffed. They call me the ShaoLinux Monk. I karate chop through Linux like a stack of concrete blocks, no matter what the distro. When it comes to databases, they always bow to my will. Im the right man for this job.

Paul didnt like his cocky nature, but Brad aced the rest of the interview, and despite some concerns, he was hired.

Paul showed Brad around the office and showed him to his workstation on his first day, and got Brad logged in. OK, so how do I change my password from this default junk? Brad asked.

Use your ShaoLinux-fu! Paul replied, while pantomiming karate moves. Paul assumed Brad was joking, and would have his password changed in a jiffy. Paul went back to his office.

Twenty minutes later, an email from Brad dinged into his inbox. NO SERIOUSLY, how do I change my password on this thing??? A little late, perhaps, but Paul determined that Brad wasnt kidding around. Since Brad was the cocky new guy, Paul decided he deserved a good ribbing on his first day.

This link should tell you everything you need to know! Paul shot back. Brad never replied to this attempt at helpful humor, so Paul assumed Brad got his password straightened out and got started on the worlds greatest ETL tool.

A few days later, Paul started getting complaints from other members of the team about Brad asking them too many questions and being unprofessional. Paul always encouraged his guys to ask questions if they werent sure about something, so he wanted to know what the big deal was. He stopped by to talk to Lacey, the network admin.

Oh, yeah. Brad wanted to know the IP for his workstation. I told him, and then he sent me this email.

Nice try, but you should double check your work! I poked around some, and I HAVE IT ON GOOD AUTHORITY THAT THE IP ADDRESS FOR THIS BOX IS 127.0.0.1! Brad - 1. Moron - 0!

That wasnt acceptable behavior, so he went to Brad to straighten him out. As soon as he approached though, Brad berated him. I dont know how you expect my advanced brain to create any magic here! This stupid system needs all of these goofy Linux commands that I cant be expected to know. All I usually need is cd, cp, mv and rm. The rest is all programmer-y bullcrap that your devs refuse to help me with. The monk will NOT take a vow of silence on this!

Sorry, Brad. I shouldnt have assumed that you would know all of these shell commands, he replied, while recalling Brad practically claimed he created Linux during his interview. Ill set up a conference call and make sure my devs know to help you out here. But you have to adjust your attitude, it wont help anything.

Paul scheduled the call, but got tied up in another meeting, and ended up dialing in late. He beeped in just in time to hear Brad riffing on him. You guys shouldnt be listening to Paul, anyway. He has no idea what hes talking about. Paul decided to mute his phone and see where this went. If I ran this place, things would be so much better, and you guys would totally respect my authority! I have 10 years experience in IT, and I know what Im doing. Paul is weak. He told me to adjust my attitude. What kind of passive-aggressive shi…

BRAD! Paul unmuted himself. You do realize Im on this call, right? I set it up? Hang up and pack up your stuff, youre done here. Paul stomped over to Brads desk to ensure he actually followed instructions for once.

Youre making a mistake, letting a talent like me go, Brad muttered as he headed for the exit. Paul rolled his eyes as he watched Brad head back to the ShaoLinux Temple where rejects like him studied the fine art of arrogance.

[Advertisement] Release! is a light card game about software and the people who make it. Order the massive, 338-card Kickstarter Edition (which includes The Daily Wtf Anti-patterns expansion) for only $29.95, shipped!

http://thedailywtf.com/articles/the-shaolinux-monk


Метки:  

Coded Smorgasbord: Efficient WTFery

Среда, 18 Февраля 2015 г. 15:00 + в цитатник

Some horrible code is acres of awful, thousands of tortured lines of mess and horror. Some developers can compress their WTFs down into a handful of lines.

For example, Zlatko was working with a Node.js developer who was big on unit tests. Unfortunately, that developer didnt understand that you couldnt write a synchronous test for an asynchronous method- the test will always pass.

Thats why this code, buried in a callback, passed:

while (i <= location.length) {
    if (i === location[i - 1].rank) {
        i++;
    }
};

Or take Wendy, who inherited an application that has to deal with poorly sanitized data. Some fields, like Print_Code, are VARCHAR(2), which means many records end up with a trailing space.

Wendys co-worker cleaned out that extra white-space with this block:

String print_code = " ".concat(dto.getPrint_code().trim());
if (print_code.length() == 3) {
print_code = print_code.trim();
}

With Java web development, its not uncommon to need to detect whether youre inside of WebLogic, Tomcat, etc.. Josh found this… exceptional solution in his codebase:

boolean isTomcat = new Throwable().getStackTrace()[1].toString().indexOf("org.apache.catalina") > -1;

For a language not exactly known for its brevity, this amount of WTF in a single line is quite an achievement .

Then again, maybe we dont need a line of code at all. Alexandre was hunting a bug that caused the wrong products to show up as a deal in their e-commerce site. Fortunately, his predecessor documented the code quite well:

/* ATTENTION: this crap below is messed up and brings more deals than you expect, it is because SQL SP looks up for the deals inside children groups of selected group. Don't change this until somebody notice the situation */

And finally, well close with a true confession from Corey. When Corey started a comp-sci program in college, he aleady had a fair bit of experience as a developer. When his professor assigned a write a factorial function exercise, Corey turned in this:

int f(int n){return n?f(n-!!n)*n:!n;}

The professor was not amused.

[Advertisement] Release! is a light card game about software and the people who make it. Order the massive, 338-card Kickstarter Edition (which includes The Daily Wtf Anti-patterns expansion) for only $29.95, shipped!

http://thedailywtf.com/articles/efficient-wtfery


Метки:  

Barely Broken In

Вторник, 17 Февраля 2015 г. 15:00 + в цитатник

One day in winter, during that blissful dead stretch between Christmas and New Year’s, Chris was startled out of a deep sleep. He reached for his blaring cell phone, squinting at the painfully bright screen.

Gfp-arkansas-mount-magazine-state-park-sign-at-the-top-of-signal-hill.jpg
by Yinan Chen

2:14 AM. His boss, Jake.

Great.

Chris was on vacation. Why was he getting this, and not the scheduled on-call guy? Chris answered, fully expecting to grumble “Look at the schedule” and hang up again.

Before Chris could say a word, Jake growled, “Get out here.”

“Huh?” Chris struggled to comprehend around his grogginess. “To the office?”

“That’s what I’m saying.”

Chris thought about mentioning he was on vacation, but something in Jake’s voice told him he already knew, and didn’t care. “What’s wrong?”

“You’ll see.”

“Not even a hint?” Chris asked. “Can’t I just remote in, or—?“

“That’s about the last thing you can do, son. Now get out here.”

Jake hung up, leaving Chris befuddled. Never before had even the most dire emergencies mandated his physical presence— especially not at 2 AM, during the deadest time of year, while he was on vacation. What could possibly be wrong?

Well, nothing for it but to throw on the nearest set of clothes and head down there.


Chris drove through pitch blackness on deserted roads. It felt like a dream, but the most bizarre details were yet to follow. Cop cars and trucks filled the company parking lot. Chris pulled up as close as he could, and noticed the smashed window on the side of the office building.

There must’ve been a break-in, he realized, stomach sinking.

Fortunately, they backed up all their important data offsite, but a lot of hardware was likely missing. Maybe Jake needs me to take inventory and provide what’s missing for the police report, Chris thought. He was glad no one would’ve been here during the robbery— and doubly glad he’d taken his laptop home over vacation, in case of emergency. Now it seemed as though he’d spared it from emergency.

He exited his car. Despite the commotion, it wasn’t hard to find his boss. Jake stood alone, cigarette clenched in his teeth, observing the police work.

“I’m here, Boss.”

Jake greeted Chris with a terse nod, exhaling a stream of smoke.

“This sucks. So what’d they get?” Chris asked.

Jake smirked a little. “‘They’ nothing, son. It was a bear.”

Chris’ jaw dropped. “What? No way!”

Jake nodded. “Near as we can figure, the sumbitch saw something he wanted, or got spooked by traffic. Busted in, went tear-assing through the office.”

Chris needed a few seconds to process this. Upon closer inspection, he noticed the trucks parked nearby were in fact from the local Game and Fish Commission.

“I love Arkansas,” he muttered, shaking his head. “Can we go in?”

It was like visiting a crime scene: flashing cameras, cops, Fish and Game people, and others who weren’t easily identified on sight. Insurance adjusters maybe, or the owner of the building. Maybe an unrelated bystander or two just marveling at the spectacle.

The office looked more like a trailer park post-tornado. Cube walls lay askew. Desks had been cleared from the inside out. There was Mike’s famed candy stash, all over the floor.

Chris wondered if he was still back home asleep, dreaming. His cube hadn’t been spared, but given the drawers held no food, the bear hadn't seemed as interested.

Jake hovered over Chris’ shoulder, and kept right on smoking inside the building. Who was going to tell him no?

Chris cursed, then turned back to Jake. “What do we do, Boss?”

“Grab as many pictures as you can. We’ll need ’em for insurance. Worry about the rest later.”

Chris shook his head. “Can you imagine if someone had been here?”

Jake said nothing, glancing at his feet.

Was someone here?!” Chris cried.

“No, son, but you got me thinking. Supposing something like this happens again, and someone were around…” Jake glanced back up, frowning with purpose. “What we need here is a mitigation strategy.”


By the time Chris returned from holiday break, the chaos was a strange memory. Broken glass vacuumed up, cube walls resurrected, candy stashes replenished. New hardware had been ordered, and was on its way. The shattered window had been replaced—

—and in the kitchen, just above the mini-fridge, Jake had thoughtfully added a shotgun.

“I love Arkansas,” Chris muttered, retrieving his coffee.

[Advertisement] Manage IT infrastructure as code across all environments with Puppet. Puppet Enterprise now offers more control and insight, with role-based access control, activity logging and all-new Puppet Apps. Start your free trial today!

http://thedailywtf.com/articles/barely-broken-in


Метки:  

CodeSOD: Variables Everywhere, But Not a Stop to Think

Понедельник, 16 Февраля 2015 г. 15:00 + в цитатник

SharePoint. What can you say about it? Among other things, it's designed to help you manage and present content. It's supposed to make things easy for you. If you want some customization, just write some code to do whatever and configure it to run at the appropriate time for the appropriate page(s).

Of course, this leaves open the possibility that folks who may be something less than experts might author said customizations.

Paul is responsible for numerous customizations written by developers long gone from their project. One particular customization was to perform some clean up. At first, it was run once per day. Over time, that grew to running 8+ times per day on each of several servers.

One day, the customization stopped working. Naturally, there was no record of it anywhere in source control (thank you predecessor coders).

Having no alternative, the code was decompiled into the following loveliness:

private static void Main(string[] args) {
  using (SPSite site = new SPSite("")) 
  {
    using (SPWeb web = site.OpenWeb())
    {
      SPList list = web.Lists["Calendar"];
      site.AllowUnsafeUpdates = true;
      try {
          foreach (SPListItem item in list.Items) {
            DateTime now   = DateTime.Now;
            DateTime time2 = now.AddDays(30.0);
            DateTime time3 = (DateTime) item["End Time"];
            DateTime time4 = (DateTime) item["Start Time"];
            DateTime time5 = time3;
            DateTime time6 = time4;
            DateTime time7 = now;
            DateTime time8 = time2;
            if (time3 >= now) {
               if ((time5 >= time7) && (time6 <= time8)) {
                  item["DisplayThis"] = "YES";
                  item.Update();
               } else {
                  item["DisplayThis"] = "NO";
                  item.Update();
               }
            } else if (time3 < now) {
              item["DisplayThis"] = "NO";
              item.Update();
            }
          }
      } catch (Exception) {
      } finally {
        site.AllowUnsafeUpdates = false;
      }
    }
  }
}

There seem to be three different ways to refer to DateTime.Now, and eight variables that could easily be knocked down to...none.

[Advertisement] Use NuGet or npm? Check out ProGet, the easy-to-use package repository that lets you host and manage your own personal or enterprise-wide NuGet feeds and npm repositories. It's got an impressively-featured free edition, too!

http://thedailywtf.com/articles/variables-everywhere-but-not-a-stop-to-think


Метки:  

Error'd: An Interesting, Cryptic, and Artistic Error

Пятница, 13 Февраля 2015 г. 14:00 + в цитатник

"Proof that there's a poet living deep within each of us...even developers," Ed writes.

"I'm not all that sure that this kind of performance analysis could apply to a database," writes Paolo.

Jared wrote, "Spotted on a public announcement board at Temple University, I believe it's announcing a new version of BIOS."

"Good news! Windows 8.1 still has support for diskettes. Bad news - I only have a DVD drive on my computer," writes Sam.

"Wow! -9 quintillion messages? Must be one of those local black hole/Interstellar time dilation effects again," writes Mike S.

"After restarting, VLC asked if I would like to send error report to developers," Arttu T. wrote, "I chose yes and, while there were problems, I'm glad to see that it was appreciated."

"On the bright side - at least the blank is guaranteed to work," writes Dana L.

"I had left Sky Harbor Airport in Phoenix before I cold see this resolved, but I sure hope that the camera (or scanner) was installed correctly ," James B. wrote.

[Advertisement] BuildMaster is more than just an automation tool: it brings together the people, process, and practices that allow teams to deliver software rapidly, reliably, and responsibly. And it's incredibly easy to get started; download now and use the built-in tutorials and wizards to get your builds and/or deploys automated!

http://thedailywtf.com/articles/an-interesting-cryptic-and-artistic-error


Метки:  

CodeSOD: Accurate Comments

Четверг, 12 Февраля 2015 г. 15:00 + в цитатник

Kevin L saw the program crash with a null pointer exception. This lead to digging through stack traces, logs, and eventually the commit history to figure out who was responsible.

Gauze Pad

The code itself is a simple string padding function, the sort of thing that when people screw it up, you just have to wonder why. This variation on that theme, however, gives us that rare treat: an accurate comment that describes the function.

// there is a much better way to do this.... 
    public static String padRegistrationNumber(String registrationNumber) {
        if (registrationNumber.length() == 11) {
            return " " + registrationNumber;
        }
        if (registrationNumber.length() == 10) {
            return "  " + registrationNumber;
        }
        if (registrationNumber.length() == 9) {
            return "   " + registrationNumber;
        }
        if (registrationNumber.length() == 8) {
            return "    " + registrationNumber;
        }
        if (registrationNumber.length() == 7) {
            return "     " + registrationNumber;
        }
        if (registrationNumber.length() == 6) {
            return "      " + registrationNumber;
        }
        if (registrationNumber.length() == 5) {
            return "       " + registrationNumber;
        }
        if (registrationNumber.length() == 4) {
            return "        " + registrationNumber;
        }
        if (registrationNumber.length() == 3) {
            return "         " + registrationNumber;
        }
        if (registrationNumber.length() == 2) {
            return "          " + registrationNumber;
        }
        if (registrationNumber.length() == 1) {
            return "           " + registrationNumber;
        }
        return registrationNumber;
    }

Note: its an accurate comment. Its still not a useful comment- this function's crapfulness is entirely self-documenting.

[Advertisement] Release! is a light card game about software and the people who make it. Order the massive, 338-card Kickstarter Edition (which includes The Daily Wtf Anti-patterns expansion) for only $29.95, shipped!

http://thedailywtf.com/articles/accurate-comments


Метки:  

Getting Wired

Среда, 11 Февраля 2015 г. 15:00 + в цитатник

It had been a very long weekend.

On Friday, the CIO of Brendans company announced that something big was in order and details would be revealed Monday morning. Questions quietly circled around the office for the rest of that day. Were people getting laid off? Was a customer unhappy and withholding payment? Was the software division being sold to East Kerblekistan?

&and many of these unanswered questions transmuted into rumors.

Come Monday morning, the staff shuffled into the companys largest conference room to hear the news. Andy, the CIO, showed up fifteen minutes late as usual. He had reached CIO status not by being punctual, smart, knowledgeable, or even particularly effective. Instead, his sharp dress, smooth tongue, and slick presentations got the job done. He had a bright can-do attitude, knew all the right buzzwords (and could occasionally string them together into something resembling a sentence), and anyone without a technical background (most importantly the CEO and the Board of Directors) saw him as a technical genius.

WLAN PCI Card cleaned

Today Andy was positively beaming. This was far above and beyond his normal self-important pomp and arrogance. From his wide smile and ecstatic mood, Brendan half-expected him to whip out a Nobel Prize, or Turing Award, or Oscar, and self-congratulate in front of the entire IT staff.

Employees of Initech! I am proud to announce that we are finally moving into the 21st century! Andy began. Ive spent the past several months in research and negotiations, and because of my hard work Initech has just been awarded a half million dollar federal grant to update our network to wireless technology! This will completely reinvigorate and synergize the company, and is a fundamental key to our plan for winning several high-dollar federal contracts for the fiscal year of 2005. Our commitment to technology is vital to our core business principles, and this upgrade will prove to prospective clients that we are serious about advancing the state of modern technology. When they tour this office and experience our brand-new wireless network, they will have no choice but to choose Initech for all of their needs!

At that point, Brendan sighed in relief and mentally checked out as Andy kept talking for the next 45 minutes about how great this network upgrade would be for business.

Not long after, Andy announced a new Network Upgrade Task Force, which he would be personally overseeing, to plan and execute the upgrade. Brendan was tagged as a vital part of the team, with tasks right on the critical path.

Initech already had a reliable wired network, and nobody was complaining about the lack of wireless access. Brendan tried to question why the network upgrade was even needed, but Carl, the team leader and one of the companys domain administrators, pulled him aside and politely told him that questioning the CIOs plans would be a career-ending error.

Over the next several weeks the team of twelve developed a plan. They started simple, trying to provide wireless access to the few areas where it would make sense, but soon Andy interfered, demanding wireless access in the places that didnt make sense. The plan became more and more complicated, resulting in dozens of wasted man-hours spent drawing up new hypothetical network diagrams. Eventually, it was decreed that Initechs entire building, all 14 floors, would be covered by the new 802.11g-compliant wireless network. A wireless access point was to be installed in each room, and each workstation would be assigned a USB external Wi-Fi adapter. Each office room had between 5 and 30 workstations, depending on the team and duties.

Outside of one of the planning meetings, Brendan pulled aside a few of his teammates. Were going to have over a thousand PCs all join the same wireless network? And have almost 150 wireless access points all within the same building? This is NOT going to work!

Carl shook his head in agreement. We cant fight Andy on this, remember what happened to Al and Gerald last year? Brendan recalled: unemployment happened. We just need to do the best we can. Andys set his mind on it, but if we can survive the beginning, we can quietly improve things once he moves on to The Next Great Project.

The project plan was completed and the other executives rubber-stamped it. On a Friday six weeks later, the Network Upgrade Task Force waited for the regular office staff to leave. They had until Monday morning to get everything set up.

By noon on Sunday, every WAP had been installed and configured, Ethernet switches from each office were removed and placed in storage, and every desktop workstation had a shiny new USB adapter connected. Andy decided that full-scale testing was unnecessary, but he did allow them to connect a few random systems to the new wireless network for testing. The new network technically worked. With only a few PCs on at once typical throughput had dropped from 100 megabit to only 15 or 20, but they had wireless! Andy ordered the team to write a memo of instructions on how to join a PC to the network, and one was printed and distributed to each workstation in the building except for the few theyd set up themselves. The CIO declared the project a success and ordered pizza for the team in celebration.

Monday did not go well for anyone on the upgrade team. Brendan personally spent nearly 16 hours that day connecting hundreds of workstations to the wireless network because the users were unable to follow the instructions correctly. As additional workstations were brought online, the network slowed to a crawl. Initechs internal web sites and applications became unusable for most users, and throughput tests consistently returned kilobit rates which were barely double-digit, if they succeeded at all.

Andy was absolutely furious and stormed through the building, red-faced, bellowing at the members of the upgrade team as they fought to connect workstations to the network. What the hell is wrong with you people? This stuff was all working when we left yesterday! It was working! Find out what you did wrong and fix it! We HAVE to get the network working, contracts worth millions of dollars are on the line! Do you hear me?! He stormed off, and the team managed to slip away to a distant conference room.

Alright, what are we going to do? Carl said.

Can we go back to the old wired network and not tell Andy? Pretend were using wireless? Brendan asked.

Carl shook his head. He may be an idiot, but hes watching us too closely. Well all be gone if he finds out we arent actually using WiFi.

Theres just too many wireless devices too close to each other, responded Brendan. I walked around the office with my personal laptop and a WiFi monitor. All the access points are channel-hopping like mad trying to find a clear channel. I cant even connect unless Im within a couple feet of an access point.

Alex, a quiet engineer from the hardware division, spoke up. It works if youre close to an access point? Brendan nodded. So what if we can get everyone that close? Puzzled glances were exchanged. Remember Project Sapphire from two years ago? he added. That government project Andy bought all the equipment for and then we didnt win the contract? We still have several pallets full of USB extension cables from that!

The idea was crazy, but they decided to test it in a couple offices. They strung up USB extensions and relocated each workstations external WiFi adapter, situating them all within a foot or so of the nearest access point. And by golly it worked! Throughput was only a few megabits, but the connection was generally reliable!

As they finished the first round of testing, Andy showed up, ready to chew the team out for not fixing the network yet. Carl explained that they had a possible workaround and his anger mellowed a bit. As long as its working by tomorrow. He huffed and stormed out.

By eight oclock the next morning, every single WiFi adapter in the building had been relocated. Bandwidth was limited to 2 - 3 Mbps due to contention, but at least network timeouts were rare. Despite the unsightly mess of WiFi adapters piled around each access point, Andy was pleased. See, this is why I picked you guys, I knew youd make it work! This is the kind of ingenuity that makes Initech the best in the industry! Good work! Get us through today, and you can all have tomorrow off.

By the end of the day, the team finished configuring the last remaining workstations and corrected a few relatively minor issues. The network was drastically slower than it used to be, but was fast enough for most of the staff. At the next full-staff quarterly meeting, Andy gave a forty-minute presentation about the resounding success and ROI of the network upgrade.

Brendan rolled his eyes and decided to update his r'esum'e in case he got involved in whatever Andys next scheme would be.

[Advertisement] BuildMaster is more than just an automation tool: it brings together the people, process, and practices that allow teams to deliver software rapidly, reliably, and responsibly. And it's incredibly easy to get started; download now and use the built-in tutorials and wizards to get your builds and/or deploys automated!

http://thedailywtf.com/articles/getting-wired


Метки:  

CodeSOD: Abuse of Properties

Вторник, 10 Февраля 2015 г. 15:00 + в цитатник

Every .NET programmer is familiar with the concept of properties. They’re a nice language feature, allowing the programmer to inject little bits of logic into the process of retrieving or setting the value of a field. A getter can, for example, lazily initialize a field when it’s first used, and a setter can validate the value before it’s set. Even a simple property with no logic beyond providing access to a backing field can be made useful by appearing in an interface or being overridden by a derived class.

An important aspect of properties is that to the outside user, they appear almost no different from a regular field. As such, they’re supposed to behave like regular fields. Any visible side effects beyond what’s necessary are heavily frowned upon, and the developer who uses the property can reasonably expect it to provide transparent access to data from his point of view.

KallDrexx’s coworker, however, was forced to deal with code made by people who didn’t seem to understand the “transparent” part– or, in fact, any part…

public IRevObjApi SelectedRevObj
{
    get
    {
        if (IdList.Count == 0) return null;

        if (IdList.SelectedIndex == -1)
            IdList.SelectedIndex = 0;

        IdList.SDescrColumnName = "PIN";
        IdList.DescrColumnName = "AIN";

        return (IRevObjApi)IdList.List[IdList.SelectedIndex];
    }
}

This monstrosity lurked in one of the fundamental classes of a web framework his company was using. Along with the reasonable task of retrieving the selected value from the list, it silently changes the list’s describing column to what it thinks is right– except in this case, there is no such column, and the application falls flat on its face.

Digging further uncovered even more WTFs...

public int SelectedRevObjID
{
    get
    {
        if (IdList.Count == 0)
            return -1;

        if (IdList.SelectedId == -1)
            IdList.SelectedIndex = 0;

        //Check to see if there is really anything in the list
        //if not, go to search
        //if (IdList.SelectedId == -1)    //tfs 40899  commented automatic Search 
        //    Navigate("CVGSCriteria");

        IdList.SDescrColumnName = "PIN";
        IdList.DescrColumnName = "AIN";
        return IdList.SelectedId;
    }
    set
    {
        //First check to be sure id != 0
        if (value != 0)
        {
            //Need to build the IDList
            var list = new ArrayList();
            IRecordsApi rapi = ApiFactory.CreateRecordsApi(View.CurrentDataAccessContext);
            IRevObjApi roApi = rapi.GetRevObjAllById(Convert.ToInt32(value), View.SecurityToken);
            list.Add(roApi);

            IdList.List = list;
            IdList.IdColumnName = "Id";
            IdList.SelectedIndex = 0;
            IdList.SDescrColumnName = "PIN";
            IdList.DescrColumnName = "AIN";
        }
    }
}

This property is supposed to retrieve the ID of the currently selected object. The getter is every bit as bad as the previous one. Luckily, someone came to their senses and commented out the part that redirects the user to a search page out of the blue if no object was selected.

The setter manages to be even worse. It does nothing when passed a zero, without informing the user of their mistake- then it gets the object from an API using the provided ID (which is helpfully converted from an integer to an integer), erases the current list, and creates a new one with the newly obtained object as its sole item. At the end, as if to spite the user even more, it resets the column names again.

The coworker bravely continued digging into other parts of this code- only to be confronted by what, if the codebase were a video game, would be the final boss:

/// 
/// Gets the datasource for the IdList grid
/// 
private DataTable IDListSectionDataSource
{
  get
  {
    IList idList = Controller.IdList.List;

    if ( idList == null )
      return null;

    string sDescrColumnName = Controller.IdList.SDescrColumnName;
    string descrColumnName = Controller.IdList.DescrColumnName;
    string idColumnName = Controller.IdList.IdColumnName;
    int idColumn = Controller.IdList.IdColumn;
    int currentId = -1;
    string descr = "";
    string sDescr = "";
    object objId;
    PropertyInfo property;
    MethodInfo method;
    
    if ( ( idList is LiteCollection ) || ( idList is DataView ) )
    {
      // Check if the embedded table can be used directly
      DataTable embeddedTable;

      if ( idList is LiteCollection )
        embeddedTable = ( (LiteCollection) idList ).DataView.Table;
      else
        embeddedTable = ( (DataView) idList ).Table;

      if ( embeddedTable.Columns[ idColumnName ] != null )
        return embeddedTable;
      else
        return null;
    }

    // Define the bind table;
    DataTable bindTable = new DataTable();
    bindTable.Columns.Add( idColumnName );

    if ( sDescrColumnName != null )
      bindTable.Columns.Add( sDescrColumnName );

    // Otherwise we have to loop through all entries
    int count = idList.Count;

    for ( int i = 0 ; i < count ; i++ )
    {
      DataRow newRow = bindTable.NewRow();

      descr = "";
      sDescr = "";

      object item = idList[ i ];

      if ( item == null )
        continue;

      // Check if this object has a public property for Id
      property = item.GetType().GetProperty( idColumnName );
      if ( property == null )
        continue;

      method = property.GetGetMethod();
      if ( method == null )
        continue;

      objId = method.Invoke( item, new object[ 0 ] );
      if ( objId == null )
        continue;

      try
      {
        switch ( objId.GetType().Name.ToLower() )
        {
          case "int32":
            currentId = (int) objId;
            break;
          case "decimal":
            currentId = decimal.ToInt32( (decimal) objId );
            break;
        }
      }
      catch
      {
        continue;
      }

      newRow[ idColumnName ] = currentId;

      // Check if there is a sdescr column available
      if ( sDescrColumnName != null )
      {
        // Check if this object has a public property with the sdescr name
        property = item.GetType().GetProperty( sDescrColumnName );
        if ( property != null )
        {
          method = property.GetGetMethod();
          if ( method != null )
          {
            sDescr = method.Invoke( item, new object[ 0 ] ) as string;

            // Check if there is a descr column available
            if ( descrColumnName != null )
            {
              // Check if this object has a public property with the descr name
              property = item.GetType().GetProperty( descrColumnName );
              if ( property != null )
              {
                method = property.GetGetMethod();
                if ( method != null )
                {
                  descr = method.Invoke( item, new object[ 0 ] ) as string;
                  sDescr = sDescr + " 
" + descr; } } } } } newRow[ sDescrColumnName ] = sDescr; } bindTable.Rows.Add( newRow ); } return bindTable; } }

Not only does this make for a lengthy method- let alone a getter- it remakes the data source every single time it’s accessed, and does so in a way that can only be described as “asinine.”

First, it checks the type of the list. If it’s one of the types that provides a DataTable out of the box, it uses that– which is fine enough- but failing that, it goes through the whole list, pulling out basic objects and retrieving their IDs via reflection. Oh, and it uses the idColumnName as the ID property name, which allows you to use any column as an ID column... provided, of course, that it hasn’t been mangled by any of the previous getters or setters.

Then, it tries to cast each of those IDs as integers– but since a simple explicit cast with error handling would actually be a reasonable solution, it first checks the runtime type of the ID object against a list of types. That has the added benefit of making the code utterly break if the ID is neither an Int32 or a decimal. In this case, it just goes with -1 as the default value. After the ID is retrieved, a six-level-deep if-chain gets the two properties containing a description (again via reflection, and again using the previously reset property names), and finally inserts a new row with the ID and description set.

All this work is, of course, repeated whenever anything tries to access the data source. It serves as a perfect example of how a feature created to simplify the life of the user of your class ends up abused so badly, it makes things harder for everyone involved.



[Advertisement] Use NuGet or npm? Check out ProGet, the easy-to-use package repository that lets you host and manage your own personal or enterprise-wide NuGet feeds and npm repositories. It's got an impressively-featured free edition, too!

http://thedailywtf.com/articles/abuse-of-properties


Метки:  

Announcements: London and Amsterdam TDWTF Meet-ups

Понедельник, 09 Февраля 2015 г. 15:00 + в цитатник

I'll be in London this week (Thus Feb 12) and Amsterdam next (Tues Feb 17), and thought it'd be a perfect opportunity for another The Daily WTF meet-up. Here's a pic from a previous year's London meet-up:

The London Meet-up will be at The Counting House near Bank station, on Tuesday, February 12th at 7:00PM. If you're interested, please RSVP to the London Software on the Rocks meet-up group; actually, one of the reasons I started that group was to keep in touch with the London friends I've met through past London TDWTF meetups. So, feel free to join either way.

I'm not sure exactly where the Amsterdam meet-up will be, but it'll be Thursday, February 17th around the same time. So, if you're up for getting together, please drop me a note via the contact form or direct, apapadimoulis/inedo.com.

[Advertisement] BuildMaster is more than just an automation tool: it brings together the people, process, and practices that allow teams to deliver software rapidly, reliably, and responsibly. And it's incredibly easy to get started; download now and use the built-in tutorials and wizards to get your builds and/or deploys automated!

http://thedailywtf.com/articles/london-and-amsterdam-tdwtf-meet-ups


Метки:  

Tales from the Interview: Role Reversal

Понедельник, 09 Февраля 2015 г. 15:00 + в цитатник

Ki and Morgan had an on-again, off-again relationship, but not because they couldnt commit; Morgan was Kis dedicated recruitment agent at Impracticable Resources. Ki had to admit he left every other recruiter shed dealt with in the dust. Thats why she was excited when he described the position at Initech: Ki had started as a web designer and migrated into Java development, and Initech was looking for exactly that to be the glue between their Java and UX teams. Eight short weeks ago, the initial phone screen had gone well.

Mirror

Gerard was Kis would-be bosss name, and warned her straight away that Initech was procedure-friendly; every box on their list had to be ticked and accompanied by its own list of ticked box-ticking-assurance boxes, supplemented by a list of ticked box-ticking-assurance-box-ticking-assurance boxes before they could bring her on board.

I am very impressed by what I see, Gerard said. We want to bring you on-site, for our standard gauntlet of interviews. Sound good?

Definitely, Ki said. When would you like me to come in?

Well let you know, Gerard said, your recruiter will give you a call.

Morgan did give Ki a call, almost three weeks later.

Ki, howve you been?

Good. Waiting to hear about the Initech position, I guess& You?

Yeah, Initech. They seem really interested in you! Can you do Thursday afternoon?

Ki stumbled out of Initechs offices two-and-a-half hours after her arrival, exhausted but happy. Her interviews had gone extremely well. Gerard, who was head of the Java team, Celia, head of the UX team, and Armin, the lead designer, all agreed that she was at the exact nexus of design and development acumen that the job required. On the phone that afternoon, Morgan glowed to the extent one can glow via audio.

Ki, the jobs as good as yours!

Thats great! Did they send you an offer?

Well& no. Knowing Initech, theyll need you to come in again for a second battery of interviews. Ill give you a call when theyve been in touch.

So that was that, for another three weeks.

Good news, Ki!

Youve got a lead on a company that hasnt outsourced their hiring to a glacier?

Even better: Initech wants you to come in next Tuesday. Now, for this set youre going to need a portfolio of previous work. You met Armin and Celia last time? Well, theyll be grilling you on your presentation. Thats why Im giving you all this notice!

Ki looked at the past weeks sitting long and empty on her desktop calendar. Uh, thanks.

Gerard, Celia, and Armin were all glad to see Ki again, and somehow (perhaps because they had three weeks to prepare) they each had almost an hour of questions for her before her portfolio presentation. But she passed with flying colours and, on the brief tour of the office, Gerard apologized for the amount of time the whole process was taking. If it were up to me, he said, youd start tomorrow. But HR still wants to have a word with you, and the whole team is headed out West for the annual general meeting at Initech HQ. Ill be sure to put in a good word for you with the bigwigs out there!

Ki thanked Gerard and left. Soon after, she called Morgan.

So Gerard tells me good things!

Yes, they seemed happy with me& again. But apparently theres one more interview—did they mention when theyd be back from their visit to HQ?

Let me see& oh, yes, heres Gerards email. Looks like youll be sitting down with HR on& hmm& uh, June 9th.

Thats two weeks from now.

Sure looks that way! Sorry, Ki. But this is going to be awesome once weve crossed the Ts and dotted the lowercase Js!

And so Ki found herself up late on the night of June 10, having heard nothing from Morgan, Gerard, or Initechs HR department. She was turning her mobile over and over in her hand, weighing her need to know against the possibility that Morgan, on the East Coast, would be asleep by now.

Hell with it, she told herself, if he didnt want midnight phone calls, he shouldve gone into used-car sales.

H-Hello? Morgan sounded groggy, but Ki held firm.

Hi Morgan, its Ki. Im sorry to call so late, but I havent heard from Initech, and Im wondering if they got in touch with you. Im sure you understand that, after eight weeks, I really need to get some closure.

There was a long pause on the other end, followed by a deep sigh. &Ki, its& complicated. Really, I dont know how this happened.

There was that sinking feeling, the one that starts in your stomach and descends to places unmentionable. How what happened, Morgan?

"Well, Ive got this email here from Initech HR. Apparently, in the wake of their annual general meeting at Initech HQ, it was decided that the role youre applying for would be better suited to a less-technical candidate. I dont know if they mean someone who just does web design, or what.

Im really sorry about this, Ki. It sounds like youre out of the running.

I dont understand, Ki said. Youre saying they changed the job so Im no longer a shoe-in?

I suppose thats what Im saying. Yes.

Well& okay. Im sorry to hear that. Goodnight, I guess?

Goodnight, Ki&

Oh, Morgan?

Yes?

Try to find me a position in computer vision or compiler design next, okay?

Huh?

That way, when they downgrade the position, Ill be a perfect fit.

Goodnight, Ki.

[Advertisement] BuildMaster is more than just an automation tool: it brings together the people, process, and practices that allow teams to deliver software rapidly, reliably, and responsibly. And it's incredibly easy to get started; download now and use the built-in tutorials and wizards to get your builds and/or deploys automated!

http://thedailywtf.com/articles/role-reversal


Метки:  

Error'd: Vacuums and Prints 20 Pages Per Minute!

Пятница, 06 Февраля 2015 г. 14:00 + в цитатник

"At first, I was a little skeptical about buying a 3rd party battery, but after looking at the extra features, I'm sold!" writes Emily S..

Charlie wrote, "If you ask, me it's more like 'Broken News'."

"The meteorologist in service at Weather.com would like to correct Lord Kelvin. Absolute Zero temperature is not -273.15 Celsius," writes Daniel.

"Yeah, having Brian Cox and Jason Bradbury as keynote speakers is pretty cool, but how they ever managed to get Generic Hero to sign on is beyond me!," wrote Mike S.

David writes, "The weather is so bad even BBC weatherman Philip Avery won't put his name to the forecast."

"I wonder how many I'd have to buy to get a whole handkerchief," John S. wrote.

Cristian writes, "Visiting the Microsoft Partner site with the new Internet Explorer 11 results in the rather surprising message."

"Lots of people make fun of Bing, but here's what MS Office Clipart search believes that a 'database' looks like," Tim W. writes.

[Advertisement] Release! is a light card game about software and the people who make it. Order the massive, 338-card Kickstarter Edition (which includes The Daily Wtf Anti-patterns expansion) for only $29.95, shipped!

http://thedailywtf.com/articles/vacuums-and-prints-20-pages-per-minute-


Метки:  

Representative Line: How to Validate a URL

Четверг, 05 Февраля 2015 г. 15:00 + в цитатник

INTERNET!There's an old joke among programmers, particularly those who have had to use regexes more often than they're comfortable with:

Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
It's a seductive trap: Regexes are good at processing strings, and are more complex than your usual string-processing utilities, so it seems logical to use regexes to do advanced string-parsing. But regular expressions are not meant to do arbitrary string parsing. Regular expressions are meant to parse regular languages. Furthermore, regular expressions are notoriously hard to read, resulting in, what appears to be, a string of random characters sneezed out all over your screen. For example, consider the following that's used for parsing a valid URL:

Regex regex =new Regex(
  @"^((((H|h)(T|t)|(F|f))(T|t)(P|p)((S|s)?))\://)?(www.|[a-zA-Z0-9].)[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,6}(\:[0-9]{1,5})*(/($|[a-zA-Z0-9\.\,\;\?'\\\+&%\$#\=~_\-]+))*$"
);

For all the detail in this regex, it makes a few crucial mistakes. Putting on my SQA hat, here's a few failing test cases to prove it:

• http://sites.google.com (no "www" prefix) • https://192.168.0.1 (same reason) • www.google.com (no protocol) • http://google.com (no www) • ftp://user:password@www.example.com (no basic auth credentials allowed) • news://www.example.com (only http, https, ftp, and ftps allowed) • http://www.test.com?pageid=123&testid=1524 (no url parameters) • http://www.

http://thedailywtf.com/articles/how-to-validate-a-url


Метки:  

To Spite Your Face…

Среда, 04 Февраля 2015 г. 15:00 + в цитатник

Ive got a gig for you, said the recruiter.

Clive, like many freelancers, weighed the contents of his bank account versus the daily rate he was promised, and decided that any gig was for him under those conditions. This one sounded mostly okay; an insurance company needed a new software package that would help them leap through some regulatory hoops. As a bonus, they wanted someone who could teach their devs the latest tools and techniques… like source control.

Clive aced the interview, and started a week later. There was already an email waiting in his work inbox, from someone named Brandon. It read: See me.

Schere Gr 99.jpgThat nose won't know what hit it…

Brandon lurked in his office, adhered to his mid90s ergonomic chair like it was an appendage. He glared over his monitor and stared at Clive. You work for me, he said.

In monosyllables and four word sentences, Brandon revealed that no one who participated in the hiring decision would have any day-to-day contact with Clive. Clive reported to him, and him alone.

Okay… well, when I was hired, they said that they wanted me to set up Subversion. Should I get started on that? Clive asked.

No.

May I ask why? Do you have another preference? Would you like to discuss the options?

No.

Clive waited. Brandon didnt expand. He simply stared at Clive. Stared, and stared.

Clive slunk back to his cube and got started on looking at the code base. It currently lived in a file share, using the file.pl.old, file.pl.old.old versioning convention. The code was Perl, and unreadable by even Perl standards. It had grown in a culture here parsable means runnable, included no comments, and had absolutely no tests. Clives only ally was Lee, another head-hunted expert who also reported directly to Brandon, and had a two week head start on understanding the code. When Clive got stuck, he poked his head around the cube wall and asked Lee.

Like a glacier grinding down a mountain, Clive slowly worked his way through the code. After about a week, he was developing a small degree of confidence. Then an email from Brandon arrived: See me.

Youre disrupting the dev team, he said.

What?

You and Lee are making too much noise. This is an office, not a social club .

Thats crazy. Im just asking him questions about the work were doing! What, do you want us to schedule a conference room just to ask questions?

Yes.

Brandon stopped talking and resumed his staring contest. He stared, and stared… Clive got the point and scurried back to his cube.

The requirements were complex and evolving, which wasnt unusual. Only one user, Carole, actually knew what they were, which also wasnt unusual. Clive sent her an email with a handful of questions, and tried to get some work done. He waited for a few days for her reply, and as he found new questions, he sent more emails.

In a week, he had sent nearly half a dozen, but got no reply. He sent more, asking for status updates. Over this time, he had more questions. He tried calling her, but it dumped to a full voicemail box. He tried scheduling a meeting, but Carole never accepted.

And then an email from Brandon arrived: See me.

Carole says youre harassing her, Brandon said.

What?

You send her emails, even after she answers your questions. She said you called a meeting but didnt show up for it. This needs to stop.

Thats crazy. She never replied, and I can show you my inbox to prove it.

Carole doesnt use email, Brandon explained. An intern prints out her emails, and she replies via inter-office mail. Shes very busy. You have the requirements document. Implement it, and stop bothering her.

What, you want us to implement a solution without ever talking to the business user who knows the requirements?

Brandon stared at him. And stared. And…

With Lees help, Clive made some real progress over the next few months. They learned their way around the absurd date format (measured as the number of days since April 3rd, 1974, except when it was measured in the number of months since the preceding Monday, except when it was measured in the number of weeks since the following Sunday). They worked past the fact that no one was allowed to upgrade past Firefox 3, or the fact that they couldnt run overnight jobs because all of the servers were turned off at 6PM sharp. Carole didnt communicate, Brandon just stared at them, and the rest of their co-workers treated them like plague carriers.

A few weeks before their six month stint expired, Clive was digging through the company network drive, searching for a spreadsheet containing sample data. He found one named after the recruiting company that placed him, and hoped that it was something useful. It was, after a fashion.

The spreadsheet was a report illustrating exactly how much the recruiting company was getting paid to provide Clive and Lee. The fees were so abusive a used car salesman would have blushed. Change tracking and collaboration was enabled on the document, which meant Clive could read comments made by various users.

From the senior management level, there were comments like, It doesnt matter how expensive it is. Accounting warned, We wont have the money to pay annual bonuses, if we do this!

Brandon had left his own note: Our business is too special. They will fail. This is a waste of money. They will fail.

The pieces clicked into place. Brandon hadnt been making a prediction; he was making a promise. And hed kept it- there was no way that Clive and Lee could deliver what was originally promised in the next few weeks.

Then an email from their recruiter arrived. That company still wants added staff. Do you want to re-up for another six months?

Having learned from Brandon, Clive sent a one-word reply: No.

[Advertisement] BuildMaster is more than just an automation tool: it brings together the people, process, and practices that allow teams to deliver software rapidly, reliably, and responsibly. And it's incredibly easy to get started; download now and use the built-in tutorials and wizards to get your builds and/or deploys automated!

http://thedailywtf.com/articles/to-spite-your-face-


Метки:  

CodeSOD: Head in the Tag Cloud

Вторник, 03 Февраля 2015 г. 15:00 + в цитатник

When most folks create something, be it carved, welded or coded, they take pride in what they're creating. It's a reflection of their soul. It's personal. They care.

However, once you tell someone that their stuff will be in or on something that is someone else's responsibility (aka.: problem), they often take less care in what they're putting there.

To me, the phrase The Cloud can be safely replaced with Someone Else's Computer in every conceivable context; load-distribution; storage; file transfer; etc.

As such, all too often, when something is to be in/near/on/associated-with any-or-all-things-cloud, the folks who build it tend to do somewhat lower quality work.

Ayken recently inherited an old website that quickly turned out to be a management nightmare. Every veteran who is used to fighting such ancient demons knows that every PHP project comes with ridiculous stuff like this trim-function that was clearly written in complete ignorance of the existence of regular expressions:


However, even the most seasoned demonslayer would be shocked and appalled to see the function responsible for displaying those nifty, once very trendy tag clouds:


Each tag name is passed along with the number of times it appears on the website and the function then sizes them in inverse order. The more posts that reference the tag, the smaller it becomes. Finally, when it's used more than 33 times, it will become larger once more, but still a bit smaller than the ones used only once.

One can only assume that Lucy was in the Sky with Diamonds when the choices for the colors were made...

[Advertisement] BuildMaster is more than just an automation tool: it brings together the people, process, and practices that allow teams to deliver software rapidly, reliably, and responsibly. And it's incredibly easy to get started; download now and use the built-in tutorials and wizards to get your builds and/or deploys automated!

http://thedailywtf.com/articles/head-in-the-tag-cloud


Метки:  

Wrongness

Понедельник, 02 Февраля 2015 г. 15:00 + в цитатник

Wrong Way Sign"You BASTARDS! You stupid little brats! Don't you even dare to try that again, ya hear me?! YA HEAR ME, PUNKS?!"

It was a quiet day at the IT department. For the last few weeks, the team has hit a dry spell – there were hardly any calls, and they spent most of the days desperately trying not to die of boredom. Ron managed to dig up an old copy of Counter-Strike and was currently getting his ass handed to him.

"Lost again?" -  Melissa, his fellow tech, finally gave up painting her nails for the tenth time and chimed in.

"You bet I did! This place is full of cheaters! Just wait till I..." – Ron's rant was cut short by a sound of a phone ringing. He rushed to the receiver and grabbed it off the hook.

"Yeah... okay, Boss ...yeah, um, we're uhh... a little busy, but we can make it, I think... Okay. Yessir. Bye!"

"So?" – Steve, a freshly-hired intern and the last part of the trio, turned away from his desk. - "Did we get some work to do?"

"Oh, it's nothing." – Ron sighed. – "Their reporting system is acting a little funny, that's all".

"You mean Bluecorp Reports?" – Melissa asked. Bluecorp was their company's main IT solution provider – their software was incredibly buggy and almost unusable, but over time the employees got familiar with its quirks and worked around most of the bugs.

"Yeah, that's it. When you view the monthly report from the web page, it works fine, but when you export it to HTML, one of the charts is suddenly one pixel tall."

"Why do we keep paying them... Steve, call their tech support and have them sort it out. I'm out for lunch. Ron, you coming?"

"Sure, why not." – Ron grabbed his jacket and headed out, leaving the intern to finish off the job.

Roadblock After Roadblock

When Ron and Melissa came back, Steve was still on the phone. So, they went for a coffee.

Then, a cigarette...and then, another one.

Finally, after an hour and a half, they found Steve with a resigned look on his face, staring at the phone in front of him.

"So, what's the news?" – Ron asked.

"Well, it took a while, but I managed to get them to acknowledge a bug in their software. Apparently, one of their XML configuration files is wrong, or something like that."

"That's good, right?" said Melissa "They'll have it fixed for us?"

"Yeah, well, that's the bad news. They said they'll fix it in the next release."

"They're on a frigging yearly release cycle!" Ron burst out, "You're right Liss, why do we keep paying them... Okay, guess we're going to fix it ourselves. Did they tell you which file that was?"

"Yeah, they did." Steve logged into the server and opened Notepad. "That's the one, I guess..."

Ron looked at the monitor. The file was only a few lines long, and it was obvious it had nothing to do with either the export, or the charts in general.

"Those bastards..." he muttered, "Just how much do we keep paying them?"

"You don't want to know, really," said Melissa, "Okay, it's PHP, right? Maybe we can take a look at the code?"

Steve clicked a few times, and brought up another file in Notepad. This time, a random jumble of letters and symbols squished into a single line was staring at them menacingly.

"And it's encrypted. Curses, foiled again..."

Ron paced nervously back and forth, trying to figure out another angle of approach.

"So, the problem is only with the export, right? And on the website, the charts are okay? Let me try something..." he pushed Steve aside, generated a report, and checked the source of the website.

Sure enough, there it was – an element pointing to report.php?f=1.png.

"So, we can get that link, just like that..." Ron copied the link and pasted it into the address bar - "and download the image from here, like th... wait, what the hell?!" he exclaimed. It was and entirely different chart coming from the same address.

"That's... the next page chart." Melissa was just as stumped.

He hit Refresh a few times, getting another and another chart each time, until finally he saw a generic "Error" image when he went past the end of the report.

"They make a new image each time you load it? That makes no sense. At all."

"Hey, wait!" Steve finally decided to remind his colleagues of his existence. "I think I know what to do. Just give me half an hour."

Desperate Measures

"Okay, give it a try now."

Ron pulled up a report, ran an export and browsed through it. "Hey, you did it! Come on, show me what you did."

"Sure, come on over," Steve opened a small Perl script on his computer, "So, when someone requests an export, normally the app would run e-mail code at the end to send it to you. Instead, it now runs this."

"So far, so good..."

"The script logs into the server and goes to the report page. Then, it keeps downloading the image and calculating a checksum of it until it gets two identical checksums in a row – that means we're getting that error image you saw."

"Uh-Huh..."

"Finally, it takes the right image, unzips the report, substitutes it in the right place, packs it again and sends it to the recipient. As simple as that."

"That's... quite a workaround, yeah. I'm not sure if it's what I'd call simple though."

This time, Melissa didn't even look up from her nails. "Hey, if it works, it works. And you know what they say – drastic software requires drastic measures, doesn't it?"

"Guess that's right," Ron relented, "Anyway, I'll be out taking my revenge on those cheating brats. You guys in?"

"Sure, why not," Melissa put her headset on, "As long as I play on the other team."

[Advertisement] BuildMaster is more than just an automation tool: it brings together the people, process, and practices that allow teams to deliver software rapidly, reliably, and responsibly. And it's incredibly easy to get started; download now and use the built-in tutorials and wizards to get your builds and/or deploys automated!

http://thedailywtf.com/articles/wrongness


Метки:  

Error'd: You Can't Beat This High Score

Пятница, 30 Января 2015 г. 14:30 + в цитатник

"According to Rocksmith's global stats, it looks like there's no point attempting to beat the arcade high score," Andrew M. wrote.

"While contacting a magazine company regarding a billing error, it appears they have rather demanding requirements for contacting customer service," writes Ryan S., "I had to override the CSS and HTML to add my own submit button, but it sent!"

Elijah G. wrote, "Ya know, maybe it's just me, but American Horror Story is looking a little bit...funny."

"Apparently, my car insurance firm has a unique way of dealing with marketing email unsubscribers - assign them a new email address," writes Matthew.

"While taking a survey, this popped up," writes Mike D., "In my opinion, when in test mode, always choose High."

"I’m not sure what email blast service Apress uses, but I think they might want to submit a feature request that the Send Final and Send Test buttons be moved a little further apart," RoN writes.

"I searched on Google to see how much R$ 212.42 was in dollars, but for some reason, it converted the temperature of a speed of some gas in dollars instead," Maxime E. wrote.

Cristian writes, "I'm not entirely sure what Word wants me to agree or not agree to here."

[Advertisement] BuildMaster is more than just an automation tool: it brings together the people, process, and practices that allow teams to deliver software rapidly, reliably, and responsibly. And it's incredibly easy to get started; download now and use the built-in tutorials and wizards to get your builds and/or deploys automated!

http://thedailywtf.com/articles/you-can-t-beat-this-high-score


Метки:  

CodeSOD: A Shining Perl

Четверг, 29 Января 2015 г. 14:30 + в цитатник

Pan paniscus06Ah, Perl. Often derided as a "write-only language", Perl nevertheless enjoys some level of popularity among WTF-savvy workplaces. So when David inherited a codebase through the purchase of a company staffed entirely with, what he had dubbed "mentally challenged chimpanzees", it seemed only natural that the code was entirely in Perl.

Dealing with financial transactions is one of the key features required for any online shopping or banking applications, and as such, it's more or less a solved problem by now. So of course, the perl gurus at ChimpanCorp reinvented the wheel with their Real-time Financial Processing app. It would calculate the user's balance every ten minutes by compiling all data posted since the last calculation, leading to a balance that was never more than ten minutes out of date! Of course, that's as good as you can possibly get when the calculation takes nine minutes to run. Still, the client was wondering if maybe the could speed up the calculations so it could run, say, every five minutes? Or maybe, hypothetically speaking, immediately after every transaction?

David dug into the codebase, clocking various methods -- it was best to limit his exposure to the actual code as much as possible, given the warning labels attached to the documentation. Something about eye strain and fecal matter... In any event, he finally pinpointed one method that was taking seven minutes to run. If he could shave off a few minutes from that, they might be able to hit the mythical five-minute benchmark.

The code, of course, had to run twenty queries on un-indexed SQL; adding a few indexes removed two minutes from the runtime, which unfortunately wasn't quite enough. So he dug into the queries themselves, carefully commenting as he went, saving a few seconds here and there with better optimized joins. And then he came to this gem:



my $mysql = 'SELECT TOP (1) n = (ROW_NUMBER() OVER (ORDER BY number))-1 FROM [master]..spt_values ORDER BY n';
my $mysth = $dbh->prepare($sql);
$mysth->execute(1, 10);
while (my @row = $sth->fetchrow_array) {
   $OurZero= $row[0];
}

David laughed, replacing this with a simple "$OurZero = 0", and moved on. One query down, only nineteen more to optimize. Four hours later, he reached the bottom of the method. This was it, what the entire seven-minute runtime was calculating:


return ($ReturnValue * $OurZero); 

David stared at the return value, then up at the method he'd been labouring to understand all day. Seven. Minutes. With a final sigh, he went to the calling function and replaced the execution with this super-optimized bit of perl:


if (1 == 2)
{
 #Only run this if you've lost your mind
 CalculateZero();
} 

Just as he checked his revision into the repository, a coworker popped his head into David's cube. "David, you will not BELIEVE how they're calculating dates!" she gushed.

"Somehow, I suspect I will."

[Advertisement] BuildMaster is more than just an automation tool: it brings together the people, process, and practices that allow teams to deliver software rapidly, reliably, and responsibly. And it's incredibly easy to get started; download now and use the built-in tutorials and wizards to get your builds and/or deploys automated!

http://thedailywtf.com/articles/a-shining-perl


Метки:  

Common Sense Not Found

Среда, 28 Января 2015 г. 14:00 + в цитатник

Mike was a server admin at your typical everyday Initech. One day, project manager Bill stopped by his cube with questions from Jay, the developer of an internal Java application.

Hello there- thanks for your time! Bill dropped into Mike’s spare chair. We needed your expertise on this one.

No problem, Mike said, swiveling to face Bill. What can I help with?

Bill’s pen hovered over the yellow notepad in his lap. He frowned down at some notes already scribbled there. The WAS HTTP server- that’s basically an Apache server, right?

HTTP Error 455 - User is a Jackass

Basically, Mike answered. Some IBM customizations, but yeah.

So it has a… HT Access file, or whatever its called? Bill asked.

He meant .htaccess, the config file. Sure, yeah.

OK. Bill glanced up with wide-eyed innocence. So we could put something into that file that would allow a redirect, right?

Um… its possible. Uneasiness crept over Mike, who realized he was about to discuss a custom solution to a problem he didnt know about, on a server he was responsible for. Whats going on?

Well, Jay wants a redirect in there to send people to another server, Bill replied.

Mike frowned in confusion. We just stood this server up. Now he wants another domain?

Huh? Oh, no, Its not our domain. Its someone elses.

OK… Im lost, Mike admitted. Lets start at the beginning. Whats the problem Jay wants to fix?

Well, he has this broken link in his app, and he wants to redirect people to the correct site, Bill explained.

Mike stared, dumbfounded for several moments. Excuse me?

Yeah. He has this link that points off to some external federal website- IRS, I think- and the link is broken. He wants to automatically redirect users to the correct site so they dont get a 404 error. We started looking into it, and found that Apache has this HT Access file thingy. It looks like thats what we need.

Youre kidding, right? Mike blurted ahead of discretion.

No. Why? Bill’s eyes widened. Something wrong?

Mike swiveled around to retrieve his coffee mug, and a measure of composure. Why doesnt he just fix the link within the app so it points to the right URL?

Well, that’s what I asked him. But he thinks it’d be more convenient to redirect people.

If the link is updated, they wont need to be redirected.

I realize that.

Mike took a long swig. Thats not what the .htaccess file is for. Its meant to redirect an incoming request to a different server of your own, not someone elses.

Oh. Bill scribbled this down on his notepad, then stared hard at the scribbles. Every moment of silence ratcheted Mike’s nervousness higher.

So youre saying we cant do the HT Access thing? Bill finally asked, looking up again.

To fix a broken link?

Yeah! Bill’s eyes lit up. Apparently, Mike’s clarifying question had given him new hope.

No. Mike crushed that hope as mercilessly as he could.

OK, so the HT Access thing wont work. Hmm, OK. Bill frowned back down at his notes, falling silent again. Mike sensed, and dreaded, another inane line of questioning about to follow.

Well, another thing Jay mentioned was a custom error page, Bill’s next foray began. Can we do that in Apache?

Mike hesitated. …Yes?

Great! Ill tell him that. He can develop a custom 404 page with some Javascript in it or something to redirect people to the correct site.

Huh?

Not the prettiest solution, I know, but Jay said he can make it work.

Mike spoke slowly. Hes going to create a custom 404 error page… for that broken link of his?

Yeah.

And that 404 page is supposed to display… when his broken link sends users off to some IRS web server?

Yeah.

The IRS web server, when it gets a request for a page that doesnt exist, is gonna display Jays custom 404 error page. Is that what you’re telling me?

Bill’s confidence faltered. Um… I think so.

Mike dropped the bomb. Hows he gonna get that custom page onto their server?

Well, it’d be on our server.

Right! So how would that custom 404 error get displayed?

When the user clicks the broken link.

I asked how. You just answered when.

Well, OK, I dont know! Im not the developer here. Bill’s hands rose defensively. Jay said he could make it work.

Hes wrong! Mike snapped.

He was pretty confident.

Mike hesitated a moment before his shoulders dropped. Facts and common sense were not to prevail that day. OK then. Lemme know when it works.

Bill perked up. Really? You’ll put it on the server?

Sure. Just have him fill out a service request and Ill deploy it.

Excellent! Thank you! Bill jumped up with pleasant surprise, and left the cube.


A few days later, Mike was completely unsurprised to find Jay frowning into his cube. My 404 page isn’t displaying!

Mike created a new email addressed to Jay, then copied and pasted a link to the IRS Help and Resources page. Sorry- you’ll have to take it up with the taxman.

[Advertisement] Manage IT infrastructure as code across all environments with Puppet. Puppet Enterprise now offers more control and insight, with role-based access control, activity logging and all-new Puppet Apps. Start your free trial today!

http://thedailywtf.com/articles/common-sense-not-found


Метки:  

CodeSOD: When You Really Want to be Sure it's an INT

Вторник, 27 Января 2015 г. 14:30 + в цитатник

Datatypes are difficult. So is typecasting. And if you don't understand one, you probably don't get the other either. And if you don't get either, you should probably give up on writing code and find a new career. You may get a slight pay cut for doing so, but at least you can quit spending half your salary on all those expensive reconstruction surgeries every time your coworkers go on a cluebat rampage against your face. And your coworkers will certainly appreciate not having to lose brain cells to your poorly-written functions, like these submitted by Kevin.

private int GetClassRoomArea(Int32 StudentCount) {
  return ((int)(Convert.ToInt32(StudentCount)) * 2 / 1000); 
} 

Either the author of this function was deathly afraid that his int would grow up into something else, or he was clueless. It takes an int, converts it to an int, and then casts it to an int. Unless he's dealing with a really quirky compiler written for free by a team of unpaid interns who don't understand the difference between a signed integer and a banana, I would place my vote on clueless.

Here's another such function:

private string GetPercentage(Int32 EducationTotal) {
  return (string)((double)(Convert.ToInt32(EducationTotal)) / Total * 100).ToString("N2");
}

This one also converts the int to an int, then inexplicably casts it to a double. This seems to be in error, so the author used integer division to change it back into an int. Finally, because ToString() is such a poorly-documented and poorly-understood call and you never know what type it'll give you, he casts its result to a string.

Upon reading these, I imagine that Kevin felt the death of at least a few more of his brain cells and tightened his grip on his trusty cluebat. Half an hour later, he returns to his desk to rewrite the offending code into something more sane. Meanwhile, the company intercom chimes "Cleanup on Floor 3, Cubicle 12. Cleanup on Floor 3, Cubicle 12."

[Advertisement] Use NuGet or npm? Check out ProGet, the easy-to-use package repository that lets you host and manage your own personal or enterprise-wide NuGet feeds and npm repositories. It's got an impressively-featured free edition, too!

http://thedailywtf.com/articles/when-you-really-want-to-be-sure-it-s-an-int


Метки:  

Поиск сообщений в rss_thedaily_wtf
Страницы: 124 ... 20 19 [18] 17 16 ..
.. 1 Календарь