Thursday 28 February 2013

Coded Smorgasbord: A Simple Misunderstanding

Coded Smorgasbord: A Simple Misunderstanding:

Some terrible code arises out of terrible business rules which no one truly understands. Some terrible code arises from laziness, sloppiness, or the need to just get it done now.


But there’s a special class of awful code that arises for a complete misunderstanding of how the language is supposed
to work. That gives us things like the loop Rasmus found:


$i = 0;
for (;;) {
    $i++;
    echo "<input type="text" name="row[]"><br />";
    if ($i >= 15) break;
}

Semaj inherited a code-base which uses this “pattern” everywhere:


try
{
   if (_staff == null)
       throw new NullReferenceException();
}
catch (NullReferenceException)
{
   _staff = _provider.GetStaff();
}

Who doesn't love using Exceptions to govern program flow?


Adam’s co-worker seems to misunderstand the purpose of an if statement:


if (dncrptList.Contains(destName))
{
   dId = SymmetricMethod.Decrypto(id);
}
else
{
   dId = SymmetricMethod.Decrypto(id);
}

Adam also points out that Decrypto would make an excellent name for a CS-themed super-villain.


And John found this one, which demonstrates PHP’s “flexibility”:


foreach ($category as $category) {
    /* do stuff */
}

The loop works just fine, but has the nasty side-effect of completely replacing the array with the last assignment to $category- the last element of the array. That wasn’t a problem until John later tried to add some features to the category listing and expected the array variable to still hold an array.

[Advertisement] Make your team a DevOps team with BuildMaster. Pairing an easy-to-use web UI with a free base platform, BuildMaster gets you started in minutes. See how Allrecipes.com and others use BuildMaster to automate their software delivery.

Monday 25 February 2013

A Spiral Phenomenon in the Himalayas

A Spiral Phenomenon in the Himalayas:


A Spiral Phenomenon in the Himalayas












Submitted by:
Unknown

Transforming Table WIN

Transforming Table WIN:















Submitted by:
Unknown

In the Lap of Tropical Luxury

WANT!

In the Lap of Tropical Luxury:


In the Lap of Tropical Luxury












Submitted by:
Unknown

Join the Army, See Middle Earth

Join the Army, See Middle Earth:


Join the Army, See Middle Earth











Submitted by:
Unknown

The LEGO "Arrested Development" Set is the Coolest Thing You'll See all Day!

The LEGO "Arrested Development" Set is the Coolest Thing You'll See all Day!:


The LEGO "Arrested Development" Set is the Coolest Thing You'll See all Day!












Submitted by:
Unknown (via I Watch Stuff)

Kids Outgrowing Your Old Camper?

Kids Outgrowing Your Old Camper?:


Kids Outgrowing Your Old Camper?












Submitted by:
DoctorTwo

Not Bad At All

Not Bad At All:


Not Bad At All












Submitted by:
Unknown

Tuesday 5 February 2013

The Sysadmin's PC

The Sysadmin's PC:
“Hey, can you give me a hand? This computer I built won’t boot.”

Alexander sighed, and went to see what Nicholas had done now.

Only a few weeks before, around the start of the year 2001, Alexander was full of hope and optimism for the new century. He and his co-workers called themselves the “AnyKey Men”: they fixed and built desktops, fed the printers, and showed the users how to find the “any key”. Alexander had a great IT manager, and some great co-workers, and was happy with his job.

Then his manager left. Alexander had been his right-hand man, and assumed he would be promoted. As much sense as promoting internally might have made, the job went to Nicholas.

Nicholas brought with him a raft of certifications purchased from a local training company. More important, he was the owner’s cousin. And more important than that: Nicholas’s mother assured everyone that he was very good with computers.

Nicholas believed his own hype, and came in the first day full of swagger. He didn’t understand what a command-line was, made a racially offensive “whooping” sound when Alexander mentioned Apache, and needed help finding the “any key”. Each time Alexander had to correct something or fix some mistake Nicholas had made, Nicholas hated him a little bit more. Alexander tried to explain to the owner that Nicholas wasn’t actually qualified, but simply got scolded for his “negative attitude” and his “sabotage” of his new boss.

And now, Nicholas was actively seeking out Alexander for help. He must have seriously screwed up this computer.

