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

Поиск сообщений в 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 ленты.
По всем вопросам о работе данного сервиса обращаться со страницы контактной информации.

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

Best of…: Best of 2015: Byte Me

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

Happy New Year! Today's "best of" is the "best" code to copy file data that I've ever seen. Originally from September. --Remy


Nibbles in a byte

The great thing about Android is the low barrier to entry: thanks to open-source tooling, emulators, and the decision to build on a language often taught in schools, just about anyone can write a simple little app.

The worst thing about Android is the low barrier to entry. Just about anyone can write a simple little app, whether they know what they're doing or not. The following code snippet is intended to take bytes from an InputStream (a common paradigm for web in Java) and save them into a file.


public void download(InputStream in, String fileName) {
	Vector vector = new Vector<>();
	byte[] tmpByteArray = new byte[1024];
	while (true) {
		int r = in.read(tmpByteArray, 0, 1024);
		if (r == -1) {
			break;
		}
		for (int i = 0; i < r; i++) {
			vector.add(Byte.valueOf(tmpByteArray[i]));
		}
	}
	byte[] byteArray = new byte[vector.size()];
	for (int i = 0; i < vector.size(); i++) {
		byteArray[i] = ((Byte) vector.elementAt(i)).byteValue();
	}
	File fout = new File(this.outFileDir.getAbsolutePath(), fileName);
	FileOutputStream fos = new FileOutputStream(fout);
	BufferedOutputStream bos = new BufferedOutputStream(fos);
	bos.write(byteArray);
	bos.close();
	fos.close();
	in.close();
}
 
 

Our Anonymous submitter writes:

At first glance it doesn't look that bad, but only until you start to estimate the memory usage of this nice little code snippet.

For those not familiar with Java and its internal representation of objects a little hint: Every Byte is a Java Object and every Java Object has a memory overhead of several bytes because of memory alignment. In detail the overhead for every object is 8 bytes for a 32-bit JVM for the Android Dalvik VM.

The code copies every received byte into a Byte object and then copies it again into a byte array before writing everything into the file-system! Hence this tiny little code snippet requires about 9-10 times the file-size in memory for downloading and saving the file.

Incidentally, the last time this author had to write code for this purpose, it looked something like this:


	BufferedReader inputReader = new BufferedReader(new InputStreamReader(in));
	File destination = new File(fileName);
	FileWriter output = new FileWriter(destination)
	String line;
	while ((line = inputReader.readLine()) != null) {
		output.write(line + "\n");
	}
	
	output.close();
	in.close();
 
 
