How Computers Get to Sleep at Night

There are two good ways to iterate over an array in PHP.  One is the classic syntax found in some form in all modern procedural languages:

for ($i = 0; $i < count($colleges); $i++) { ... }

There’s also this straightforward variant, also found in a lot of languages now:

foreach ($colleges as $college) { ... }

Given these two loops, under no circumstances is the following acceptable:

$i = 0;
while($i != (count($colleges) - 1)) { ... $i++; ... }

Besides being unnecessarily verbose, this will also never terminate if the array is empty.  Eventually the server will get bored of counting up one integer at a time and forcibly kill the script, but that just means users will have to call me to fix it.

In conclusion, please don’t let student developers touch any more of my production code.

We the People

For reasons that I shall leave ambiguous, I was perusing the (current) Boston Municipal Code yesterday. There’s some great stuff in there. For example, it’s illegal to manufacture or sell a mercury thermometer in the city of Boston, except by prescription.

Then there’s this restriction:

Whoever sells, or distributes, or imports, or loans, or possesses with the intent to sell … a book, pamphlet, ballad, printed paper, phonographic record, print, picture, figure, image, or description which depicts or describes … patently offensive representations or descriptions of ultimate sexual acts, normal or perverted, actual or simulated … shall be subject to a fine of fifty ($50.00) dollars….

Then there’s this regulation for street-railway cars (emphasis mine):

No person having control of the speed of a street-railway car passing in a street shall fail to keep a vigilant watch for all teams, carriages, and persons, especially children, nor shall such person fail to strike a bell several times in quick succession on approaching any team, carriage, or person, and no person shall, after such striking of a bell, delay or hinder the passage of the car.

That’s a point to me: my city built its subway and streetcars before anybody dreamed of having automobiles… and it’s still there today.

Thar be Dragons Here

We’ve started creating a lot of video tutorials at work, and we thought speech transcription software like MacSpeech Dictate (built on the supposedly phenomenal Dragon NaturallySpeaking engine) would help us prepare scripts.

I gave the software three long samples of my voice, and then imported a collection of lengthy documents it supposedly used to analyze my writing style.  In the end, I even slowed down my speaking to probably around 60 or 70 words per minute – a speed an ordinary typist could probably keep up with just fine, and an advanced typist would find boring.

I tried reading this simple test sentence:

This video is a tutorial for web developers who want to create new applications in our web space, or install applications they’ve downloaded from the web.

This is what came out – I swear I’m not making this up:

This is a program of us look like he’s our lips excreting around each or install outrage at a gallop away.

A coworker swears Dragon is both reliable and accurate, though when he tried to demonstrate that on his own computer he got no better results than I did.  I’m underwhelmed.

Legalese, as Outlined Herein Forthwith

After my building changed owners, they started using a different lease.  I read through it this weekend, and my favorite representative clause really has to be this one:

1.3.  The pet will be an ordinary house pet.  Ordinary house pets include cats.

That’s just an amazingly gratuitous use of legal sentence constructs to say, in the end, “You can have a cat.”

I also haven’t figured out this one, though Google suggests it’s a standard clause in many leases:

TIME IS OF THE ESSENCE.  Time is of the essence of this Lease and each and all of its provisions.

The way that phrase is used in casual conversation, I feel like I’m being told if I don’t sign the lease quickly someone will die.

Here a Yell, There a Yell

The jury is still out on most of the new students living in my building, but I’m already impressed by the guy who was on the elevator with his friend when I stepped on this afternoon.  He was scrolling through contacts on his phone, reading them aloud.

David… Diana… Danny… Ellen… Erica!  That was her name.  Erica.

The conversation that followed when he dialed Ms. Erica’s newfound number made clear (if it weren’t already) that he’d met her the night before, punched her number into his phone for safekeeping, and then forgot who she was until the next day.  This relationship is destined for greatness.

Now we just have to get the police in to teach the kids above me that it is inappropriate to carry on conversations from their balcony to persons on another balcony at 11:00 at night.  Last year’s students took one or two weeks to learn that.  This year’s seem to be collectively less intelligent.

What’s Mine is Yours… Apparently

Dear Boston Globe,

You really need to stop delivering my newspaper to my neighbors.  It was funny for a while when nobody was living in that apartment, but now some students have moved in.  It’s only a matter of time before one of them wakes up early (perhaps for an exam) and thinks she’s gotten a free newspaper.

If you’d like to also leave them a free newspaper after delivering mine, I support that.  College students should be well informed.  However, that is not my primary motivation for taking out a subscription.  I want to read the paper myself on the train in the morning.

One helpful trick is to look at the number on the apartment door before leaving the paper.  If it’s identical to the number on the subscription list, the paper can go there.  If it’s different – even by just one or two digits – other people probably live there who didn’t subscribe, and you should keep looking.  In my case, you’ll find the correct apartment is literally across the hall, and it will require no additional work to find.