Alexander started by pushing the power button, just to see what happened. The fans spun up, but nothing else happened- no POST beeps, no blinkenlights, nothing. Alexander popped the side of the case, expecting to see something horrible and obviously wrong, but at a cursory glance, the only thing wrong was the sloppy cabling. He traced, disconnected and resat all of the key cables. The green LED on the mainboard lit up, indicating it got power.

That still didn’t fix anything. Alexander checked a few more obvious things, then reached in, past the rat’s nest of cables, to pull the heat sink from the CPU. It slid right off into his hand, because it wasn’t properly seated. There wasn’t a drop of thermal grease, either.

“You really need to put thermal grease on here.”

“I totally did,” Nicholas protested. “I used a bunch.”

Alexander ignored his obvious lie, and reached in to pull out the CPU
. It was a Socket-A style mount, which had a lever to release the chip. When Alexander pulled on the lever, it refused to budge. The CPU wobbled in the socket, something that the Socket-A mount was supposed to render impossible. It either was seated or it wasn’t.

Alexander put a little more force onto the lever, and after some unpleasant crackling, the socket slid open. The chip practically jumped out of the socket, overjoyed to be free of its restraints. A glob of thermal grease jumped out from beneath it. Nicholas hadn’t been lying.

Socket-A mounts, like most CPU mounts, were designed to allow a chip to enter one way. When the chip was oriented correctly, it would simply slide into the mount with no friction. Any other orientation would refuse to let the chip in. It was essentially fool-proof.

Everything is fool-proof until they invent a better fool. When the chip didn’t slide into place, Nicholas slathered an inch of lubricant on the pins and then jammed the chip into the socket like it was going into the backseat of a Volkswagen.

“Can you fix it?” Nicholas asked.

Alexander looked at the bottom of the chip. Pins were bent and a few were broken. By rights, the ceramic base should have given out with that kind of pressure, and it was only because fate loves idiots that the chip wasn’t broken into a pile of shiny pieces. “No.”

This wasn’t just any desktop that Nicholas had ruined. This particular computer was bound for the owner’s desk. Nicholas had proudly ordered the best parts available, and had spent weeks bragging about how awesome the computer would be.

The computer was broken, and Alexander was the last person to touch it. Nicholas cried to his cousin, who screamed at Alexander. Threats of unemployement flowed freely. Frustrated, Alexander returned to his desk and checked his email.

There was a note from his old boss. A new position had opened up, and he wanted Alexander to apply.


Monday 4 February 2013

Block Telemarketers and Robocalls for Good with the Raspberry Pi-Powered Banana Phone

Block Telemarketers and Robocalls for Good with the Raspberry Pi-Powered Banana Phone:




No one likes unsolicited and unwanted calls from telemarketers or robocalls from information-collecting bots, but putting a stop to them is troublesome enough that The FTC is offering $50,000 to anyone who can stop them. This DIY project, dubbed "The Banana Phone" for reasons you can see in the video, may very well qualify for the prize.
Here's how the banana phone works. When a robocaller or automated dialer calls you, the Banana Phone picks up, plays a song (in this case, it's Raffi's earworm we all know) and while the song plays, text-to-speech tells the caller to enter a four-digit passcode in order to be connected to the actual line they're calling. Automated dialers would give up at that point, but real humans would enter the number and get connected right away.
The Banana Phone cost around $100 to build, and uses entirely off-the-shelf products, including a Raspberry Pi and an Obihai phone-to-Ethernet adapter. Alex Ruiz, the man behind the project, explains and demos the setup in the video above. Alex has a landline and uses it to protect that, but we could imagine the system could be adapted for people who use a mobile phone or VoIP service primarily (although most of those services and smartphones have built-in tools to block unwanted calls anyway.)
He says it's worked pretty well so far, but it's obviously not a perfect solution to the telemarketer problem. For one, any human in a call center can listen to the instructions and enter the passcode to bypass it and get through to you—but considering most human call centers have automated dialers that only connect after registering someone picked up, it may be pretty effective there too. Of course, if everyone had one, marketing firms would find a way around it, but for the time being, it might be a fun DIY project and a decent way—albeit amusing to your friends and family—to protect your privacy.
The Banana Phone Project: The Evolution of Caller ID | YouTube via Hack-a-Day