[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/best-of-2015-byte-me


Метки:  

Best of…: Best of 2015: The A(nti)-Team

Четверг, 31 Декабря 2015 г. 14:30 + в цитатник

Building a good, healthy team environment is hard. In this story, they just don't bother. --Remy


In the 1980s, there was a TV show called The A-Team. There was the scrounger, who could scam anyone out of anything. He would make promises that were sort of true to get what he wanted (sound like marketing?) There was the tough guy who could intimidate anyone into doing anything. He knew how to get things done, but underneath it all, was a nice guy. There was the leader, who could always come up with a plan to save the day. And there was the one guy who was a little crazy (the good kind of crazy), but who you could count on in a pinch. There was also the occasional outside helper who would run interference and recon. This was a group of folks who worked as a well-oiled machine to get the job done. Failure was not an option! They were a team!

The A-Team never filed a project methodology document. No wonder they were wanted criminals.

Alex had taken a job on a new greenfield development effort to replace an aging and unsupportable birds-nest-o-wtf™. Naturally, the position was advertised as we intend to do things right! The project is fully funded. We will have the proper equipment and team personnel to get this job done. We have the full support of six layers of management plus all of the users. Alex was optimistic.

The first thing they did was spend several months wrapped in those numerous layers of management, end users, support folks, senior people who used to support the project (to explain the problems that plagued the old system), and the three architects of the new system. The new architecture was heavily documented, presented to and signed off on by all of the above. It was even reviewed with a critical eye by an independent third party regulatory auditing agency to ensure that the overseeing authorities were confident that the correct approach was being taken.

An 8 page document detailing development coding guidelines (e.g.: code formatting settings, naming conventions, unit tests, code coverage and other such team-wide items) was created, reviewed and decreed to be followed by all who worked on the project.

The project was off to a good start.

Job one was to hire the development part of the team. For this, they looked (very far) offshore to find the cheapest possible talent. After all, anyone can be trained, right? A team of 11 developers who collectively had 13 years of experience, and a team leader with 5 years of experience were hired and put in place.

The next major decision was which database should be used. There were three in widespread use at the company. Since all of the databases were hosted on centralized servers, one was immediately ruled out because the hardware that hosted the data servers was insufficiently powerful to handle the expected load in a reasonable time frame. Of the other two, one was widely used by everyone on the team. They knew its syntax, quirks and limits. The the third was mis-configured to have a reputation as being flaky. However, that one also was the corporate standard. In spite of the objections of the team, they used the third one.

Project management decided that QA folks could be brought in later.

Finally, it was time to begin doing detailed design. The offshore lead decided that a lot of time could be saved by doing design on-the-fly as required. Of course, the architects objected, but the project manager agreed to it.

And so the architects started working on building the controller engine and other such mainstays of the project. The junior team, which was to query numerous remote systems for input data, merge, filter and pre-process it, decided that they knew better than what was specified in the architecture document, and started designing their own way of doing things. Without telling the architects or management.

Come time for the first sprint check-in and all sorts of red flags flew up during code reviews. The junior lead decreed that the architecture document was only a suggestion that could be ignored in favor of the developers desires. Naturally, this spawned lots of are-you-fg-kidding-mes and emails up the chain. The project manager and above seemed disinterested, saying that the junior developers shouldnt be doing that, but we trust them to do the right thing.

This went on, with the architects pointing out implementation flaws and shortcomings that would not support the requirements. All suggestions were ignored, because the offshore lead said Google fosters an environment of innovation and creativity; we should too! He was reminded that Google is (in large part) a think-tank, and that this was a highly regulated project within a highly regulated industry. The architecture, which had been signed off by more than 40 managers, was not optional or a suggestion, but mandatory. This was not kindergarten, where creativity is fostered; you had to stick to the approved plan! Now, were not talking about how to write a subroutine, or encapsulate an object; were talking about using threading incorrectly and in the wrong places, doing database accesses and interprocess communication in such ways that would not be scalable, or provide enough throughput to finish daily runs by regulatory deadlines. Spawning multiple processes instead of just using threads. Using files to act as semaphores, because thats how they did it in school. The list goes on.

None of that mattered. The junior developers resented that they were not consulted on the architecture, and so were bent on ignoring it - with the blessing of their lead. The project manager continued to acknowledge the problems, but didnt do anything about them. The problems were reported up the chain, and nothing was done. Everyone on the team should have an equal say in things.

In the real world, if a student thinks the teacher is wrong, he doesnt get to change his grade. The surgical resident cuts where the surgeon says and not the other way around. The general doesnt discuss strategy with the privates. If you join a union, and as the new guy demand to have equal say on policy with the union bosses, youll be bunking with Jimmy Hoffa. Experience speaks with exclamation points. Inexperience speaks with question marks.

Except on this team.

The junior developers continued to do what they thought was best, ignoring the architects at every turn. Much of their code was written and rewritten several times over because the designs by the juniors didnt take things into account. Things more experienced folks know to plan for. By the time 8 months had passed, so much damage had been done that some of the more complex requirements simply couldnt be hooked in, and more than a month of back-pedaling had to be done on a greenfield development project.

About this time, management acquiesced and asked some of the business users to write business-level tests (e.g.: via a spreadsheet that would be fed into JBehave to JUnit test things). The developers would provide the underlying code and some sample entries in the spreadsheets. The architects said that QA folks should be hired because business folks rarely know how to deal with edge cases, precision issues, etc. But the money was not to be spent. After six months of effort, the business users proudly decreed that all the tests for the entire application (e.g.: the entire requirements document) had been set up. A five minute glance showed that they didnt handle edge cases, null cases, precision cases, or most of the other things that usually require tests. In fact, they had put all of the records that could possibly be processed (at least in their minds) into one giant pass-fail test. Of course, when something changed and it inevitably failed, there was no way to know what failed.

Finally, it got so bad that the architects built a physical wall in the code between the setup code (written by the offshore folks) and main engine (written by the architects) sections of the application. Immediately before the main engine began to grind the data, every single variable in the system would be flushed to a state table in the database, so that when something would inevitably be challenged, they could show the inputs that were provided and send the fix-it work to the offshore team. At least this way, they could insulate the main engine from the debris.

The department saved a lot of money by using cheap labor, no QA folks and the politically expedient database. Of course, all of the code of the setup portion done by the offshore team was a disaster, and for the most part, very difficult to learn, support, debug and enhance.

The product hadnt even been deployed yet, and the users were already complaining that it took too long to diagnose and fix problems (one of the main reasons the whole rewrite project was authorized), that perhaps the rewrite wasnt satisfying the main purpose of the rewrite, and that perhaps something might be wrong&

[Advertisement] Scout is the best way to monitor your critical server infrastructure. With over 90 open source plugins, robust alerting, beautiful dashboards and a 5 minute install - Scout saves youvaluable engineering time. Try the server monitoring you'll M today.Your first 30 days are free on us. Learn more at Scout.

http://thedailywtf.com/articles/best-of-2015-the-a-nti-team


Метки:  

Best of…: Best of 2015: Tis' the Season

Среда, 30 Декабря 2015 г. 14:30 + в цитатник

We just finished the holiday season, but it's not too long ago that we were wrapped up in a different kind of season: Hunting Season As commenter RFoxmich pointed out: this might be the first 0pt. "Buck". --Remy


Deep in the wooded vales of red state America, December is hallowed not just for hunting presents, but also hunting deer. Lo, the season opened on a Friday. Clayton’s consulting firm declared it Camo Day in celebration.

Employees festooned themselves and their office in their brown-and-green finest. Some posted deer horns and small taxidermic animals in prominent locations. While this particular company stopped short of installing a shotgun in the kitchen, just in case a bear happened along, it was still the most redneck of wonderlands.

Clayton could even swear he smelled hunting musk as he moved through the floor, trying to get back to his desk after an exhausting code review. And everywhere he looked, camouflage-print duct tape lingered like traces of scat: patching a hole in the carpet, propping up the back of a swivel chair, cradling a leaky ceiling tile …

Both tape and musk led to his manager Buck’s office.

“How you doin’, Clayton!” His voice boomed out from the office like a blunderbuss’ payload, halting Clayton in his tracks. “How’d that code review go?”

Clayton peeked in to find Buck applying a piece of camo duct tape to a patch of ruined drywall behind his desk chair. He ignored the scene to reply, “Fine. John has some changes to make, but nothing major.”

“Good, good.” Buck rubbed a fist over the newly applied tape. “Don’t mind me, I’m just taking the initiative to fix a few things around here.”

Clayton debated whether to say anything. In the end, he couldn’t help himself. “Uh, all that stuff you’re fixing probably needs more than duct tape.”

This prompted Buck’s ringing laugh. “If you can’t fix it with duct tape, you’re not using enough!” Finished with the wall, Buck turned, yanked his laptop out of its docking station, and began wrapping the camo-colored tape around it.

Clayton really knew better, but again couldn’t help himself. “What are you doing?”

“Decorating my laptop!” Buck replied.

“But … you’re covering the vents,” Clayton managed around his shock. “It’s gonna overheat.”

“It’s winter and it’s cold out! This thing’ll be fine.”

“Win—you’re taking it outside?” Clayton faltered.

“Out to my hunting blind! I’m cutting out early to get a jump on the season.” Buck reached into his pocket. Out came an obnoxiously sized lock-back knife that he used to slice a gap into the tape layer, allowing him to open up the laptop.

“Why bother working remotely?” Clayton asked. “Just call it a week.”

“The usual BS quarterly meeting is this afternoon—of course.” Buck rolled his eyes. “Gotta join the WebEx and at least pretend to pay attention.”

The WebEx would handle both video and audio for the meeting. Clayton imagined the deer would take a dim view to budget projections, but Buck’s laptop did have a mute button.

“Happy hunting, champ! I’ll have my cell phone in case you need anything.” Buck packed his laptop, then gathered his coat and a cooler that was almost certainly full of beer.

“Uh, OK.”

In the end, Clayton couldn’t complain about a manager-free afternoon. He returned to his desk, dug into his work, and all was well.

A few hours later, his desk phone rang. Buck’s cell.

Clayton internalized a curse and picked up the phone. “Hello?”

There was nothing on the other end at first aside from scuffling, and a string of very not-internalized curses from Buck.

“Boss?” Clayton prompted.

“The damn thing’s a brick!” Buck cried.

“What is?” Clayton asked.

“It just shut down on me!”

“Your laptop?”

“And the damn meeting’s still on!” More scuffling noises from Buck’s end. “Hopefully everyone’s too busy snoozing to notice I fell off the WebEx. Hang on, I’ll be in the office soon!”

Clayton didn’t bother stifling his groan, but managed to hang up before it escaped.

Twenty minutes later, Buck stampeded into his cube, cooler and laptop in tow. He dropped the camouflaged computer onto Clayton’s desk, shaking out his hand. “Sumbitch shut down on me out of nowhere!”

Clayton felt the waves of hot fury radiating off the laptop when he stuck his hand near it. “It overheated, like I said. You blocked the fans that keep air circulating through there,” he explained. “We gotta get this tape off.”

“Nah! If it’s hot, we just gotta cool it down, right?” Buck opened up his cooler and pulled out a half-melted bag of ice. He then turned and dropped said bag directly onto the laptop.

Clayton’s jaw fell. Should he bother to say anything? No, it never helped.

“While it’s cooling off, I’ll need your computer to log back into the WebEx,” Buck said.

Clayton suppressed his instinctive panic. “You have to leave it here. No ice or camo. I’m done for the day, and I’m not touching any more work until Monday! Deal?”

“Deal.”

With a collecting breath, Clayton logged out, then stood to gather his belongings. “There you go.”

Buck clapped him on the shoulder. “Happy hunting, champ!”

[Advertisement] Release! is a light card game about software and the people who make it. Play with 2-5 people, or up to 10 with two copies - only $9.95 shipped!

http://thedailywtf.com/articles/best-of-2015-tis-the-season


Метки:  

Best of…: Best of 2015: Once You Eliminate the Impossible…

Вторник, 29 Декабря 2015 г. 14:30 + в цитатник

This article, from April had a problem, so they decided to use XML. Now they have An error occurred while parsing EntityName. Line 7, position 32. -- Remy

Once you eliminate the impossible…

&Whatever remains, no matter how improbable, must be XML.

William Hogarth - Absurd perspectives.png

Developers have many weaknesses, among them this: they dont like to say that something cant be done. Thats why when Glenn Ms client, TelCo, asked if their request was really impossible, instead of apologizing and vigorously nodding his head, Glenn said, Well, technically&

And thats how he ended up writing this.


    
        
            
                
                    
                        
                            
(?:0x)?([0-9a-fA-F][0-9a-fA-F])\s*([0-9a-fA-F][0-9a-fA-F])\s*([0-9a-fA-F][0-9a-fA-F])\s*([0-9a-fA-F][0-9a-fA-F]) .1.3.6.1.4.1.2011.2.217.1.4.1.1.6 %4$s%3$s%2$s%1$s 8388607 8388608
1
1 (?:0x)?([0-9a-fA-F][0-9a-fA-F])\s*([0-9a-fA-F][0-9a-fA-F])\s*([0-9a-fA-F][0-9a-fA-F])\s*([0-9a-fA-F][0-9a-fA-F]) .1.3.6.1.4.1.2011.2.217.1.4.1.1.6 %4$s%3$s%2$s%1$s 23 255 127
(?:0x)?([0-9a-fA-F][0-9a-fA-F])\s*([0-9a-fA-F][0-9a-fA-F])\s*([0-9a-fA-F][0-9a-fA-F])\s*([0-9a-fA-F][0-9a-fA-F]) .1.3.6.1.4.1.2011.2.217.1.4.1.1.6 %4$s%3$s%2$s%1$s 31 1 1 -1 1

Thats an XML DDF, a Data-Definition File for the systems-monitoring application Glenn supports. See, the system can read data from any device that supports the Modbus/TCP or SNMP protocols, as long as it has a DDF file that defines the data points and how theyre to be displayed. The DDF schema includes the arithmetic, boolean, regex, and conditional operators you see above, to let the system know how the data should be cleaned up.

Logic via XML? Thats a WTF all by itself, sure. But TRWTF is what that snippet above is actually doing. TelCo was monitoring a device that spat out temperature values (simple enough), but it presented them as an eight-character string representing the hexadecimal value of an IEEE754 32-bit floating-point number. The task that Glenn probably should have said was impossible was to cast that bizarre value back into its numeric equivalent. DDF, for all its awesome expressive power, lacked a typecast operator.

Thats why Glenn wrote the DDF shown above, which does this:

  • Since the byte order was flipped, use to put them back in an order we can work with
  • Use to convert from octetString to uint_32
  • Use and to isolate the sign bit, exponent and mantissa
  • Convert the sign bit to +/1
  • Unbias the exponent, then 1 by that many
  • Divide the mantissa by 2^23
  • Multiply the last three items together to get the final result. Since and other operators only accept 2 operands, these need to be nested

Next time, Glenn plans to stick to his guns, because he just heard that TelCo will be modifying their device to present temperature using integers.

[Advertisement] Release! is a light card game about software and the people who make it. Play with 2-5 people, or up to 10 with two copies - only $9.95 shipped!

http://thedailywtf.com/articles/best-of-2015-once-you-eliminate-the-impossible


Метки:  

Best of…: Best of 2015: To Spite Your Face…

Понедельник, 28 Декабря 2015 г. 14:30 + в цитатник
This article, from February had me cringing even as I reread it- and I wrote it! I've had the misfortune of working on a number of projects that failed because of people like Brandon making sure they failed. --Remy

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] 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/best-of-2015-to-spite-your-face