Thank you for your cooperation in this matter,
Someone who doesn’t live with his college student neighbors

Do Nothing 3: Do Nothing with a Vengeance

Stephen Colbert interviewed Congressman Lynn Westmoreland on the Colbert Report.

Westmoreland is known best for cosponsoring bills to display the Ten Commandments in the House and Senate, and to allow them to be displayed in courtrooms.  Asked to name them in the interview he gets (and I quote), “don’t murder, don’t lie, don’t steal,” before giving up.

Some would criticize him.  I say: that’s why he wanted them on display in the first place!  How else are they supposed to remember all that cruft about not coveting your neighbor’s wife and honoring your parents?

That aside, this was my favorite exchange:

Colbert:  This has been called a “Do Nothing Congress.”  Is it safe to say you’re the do nothingest?

Westmoreland: Well, there’s one other do nothinger.  I don’t know who that is, but they’re a democrat.  So there’s one democrat do nothinger, one republican.

Colbert: Are you even a congressman if you haven’t actually introduced a law?

Westmoreland: I got sworn in with everybody else…

Besides, one doesn’t need to take action to have some brilliant ideas:

Colbert: What can we get rid of to balance the budget?

Westmoreland: Department of Education.

He has a point.  If we didn’t keep trying so hard to educate students, fewer of them would grow up to be responsible members of society, and it would be so much easier to get nothing done!

PoaT+xkcd+www+blog = Fun!

Randall Munroe, creator of xkcd, blogged about the infamous Plane on a Treadmill problem from the perspective of how people interpret the problem differently, and how that leads to chaos in Internet “discussions.”  I enjoy the summary at the end:

So, people who go with interpretation #3 notice immediately that the plane cannot move and keep trying to condescendingly explain to the #2 crowd that nothing they say changes the basic facts of the problem. The #2 crowd is busy explaining to the #3 crowd that planes aren’t driven by their wheels. Of course, this being the internet, there’s also a #4 crowd loudly arguing that even if the plane was able to move, it couldn’t have been what hit the Pentagon.

All in all, it’s a lovely recipe for an internet argument, and it’s been had too many times. So let’s see if we can avoid that. I suggest posting stories about something that happened to you recently, and post nice things about other peoples’ stories. If you’re desperate to tell me that I’m wrong on the internet, don’t bother. I’ve snuck onto the plane into first class with the #5 crowd and we’re busy finding out how many cocktails they’ll serve while we’re waiting for the treadmill to start. God help us if, after the fourth round of drinks, someone brings up the two envelopes paradox.

It somehow reminds me of a great Simpsons quote, as a group of pirates are about to bury some treasure:

Captain, what if, instead of burying the treasure, we use it to buy things? You know, things we like?

I Knew I Should’ve Unplugged It First

I’ve bought (over time) five Western Digital “My Book” drives.  Two of them have failed – one the moment I plugged it in, the other just recently.

Those of you who might trust me to make important decisions should note that I bought one of the drives after the two failures.  Einstein famously defined insanity as doing the same thing repeatedly and expecting different results.  Make of that what you will.

The recent failure was of a drive holding many of my collected television shows – West Wing, Studio 60 on the Sunset Strip, Sports Night, Gilmore Girls, Scrubs, Friends, Star Trek TNG, DS9, Monk, Grey’s Anatomy, Psych… and probably others I’ve forgotten.  Having them all at my fingertips was a great triumph in personal computing for me.  (And this is just one drive in a bank of 3 TB of storage in front of me at the moment.  Anyone else remember when we used 1.44 MB floppies?)

Of course, all my content is backed up.  All of it.  Except this drive.  This drive contains mostly videos ripped from DVDs, which I of course own (shame on you for thinking I pirated content!), so I reasoned I could always encode them again if the drive failed.  Faced with that very possibility, though, I’ve realized something important: I really don’t want to!  It’s well over a thousand hours of video, and I don’t have the patience to encode it all again.

I developed a theory.  Perhaps the physical drive is intact, but the USB connection is faulty.  The Internet backs me up on this.  It also believes we never landed on the moon, but we’ll focus on the hard drive for the moment.

To prove this theory (and reclaim my data), I began disassembling the case, per Scott Cramer’s description.  It went well, until step two.  This requires depressing a catch at the top and bottom of the drive while pulling the two halves of the case apart.  I performed a quick inventory of my hands, and found two fewer than required for this task.

The end result of all this had me sitting at my desk this beautiful summer evening with a hard drive in front of me, jamming a screw driver into one side and a steel letter opener into the other, and thinking, offhandedly, “So this is how I’m going to die.”