Метки:  

Coded Smorgasbord: Classic WTF: Holiday Smorgasbord

Пятница, 25 Декабря 2015 г. 14:30 + в цитатник

Your Christmas present this year is a pile of WTFs from back in 2005. A veritable holiday smorgasbord. This post wouldn't be here if it didn't exist. --Remy

It's been a while since I've done a smorgasbord post, so here goes ...


DM discovered the source of some rather ... unprofessional ... error messages in the log files ...

try
{
  /* SNIP: 15 lines */
}
catch
{
  //How did this happen??
  log.fatal("Aaaaarrrgghhhh");
}

A former developer on Chris' team made up his own way of handling align="center" ...

Please click the 'Print' button to print the Licence Terms and Conditions and sign to accept where indicated.
<br><br>
        
        
        
        
        
        
        
        
      
<input type="button" value=" Print " onclick="window.print();">

The customer service at Jason Harmon's had been telling clients that the bad data coming seen in their system was a configuraiton problem, not a code problem. A client finally complained enough to get the problem pushed back to development where Jason learned that this just might be a coding problem after all ...

private bool IsValid() 
{
  return true;
}

Shayne Studdard chuckled at the original authors comment while porting the old ASP code into the ASP.NET ...

var aLeapYears = 
new Array(1900,1904,1908,1912,1916,1920,1924,1928,1932,1936,
1940,1944,1948,1952,1956,1960,1964,1968,1972,1976,
1980,1984,1988,1992,1996,2000,2004,2008,2012,2016,
2020,2024,2028,2032,2036,2040,2044,2048,2052,2056,
2060) //please god let this be far enough??

Chris Reigrut recalls a conversation with a technical support guy years back when he had a problem with one of their products ...

Chris : We're having problems with the new version of your software.
Support : That can't be. We didn't change anything.
Chris : Well, I uninstalled the new version and put the old one back on, and the problem went away. I then reinstalled the new version, and the problem came back.
Support : No, it can't be our software. We didn't change anything!
( ... Lots of back and forth about my analysis of the problem ...)
Chris : So you're telling me that you sent out an update, but you didn't change anything. If that's the case, what's the point of the update?
( ... More back and forth, Support getting more and more exasperated ...)
Support : I'm telling you, nothing changed!!! The only difference between the old version and the new version is that the old version was in COBOL, and the new one is in C!!!

Tristan Harmer was a bit mystified by this metaphysical comment ...

If iFile.Exists Then
fileSizeBytes = iFile.Length.ToString
Else
'Actually this test was done earlier
' - the code wouldn't be here if it didn't exist
Throw New FieldAccessException("File does not exist.")
End If

And I suppose I'll wrap it up with this bit from TomA, who shows us yet another way to zero-pad a number

$limit = 9999;
for($i=1000;$i<$limit;$i++) 
{
  $number = "$i";
  if ($i<10) $number = "0".$number;
  if ($i<100) $number = "0".$number;
  if ($i<1000) $number = "0".$number;
  if ($i<10000) $number = "0".$number;
  if ($i<100000) $number = "0".$number;
  [ ... snip ...]
}
[Advertisement] Release! is a light card game about software and the people who make it. Play with 2-5 people, or up to 10 with two copies - only $9.95 shipped!

http://thedailywtf.com/articles/classic-wtf-holiday-smorgasbord


Метки:  

The PM Who Stole Christmas

Четверг, 24 Декабря 2015 г. 14:30 + в цитатник

Its Christmas Eve, and that means were taking a little break from writing new articles. Starting next week, well re-run all of the best articles of this year.

For today, though, while I was working on The Glitch Who Stole Christmas, I got a bit inspired, and maybe a bit carried away.
Instead of our usual fare, heres something a little… different.

Every Dev down in Devville liked Christmas a lot…
But the PM who lived in the corner office did NOT!
The PM hated Christmas! The whole Christmas season!
Now, please dont ask why. No one quite knows his reason.
It could be his head wasnt screwed on just right.
It could be, that his project timeline was too tight,
But I think the most likely reason of all,
May have been that his brain was two sizes too small.

Whatever the reason, his brain or his sprint,
He stood there on Christmas Eve, squinting a squint,
Staring down from his desk with a sour, PM grimace,
At the cold dark monitors around the office.

For he knew every Dev down in Devville beneath,
Was busy now, hanging a mistletoe wreath.
And theyre hanging their stockings! he snarled with a sneer
The milestones tomorrow! Its practically here!
Then he growled, with his PM fingers nervously drumming,
I MUST find some way to stop Christmas from coming!"
For tomorrow, he knew, all the Dev girls and boys,
Would wake up bright and early. Theyd rush for their toys!

And then! Oh, the noise! Oh, the Noise!
Noise! Noise! Noise!
Thats one thing he hated! The NOISE!
NOISE! NOISE! NOISE!

Then, the devs, young and old, would sit down to a feast.
And theyd feast! And theyd feast! And theyd FEAST!
FEAST! FEAST! FEAST!

They would feast on Soylent, and rare energy drinks,
This was something the PM couldnt stand to think,
And THEN theyd do something he liked least of all!

Every dev down in Devville, the tall and the small,
Would log on together, network lights blinking.
Theyd stand, lan-on-lan. And the devs would start playing!
Theyd play! And theyd play! And theyd PLAY!
PLAY! PLAY! PLAY!

And the more the PM thought of this dev Christmas-thing,
The more the PM thought, I must stop this whole thing!
Why, for twenty-three years Ive put up with it now!
I must stop this Christmas from coming! But HOW?

Then, he got an idea! An awful idea!
The PM got a wonderful, awful idea!

I know just what to do! the PM laughed with a hoot,
And then he ran a command and made a server to reboot.
And he chuckled, and clucked, What a great PM trick!
With the server down, theyll need to come back in, and quick!
All I need is an outage… the PM looked around.
But, since load balancers are robust, there was none to be found.

Did that stop the old PM? No! The PM simply said,
If I cant make an outage, Ill fake one instead!
So he fired up Outlook, made the font color red,
And typed out a message which frantically said:

The server is down, the application has crashed,
The developers responsible should have their heads bashed!

Then the PM clicked SEND and the chain started down,
From the CEO to the devs, asnooze in their town.
All their windows were dark. Quiet snow filled the air.
All the devs were all dreaming sweet dreams without care.

Then he did the same thing to the other Devs projects,
Leaving bugs and errors and emails with scary subjects.
The project is late, we surely are doomed,
He wrote and sent and the emails zoomed.

And the PM grabbed the source tree and he started to skim,
When he heard someone asking, Why are you in VIM?
He turned around fast, and he saw a small Dev!
Little Tina-Kiev Dev, who was an SAII,
The PM had been caught by this tiny code enabler,
Whod came to the office for her red stapler.

She stared at the PM and said, Project Lead, why,
Why are you checking our source tree? WHY?
But you know, that old PM was so smart and so slick,
He thought up a lie and he thought it up quick!
Why, my sweet little tot, the fake developer lied,
A line in this code wont lint and that commits denied
So Im checking in a patch, my dear.
Ill release it out there after I fix it up here.
And this fib fooled the dev. Then he patted her head.
And he got her a red stapler and sent her to bed.

Feh, feh to the devs! he was PMishly humming.
Theyre finding out now that no Christmas is coming!
Theyre just waking up! I know what theyll do!
Their mouths will hang open a minute or two,
Then the devs down in Devville will all cry Boo hoo!
Thats a noise, pipped the PM, That I simply must hear.

So he paused. And the PM put his hand to his ear.
And he did hear a sound rising over the snow.
It started in low. Then it started to grow.
But the sound wasnt sad! Why this sounded merry!
It couldnt be so! But it WAS merry! Very!

He stared down at Devville! The PM popped his eyes!
Then he shook! What he saw was a shocking surprise!

Every Dev down in Devville, the tall and the small,
Was playing! Without any calls at all!
He hadnt stopped Christmas from coming! It CAME!
Somehow or other, it came just the same!

And the PM, with his PM-feet in sensible shoes,
Stood puzzling and trying to understand this news.
I sent emails! I marked them important!
I filed tickets with statuses of urgent!
And he puzzled three hours, till his puzzler was sore.
Then, the PM thought of something he hadnt thought of before!

Maybe Christmas, he thought, doesnt disrupt my sprint,
Maybe Christmas… perhaps blocked days arent a misprint.
And what happened then? Well… in Devville they say,
That the PMs small brain grew three sizes that day!
And the minute his schedule didnt feel quite so tight,
He whizzed out of the office through the bright morning light.

Happy Holidays!

Image credits:
Uses the following assets:

  • Concept Draw screenshot by Anna Korlyakova (CC license)
  • [Advertisement] Release! is a light card game about software and the people who make it. Play with 2-5 people, or up to 10 with two copies - only $9.95 shipped!

http://thedailywtf.com/articles/the-pm-who-stole-christmas


Метки:  

The Glitch Who Stole Christmas

Среда, 23 Декабря 2015 г. 14:30 + в цитатник

Every Who down in Whoville like Christmas a lot…
But the Bug, who lived just North of Whoville, did not!

Peter L sat on his recliner, wireless keyboard and mouse balanced on his lap, and watched Jebediah Kerman burn up on re-entry. It was Cyber Monday, also known as look, the consumer didnt buy enough stuff on Black Friday, so please buy more stuff!

Peter was enjoying his day off in part, because he was good at his job. He worked for an ad company, running the analytics and making sure the right ads got served up to the right customers at the right times. And here, on the busiest online shopping day of the year, no one was calling him, no one was screaming that the campaign wasnt running, no one was going to get him out of this-

Honey, Macys isnt working, his wife called from the other side living room. Can you take a look?

What do you mean its not working? Are you getting an error?

No. It just hangs on this loading screen when I try and check out.

Just refresh it, Peter said as he started trying to redesign Jebediahs next Kerbal death trap.

I did that. And I tried another browser. And its not in private mode. And some of the gifts in the cart are yours.

Peter sighed, put his game aside, and levered himself out of the recliner. His wife walked him through the steps: she could browse the store fine, she could add items to her cart, but when she clicked the checkout button, it would go to a page that displayed nothing but a Loading… modal popup.

Peter noticed that this was pointing at a different domain- www1.macys.com instead of www.macys.com, which made him wonder if Macys had underestimated the load theyd need to service. Still, it did look like a lot of assets were getting served up successfully, so maybe there was something else wrong.

He pulled up the Firefox dev tools and checked the logs. Sure enough, a huge pile of errors was dumped out, and most of them revolved around assets which had failed to load- assets which werent hosted on Macys servers, but one of those awkward and anonymously named ad servers.

For a moment, Peters pulse shot up, fearing that his company might be responsible for taking Macys down. A quick check on the domain proved that it actually belonged to a different ad company. They were attempting to load a tracking pixel and that load was failing and the breaking other scripts on the page.

Peter saved the page locally, commented out the offending tracking elements- and there were a lot of them- and then loaded up the local version of the page. A quick click of the submit button sent their orders up to Macys servers and along with it, all the gifts for their aunts, uncles, nephews, and Peter.

And what happened then? Well… in Whoville they say,
That some anonymous ad servers capacity grew three sizes that day!

[Advertisement] Scout is the best way to monitor your critical server infrastructure. With over 90 open source plugins, robust alerting, beautiful dashboards and a 5 minute install - Scout saves youvaluable engineering time. Try the server monitoring you'll M today.Your first 30 days are free on us. Learn more at Scout.

http://thedailywtf.com/articles/the-glitch-who-stole-christmas


Метки:  

CodeSOD: The Apple Genius

Вторник, 22 Декабря 2015 г. 14:30 + в цитатник

Apple refers to their in-store technicians as geniuses. Everyone on Earth knows that its nothing more than cute marketing and is a meaningless title.

Well, almost everyone. Derick worked for a company where the CIO worked at Apples HQ at some point. Said CIO was quite proud of this achievement, and made sure everyone knew it. He wasnt happy that his new startup had decided to use C#, but it was okay: he was ready to reinvent core pieces of the .NET framework to avoid having to deal with whatever bombs Microsoft had snuck in.

And he was going to optimize it.

 static public bool RegExp(ref String buffer, ref String compare)
        {
            bool bMatch = false;

            if ((buffer.Length == 0) || (compare.Length == 0))
            {
                return bMatch;
            }

            try
            {
                // DO NOT USE RegexOptions.Compiled -> Massive Overhead - NO BENEFIT
                Regex _regex = new Regex(@compare, RegexOptions.IgnoreCase);

                Match match = _regex.Match(buffer);
                if (match.Success)
                {
                    String matchString = match.Groups[0].Value;
                    bMatch = true;
                }
            }
            catch (Exception ex)
            {
#if DEBUG
                string str = ex.Message;
                string ttl = "Company (DBG)";
                MessageBox.Show(str, ttl);
#else
    
    // throw new Exception("An error occurred", ex);
#endif
            }

            return bMatch;
        }

Theres a lot of little things in here. Swallowing exceptions is always a great code smell, but its even better to see the line that was commented out- even when they rethrew the Exception, they wrapped it in a generic Exception object, breaking any attempts to use structured exception handling to respond to the specific error.

Of course, that happens inside of a conditional compilation section- so in DEBUG mode, it raises a Message Box instead, which is great. I love clicking through piles of those when the application runs into a problem that isnt properly handled.

The use of the @ sign on the @compare is intriguing. The @ means two things in C#. First, and most often, you use it to disable metacharacters on a string literal. Rarely, you use it to let you create a variable named after a keyword: int @while = 5.

compare is neither a string literal, nor is it a reserved word in C#.

But finally, the icing on the cake, is his comment.

// DO NOT USE RegexOptions.Compiled -> Massive Overhead - NO BENEFIT

CIO Wile E. Coyote, SUPER GENIUS, discovered that compiling a regex does nothing but add overhead when youre throwing away the instance and never using it again. This was such a shocking discovery that the CIO had to make sure to document it IN CAPITAL LETTERS.

[Advertisement] Release! is a light card game about software and the people who make it. Play with 2-5 people, or up to 10 with two copies - only $9.95 shipped!

http://thedailywtf.com/articles/the-apple-genius


Метки:  

The Machine

Понедельник, 21 Декабря 2015 г. 14:30 + в цитатник

The Haunted House Das Geisterhaus (5360049608)

I shouldn't have taken that call, I thought, looking down the dark, endless staircase.

But deep down, I knew there was no other choice. Running a computer repair shop in a town like Derry meant one thing: if you want to put food on the table and pay the bills, you can't afford to lose a client. No, not in this day and age, not in a market filled to the brim with geeky teenagers offering cut-throat prices. You snatch up every opportunity and suck it dry before it worms out of your hands.

Besides, it was supposed to be an easy job. Just an animal shelter on the outskirts of the town with a computer—"The Machine", as the monotone voice over the phone had called it—that wouldn't turn on.

Plug it back into the wall socket, pocket the cash, and head home, I'd thought, driving a muddy dirt road out of town and into a dark, foggy marsh. Easy money.

But now, staring down the abyss leading to the shelter's basement, listening to the distant howl of hundreds of stray dogs, breathing the stale air filled with a faint tinge of decay ... suddenly, it didn't look that simple.

"Take care." Behind me, the shelter's owner—an old, weary man stuck managing a building in equally bad repair— watched me from a distance. There was something off about him, about the way he looked at the door, how his face twitched slightly every time I mentioned the computer.

It's probably nothing, just the quirks of old age, I kept thinking, but the suspicion in the back of my mind refused to die down.

"I will," I told him, then closed the door behind me.

The bare old bulb at the end of the stairwell didn't provide much light to see by. I put my hand on the unpainted wall and slowly set my foot on the concrete step below, trying to keep balance while my eyes adjusted to the dimness. Step by step, I slowly headed down, the air growing thicker and heavier around me, the noxious smell intensifying, making me sick to my stomach ... but I held on, some nagging feeling driving me further and further into the unknown.

Finally, I reached solid floor and looked around the room. It was tight, quiet, and almost empty—very much unlike the rest of the shelter, as if it didn't belong to the building.

And it was there, atop a light wooden table against the grey, bare wall, plugged into the sole wall socket in the room.

The Machine.

It was an apt name for that piece of hardware. The solid, unbranded beige tower standing next to a bulky CRT monitor and a Model M keyboard radiated an aura of nostalgic grandeur. I stepped towards the table and ran my finger across it, collecting a thick layer of dust. But the computer itself looked almost brand new, its case shining even under the weak light of the room.

It must've been here for at least twenty years, I thought. Why would anyone still use such an antique? I flicked the switch on the front.

The computer roared.

I've heard a lot of noises coming from a computer, but never anything like that. It was the howl of a hurt, suffering animal, a scream of agony. I stepped back instinctively, but the sound persisted, filling the air with a maddening wail that I was sure could be heard throughout the whole shelter. A moment later, the monitor lit up.

OPERATING SYSTEM NOT FOUND

I turned the poor PC off, and the noise stopped. I reached for a screwdriver in my pocket, but then I noticed a floppy drive next to the switch. I pushed the eject button, and a disk slipped out of the slot. I pulled it off and held it to the light: a red, unlabelled 3.5 inch floppy, just like any other. Hoping that would solve the problem, I set it aside and tried booting the PC again.

The howl was even louder and angrier than before, and the same words showed on the screen before I put the computer out of its misery.

So, you won't find the OS. Let's see your hard drive, then.

I unplugged all the cables from the back and put the case on the floor. Slowly, I took out all the screws, and dismounted the side panel.

THUMP!

The mangled body of a black rat fell out of the chassis, filling the room with the rotten stench of death.

I froze. I tried to scream, run, do anything at all, but I couldn't, as if something were holding me in place. I looked at the rodent—its fur marked with deep, bloody wounds, its eyes wide open with a piercing stare—and a million thoughts rushed through my mind. How did it even get there? How did it end up like this? It's as if ...

As if The Machine chewed on it, a quiet voice whispered in the back of my head. Chewed on it, then spat it out like a bad dinner.

Holding back a retch, I tossed the rat away and examined the computer's insides. There was no hard drive, not even a place for it, but I noticed the floppy connector dangling in front of the motherboard, probably pulled out by the poor creature struggling for its life. I plugged it back in, reassembled the case, and hooked it to the rest of the setup.

Finally, I slipped the disk back into the drive, and, heart pounding, I pressed the power switch again. A fan spun up quietly, the floppy drive started buzzing ...

... and finally, the DOS prompt showed up.

I ran. I ran up the stairs, leaving The Machine behind me, rushing to get as far away from this place as possible. I kicked the door open and burst into the blinding light of the main shelter hall, panicked, breathing heavily and nearly falling to my knees. I looked around, squinting under the painful brightness.

No one was there. Even the dogs had fallen silent. A brown paper envelope rested on a nearby desk, labeled FOR FIXING THE MACHINE in bold, black letters.

A thought formed in my brain: How did they know I fixed it? And then another one: Would I be here if I hadn't?

I opened the envelope with shaking hands and reached inside. A thick wad of cash in tens and twenties, almost five hundred dollars wrapped together.

They could've bought a new computer with this kind of money, I thought, but something told me they would never do that.

I stuffed the bills back in the envelope and prepared to leave, but as I ran my fingers over the brown paper, I felt something stiff inside. Curious, I pulled it out.

A red, unlabelled, 3.5 inch floppy, just like any other.

[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/the-machine


Метки:  

Error'd: Exactly What I was Looking For

Пятница, 18 Декабря 2015 г. 14:00 + в цитатник

Adrian K. wrote, "Why yes, Apple Developer Forum, that is EXACTLY what I meant!"

"I'm not sure that Android Studio knwos what's going on," writes Maciej P.

"In space and virtual? Sign me up," wrote Mark F.

"Just my luck. Xfinity's billing exception error page caused another exception," writes Chris L.

Kolja writes, "I guess they forgot to follow their own instructions."

"Yeah, the file exists," Matt T. wrote, "THAT'S my problem!"

"With all the sick people who could potentially use a ATM in a given day, I guess it was only a matter of time before it developed a sore throat," Chris C. writes.

"While maybe not for everyone, I agree with YouGov," wrote Edward H., "the University of Oxford has the potential to be a great pet."

[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/exactly-what-i-was-looking-for


Метки:  

Representative Line: The Returned Value

Четверг, 17 Декабря 2015 г. 14:30 + в цитатник

Wilson Silva was looking through some production code, and found this representative line. This particular block of Ruby code was written by someone who claimed to have lots of programming experience. One must wonder what that experience was.

def return_value(value)
  return value
end
[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/the-returned-value


Метки:  

The Excel Expert

Среда, 16 Декабря 2015 г. 14:30 + в цитатник

Named Variables in Excel

Ishai bore the unenviable, oft-cursed title of Microsoft Support Engineer. Just about every user who ended up in his call queue was peeved from the start, having navigated half a dozen phone menu options and being stuck on hold for interminable wait times. It didn’t make for a productive support experience.

There was nothing Ishai could do about it. After years in the trenches, he was used to it; customer ire was like his own personal cosmic background radiation. But no matter how many times one thinks he’s seen everything, the universe always has something more to reveal to him.

His desk phone rang for the umpteenth time that day. “Tier three support, this is Ishai. How may I help you today?”

Instead of the mix of frustration and relief most people had upon reaching a human, this caller started off … haughty.

“I am Professor Benson. Got that? Professor Benson, not ‘Mr. Benson’ or ‘Sir’ or anything else you decide to call me. I’m a Computer Science professor at BigName University, and I’ve found a bug in the latest version of Excel.”

Get in line, Ishai thought. Happily, he was free to roll his eyes without risk. “Can you explain the problem, si—uh, Professor?”

“I’m performing a complex calculation.” Professor Benson rattled off the name of an obscure formula that took several variables as input, a formula Ishai had little familiarity with. “The results Excel gives back are wrong. I have no trouble working the calculation by hand, and when I do, I get the expected result.”

“I see,” Ishai said. “I’ll need some time to look into this. Can you provide your callback number? I’ll get back to you with a progress update within the next week.”

“The next week?” Professor Benson sniffed. “All right. I suppose I have no choice.”

Ishai obtained his contact information and gratefully ended the call, but his relief was not to last. The formula turned out to be extremely complex. He needed almost the full week just to figure out what it was supposed to do. Finally, he amassed enough understanding to attempt a few calculations by hand.

To his complete lack of surprise, he found his calculations matched Excel’s results every time.

“I’m sorry, Professor Benson,” Ishai spoke over the phone a short while later. “It looks like everything’s working as expected.”

“Well, yes,” Professor Benson replied. “In the simplistic cases you no doubt tested with, it works fine. But in more complex scenarios, it doesn’t.”

Ishai frowned. “Maybe you could send me a representative sample to test with?”

“Well, all right,” the professor huffed. “If you think you can handle it.”

“I’ll give it my very best shot,” Ishai half-growled back.

Ishai received a sample workbook from Professor Benson a short while later. Upon opening it, he had to bite back a sob. The calculations were hard enough with integers. Here, the good professor was using exponents and other values out to 7 decimals. The sort of thing that was next to impossible to calculate by hand.

It took another long week of struggling, but Ishai finally completed the calculations. To his shock, Professor Benson was right. Excel was giving the wrong answer—or so it seemed at first. Since part of the formula involved raising variables to the power of other variables, every single digit counted. The professor had configured his workbook to only have 2-decimal digit precision—thus, numbers like 2.0103235 were being truncated down to 2.01 before any mathematical operations were performed. Once Ishai changed the decimal precision to 10, Excel began providing the correct answer.

Relieved, and not without some measure of evil glee, he called Professor Benson and explained the issue.

Instead of the slightest bit of gratitude, Professor Benson’s tone of voice froze over. “And I assume you believe this is fixed now?”

“Well, nothing’s actually broken,” Ishai explained. “Excel’s behaving correctly. You just—”

“’I just’ nothing!” the professor cried. “If I didn’t know about changing the precision, how can you expect anyone else to? Your implementation of the formula is flawed! I should be getting a refund from you people, or at least a medal!”

“I’m sorry, but there’s no bug here,” Ishai pleaded.

After another 30 minutes of unproductive bickering, Ishai finally got Professor Benson off the phone—but not before Benson had threatened to complain to his manager, his manager’s manager, all the way up to Bill Gates if he had to.

Ishai slumped over his desk, nursing his temple. “Man, I gotta become a developer,” he muttered. “I bet they don’t deal with crap like this.”


I’m giving away a paperback of my sci-fi/fantasy novel Blood’s Force. Want a chance to win your very own hard copy? Use the widget below to enter!

Goodreads Book Giveaway

Blood's Force by Ellis Morning

Blood's Force

by Ellis Morning

Giveaway ends December 19, 2015.

See the giveaway details at Goodreads.

Enter Giveaway
[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/the-excel-expert


Метки:  

CodeSOD: Leaving an Honest Comment

Вторник, 15 Декабря 2015 г. 14:30 + в цитатник

Apos workplace just recently migrated their code into source control. They have eight years of code thats been written and maintained by developers using a network share as their central repository.

// Special treatment for Attribute "weight unit"
// Needs to be mapped to more readable values for display because SAP is using some ISO codes that are not understandable
// by normal users. Hence, if we encounter this attribute, we map it to resemble an easier understandable unit
// Yes, this is all hardcoded, yes "one" should not do that
// Please redirect any complaints to the peeps who do budgeting and the customer who is not paying to do this properly
if (idAttribute_ == 18500) {
        if (textblock_ == "KGM") {
                textblock_ = "KG";
        }
        if (textblock_ == "MGM") {
                textblock_ = "MG";
        }
        if (textblock_ == "GRM") {
                textblock_ = "G";
        }
}

Apparently, they dont have the budget for a hash map. Apo discovered this when the customer complained about the formatting for tons. Unfortunately, he was tackling the problem while juggling 300 other higher priority customer issues, so instead of spending five minutes to clean it up, he spent 30 seconds adding another if statement.

[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/leaving-an-honest-comment


Метки:  

Tales from the Interview: Secure Portfolio

Понедельник, 14 Декабря 2015 г. 14:30 + в цитатник

Atari Portfolio Photomanipped

"Heeey, Sean ..." Aisha's tone was cloying as she poked her head around the divider of Sean's cube, still seated on her desk chair.

"No," he joked, looking up from his work.

She laughed, weakly. "Listen, John's sick, probably out the whole week. Can you interview this new dev candidate?"

Glancing at his calendar, Sean sighed. "Sure. When will he be here?"

"An hour from now. Here's his code sample, good luck!" She thrust some papers into his hand and rolled away, leaving Sean dumbfounded.

Great, he thought. What am I in for?

Figuring he'd at least familiarize himself with the sample, toss the guy the usual softball questions, and get a feel for him, Sean flipped through the stack of printouts. Oddly enough, along with his PHP code, the candidate had submitted a SQL dump.

"Thoughtful of him," Sean murmured. "Weird, though ... this test data looks very real."

Then he flipped over the page and found the CREATE TABLE for the USERS table. What followed were a hundred insert rows, all with passwords like "==AUWZEdZhlTT1UMaVXTWJVU".

"Is that ... Base 64, reversed?" Sean wondered, flipping to the PHP code in horror. Sure enough, he found the following in "Security.php":


function encode5t($str){
 for($i=0; $i<5; $i++){
 $str=strrev(base64_encode($str));
 }
 return $str;
}

"Because just one encode-and-reverse wasn't enough," Sean snarked, rolling his eyes, then raised his voice to be heard over the cube wall. "On second thought, Aisha, I'm feeling under the weather myself. Better call the guy and cancel."

And maybe call his previous employer and let them know about the data breech while we're at it, he thought.

[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/secure-portfolio


Метки:  

Error'd: Flipping Burgers at Google

Пятница, 11 Декабря 2015 г. 15:00 + в цитатник

"For some, Google interview questions are getting more obscure," writes Ernie, "but for those of us who worked for years in fast food, all that toiling might pay off."

"Prezi.com online presentation portal has a prezi about the life after flash, but I cannot watch it without flash," writes Peter.

"Good thing I'm not a Toyota owner," wrote Daniel, "especially since I don't have any flood insurance."

"Looks like the stress from starring in all those ads has pushed Flo over the edge," Todd R. wrote.

Mark R. wrote, "Microsoft Ignite Australia is happening...someday."

"In an ocean of errors, I see one faint glimmer of hope," writes Piero C.

Kolja wrote, "Useless? Well, what am I even doing?!"

"After putting it off for a while, I'm REALLY glad that I finally decided to pull the trigger on the Windows 10 upgrade," Jack T. writes.

[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/flipping-burgers-at-google


Метки:  

Awk-ward Error Checking

Четверг, 10 Декабря 2015 г. 14:30 + в цитатник

Emma W. was hired on by BerkTechs QA department in preparation for a major code rewrite. A Russian company had purchased a thousand copies of BerkTechs emponymous software package, but as it only supported English, it would require a substantial localization project to support Russian.

After Emma started, it didnt take long for her to notice some common patterns in her unit tests.

Why is the script scrubber.awk telling me a file is missing a semicolon? she asked Danny, her supervisor. Shouldnt this error come from the compiler?

No, we scrub everything before it gets to the compiler, Danny explained. Nothing ever reaches it without passing our best practices. Thats what scrubber.awk is for.

Curious as to what kind of pre-processing that file was performing, Emma cajoled a developer into letting her take a peek at the source code. There wasnt just one .awk script pre-processing the C++ code.

There were 107.

If All You Have Is A Hammer&

Danny, Emma asked over lunch one day, dont you think we rely too much on AWK for our build process?

AWK is our build process, he replied. Its like mortar, joining our bricks of C++ code. At least thats how Rupert describes it. Rupert was the chief code architect, and the one who first wrote BerkTechs code decades ago.

But you dont need AWK scripts for almost anything. Compilers can give you much more nuanced syntax errors and lexical analysis than ad-hoc scripts can.

Yeah, but its Ruperts baby. Rupert wrote the app in AWK first, using a branch of one of the old Unix-based interpreters. Later he rewrote parts of it in C++ for better performance. Hes never wanted to let go of AWK. He wont even run the compiler from the command line. When I say everything has to be done through AWK, I mean everything.

Time Capsule

Soon after, Emma met Rupert for the first time. His office was a perfectly preserved time capsule from 1983. Books older than Emma sat on a shelf, arranged by subject, and surprisingly dust-free. Rupert seemed like he had been preserved in the time capsule, too, with a tight collared polo and polyester slacks.

Danny sent me, Emma said. Weve noticed a lot of multi-byte encoding issues come up lately.

Multi-byte? Rupert said. Our developers should just use regular ASCII.

But that wont work for localization. Our Russian translators give us our localization files in Unicode, which uses multi-byte characters for the Cyrillic alphabet. The problem is our version of AWK. It wasnt designed for multi-byte encodings.

AWK can handle Unicode, Rupert said, dismissing Emma with a wave. It can handle anything.

Mutiny

Soon, development stalled on the localization project because of the multi-byte encoding issue, and deadlines were missed. With the top brass breathing down his neck, Rupert called an all-staff meeting at a fast food joint down the street to discuss the issue.

I know what youre thinking, Rupert started, But were not ditching AWK.

Danny spoke first. Theres no other way, he said. There are dozens, hundreds of scripting tools we can use. We can just hand off the localized strings to another tool, and AWK wont even have to touch it.

Not going to happen. Rupert crossed his arms.

The installation process is taking too long! someone else added. We have to install our own version of AWK on every computer the application runs on!

AWK is not a resource hog, Rupert said, adamant. Its no big deal.

The complaints raged for an hour. Finally, Rupert said, This is a waste of time. Were not ditching AWK, and were not bringing in another toolset. Ill fix the encoding issue myself.

&Everything Looks Like A Nail

Ruperts localization code arrived so late, Emma was forced to work nights unit-testing all the new code. By and large, everything worked as Rupert had promised. The project shipped, and soon a thousand PCs in a corporate office in Moscow had Ruperts obscure version of AWK installed on them.

Danny was uneasy, as he told Emma over lunch following the release. You know those obfusgation coding contests? I tried looking at Ruperts localization code. Its more impenetrable than the samples Ive seen for those contests. If you find anything wrong, hes the only one who can fix it.

Emma remembered Ruperts perfectly-preserved office. If he can keep his code as clean as his office, maybe all of his AWK scripts will keep working for another ten years.

[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/awk-ward-error-checking


Метки:  

CodeSOD: Collated Performance

Среда, 09 Декабря 2015 г. 14:30 + в цитатник

Eliza had a co-worker who had a problem. There were users with names like Ren'e. Other users, using standard keyboards, wanted to search for Ren'e, but couldnt be bothered to figure out how to type that accent, so they just searched for Rene.

The co-worker came up with this solution:

SELECT * FROM table WHERE UPPER(trim(translate(first_name, ''E^E"E`EAE+^A`A"A'AC`U^U"U^O"O"I^IŸ'e^e"e`e^a`a"a'ac`u^u"u^u^o"o^i"i"y', 'EEEEEEAAAACUUUOOIIYeeeeaaaacuuuuooiiy'))) LIKE (translate('FIRSTNAMESEARCHSTRING%', ''E^E"E`EAE+^A`A"A'AC`U^U"U^O"O"I^IŸ'e^e"e`e^a`a"a'ac`u^u"u^u^o"o^i"i"y', 'EEEEEEAAAACUUUOOIIYeeeeaaaacuuuuooiiy')) AND UPPER(trim(translate(last_name, ''E^E"E`EAE+^A`A"A'AC`U^U"U^O"O"I^IŸ'e^e"e`e^a`a"a'ac`u^u"u^u^o"o^i"i"y', 'EEEEEEAAAACUUUOOIIYeeeeaaaacuuuuooiiy'))) LIKE (translate('LASTNAMESEARCHSTRING%', ''E^E"E`EAE+^A`A"A'AC`U^U"U^O"O"I^IŸ'e^e"e`e^a`a"a'ac`u^u"u^u^o"o^i"i"y', 'EEEEEEAAAACUUUOOIIYeeeeaaaacuuuuooiiy'))

Eliza noticed it because this query was extremely slow- and no surprise. translate is unavoidably a character by character operation. It was taking 30 seconds to search their database with a nine character last name that didnt even contain any of the replaced characters. And of course, in most collations and character sets, 'E and upper(''e') are going to be the same character, making half the replacements completely unnecessary.

Speaking of collations, theyre a tool thats been standardized to make this really complicated problem of determining which characters are the same, or what order is alphabetical easy for programmers to solve. Every RDBMS supports them, and by specifying a collation. You can set the collation either on the table, the column, the individual query youre running against, or for the session of the query, using the standard SQL command COLLATE.

Eliza added some code to issue a COLLATE utf8_general_ci; command before running the query, removed the translates, and watched the query execute in 1/30th of a second, instead of 30 seconds.

[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/collated-performance


Метки:  

Announcements: Puppet Labs Sponsors 2016 and Launches a New Tool!

Вторник, 08 Декабря 2015 г. 18:00 + в цитатник

Here at TDWTF, were happy to announce that Puppet Labs have renewed their sponsorship of TDWTF.

DevOps and infrastructure automation are at that critical cusp, where everyones talking about the buzzword, and everyone knows that its important, but most people dont know exactly what it means to do DevOps. The tools we use to build infrastructure and deploy applications are changing fast, and the complexity is increasing: and complexity means more opportunities for WTFs.


Puppet Enterprise banner

We dont get a lot of application deployment stories submitted by our readers, which honestly surprises me. Application deployment is hard, and Ive seen it get screwed up in a number of ways (I once supported an application that pushed all of its logic into the database layer because the deployment procedures for that environment were more lax than on the web environment!). Tools like Puppet streamline, improve and automate deployments.

Thats where Puppet Application Orchestration comes into play. Its an application deployment tool that integrates with all of the automation Puppet already offers. It will be part of Puppet Enterprise 2015.3.

Too many organizations still have manual application deployment processes that are slow and error prone (Ive also seen just copy the compiled DLL into a network share that everybodys client app points to deployments). Puppet Application Orchestration puts everything together, extending its existing concept of nodes and adding your applications as resources, which gives Puppet all the context it needs to manage those services.

Even the most trivial data-driven application depends on a complex pile of underlying infrastructure (NTP, DNS, gateways and firewalls) and services (your database, your application and web servers, the load balancer), plus the application code itself. Changes anywhere in that stack have to be controlled, they have to happen in a very specific sequence, and we need to be able to test these changes. Puppet can manage and automate the entire stack, which gives you everything you need.

Thanks again to Puppet for sponsoring our site, and helping us bring more WTFs to you. You can learn more about Puppet by signing up for their Puppet Enterprise 2015.3 Webinar, watching their CEO Luke Kanies PuppetConf Keynote, and staying up to date on Puppet Application Orchestration news

[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/puppet-labs-sponsors-2016-and-launches-a-new-tool


Метки:  

Safe-ty First

Вторник, 08 Декабря 2015 г. 14:30 + в цитатник

Connor was a Highly-Paid Consultant who dealt with data security and audits, making sure companies secrets were irretrievable by enemies, competitors, and unauthorized employees alike.

He got an assignment to work with GrocerSoft, a mid-sized company which developed software mostly used by small, independent grocery stores across the nation. Theyd just picked up a new client, a chain of medium-sized grocery stores with a paranoid board of directors who imagined all sorts of competitors trying to steal their Top Secret grocery inventory suppliers. As part of the new agreement, GrocerSofts sales team had promised annual security audits of GrocerSofts data.

Australian Made CMI H2D Home Safe

Connor arrived on-location at the GrocerSoft National Headquarters in Des Moines, Iowa one snowy winter afternoon. The doors were unlocked and no one was there to greet him. Being a security auditor, he decided to wander around for a bit. After a half hour, someone finally asked him if he was lost, and directed him to his contacts office.

His contact was a middle-aged man named Toby who worked as the CTO of GrocerSoft. Toby had worked there for decades, since well before GrocerSoft got big, and had never had another job in his life. He was also, as Connor would discover, quite clueless for someone with the title of Chief Technology Officer.

Toby liked to talk. A lot. About everything. Toby took him on a grand tour of the office, showing him every irrelevant nook and cranny. This, you see, Toby would say while pointing, was our first vending machine. We got our first $100K contract in 1982 and got this installed to celebrate. You know youve finally made it big when Pepsi brings pop to you. He laughed loudly as if that was the funniest joke hed ever made in his life. It doesnt work anymore, of course, but we keep it around as a reminder. Sometimes the new guys will try and put quarters in there! Then Toby leaned in and conspiratorially wrapped an arm around Connors shoulder. We tell em that helps keep the bottom line up!

Connor silently rolled his eyes and suffered through the tour as Toby continued on and on, showing him the Sacred Coffee-Stained Office Chair of Conference Room 4 that some Hollywood technical consultant had spilled his coffee on while gathering information for a grocery store shootout in a blockbuster action film. Next was the Donut Box of Miracles which had been left in the founders office and discovered fourteen years after his death, then plastic-wrapped and put on display for all to see. Not to mention the Plush Doll of Excellence, a stuffed alien awarded by a client in 1997 after GrocerSoft completed a trainwreck 14-month-long website development for them.

Eventually they got to business. Okay, Connor, like we told you earlier our new client, who we cant name because of their NDA, needs to know our backups of their data are safe. Toby lead him to the corner of an unused office and showed him a fireproof safe. All the datatapes are in that safe. It can only be opened by a web page that only works from my computer. Its locked down by the IT address and MAP port. And, he pointed his finger up in a Eureka gesture, it only works in Inter-Network Explorer, too! They say no one uses that anymore and all the hackers use Google Crohns, so thats blocked. Real, real secure. He leaned in and winked. They built these specifically for the NSA to hold all the battle plans for capturing Saddam Bin Laden. Totally unbreakable! Anyways, I gotta go, going to Hawaii with the wife for the week and the plane leaves in a couple hours. Have fun trying to crack that safe!

And with a wink and a laugh, Toby stormed out, leaving Connor to do his audit.

Connor returned the next morning to begin his audit. A visual examination of the safe showed no physical way for him to get in without destroying it, so he noted the make and model and set up for some Internet research. It was a DigiSafe 9000, a LAN-connected fireproof safe with a built-in web server on port 4567 that could be controlled by any PC or smartphone.

Connor nmapd the network and poked the only host with an open port 4567, but was greeted with a security error page. Your system is not authorized to access this device! A report has been filed and may be used by the owners of this device to press charges!

He chuckled lightly and decided to visit Tobys office next, to see if he could find a MAC and IP address to spoof on his laptop.

He walked into Tobys office, a spacious corner office on the top floor of the five-story building. It was open and the receptionist didnt even look up as he waltzed into the CTOs office.

He sat down at the desk. It was piled high with paperwork, folders, and notebooks. The darkened monitor was plastered with dozens of sticky notes.

He noticed the small workstation was on and pressed the spacebar. The screen instantly lit up and he was greeted by an unlocked Windows session! Connor grunted in disgust. At least a couple dozen applications were already open, including Internet Explorer, which he guessed was Tobys previously-mentioned Inter-Network Explorer.

Probably fifty tabs were open. He started clicking through them, and, not surprisingly, found the DigiSafe 9000 login page was there. It had a simple login prompt with a note that the default password was 00000000 and should be changed after the first login for security reasons.

Connor eyed all the sticky notes. He saw private email passwords, shopping lists from 2011, phone numbers for women with names like Candy and Bunny, and a reminder to buy tickets for Attack of the Clones ahead of time.

And one labeled New Client Safe: 00000000

He punched in eight zeros to the login prompt and hit enter. After churning for several seconds, it showed him a simple control page with no styling. He clicked Unlock and after several more seconds the site showed an alert box stating The DigiSafe 9000 has been unlocked and opened. It will re-lock when you close the door.

Ugh, he groaned as he sat up from the chair and headed down to the empty office with the safe. Sure enough, the safe door was wide open and inside sat a pile of writeable DVDs and several USB hard drives.

Weeks later, Toby called up Connors employer to complain about the audit results. He seemed to think Connors methods were unfair because real hackers dont read passwords from peoples notes! Toby didnt care though. His employer got paid, he got paid, and GrocerSofts new client decided to store their Top Secret Supplier List with another vendor.

[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/safe-ty-first


Метки:  

Поиск сообщений в rss_thedaily_wtf
Страницы: 124 ... 32 31 [30] 29 28 ..
.. 1 Календарь