Archive for July, 2007

How to code properly: A revision control tip

Tuesday, July 31st, 2007

One of a developers best tools is his revision control system. Be it the crufty old standby CVS or Subversion, the darling of the hipster Rails community, or a wacky fringe “I hope you paid attention in school. And majored in math. And got an advanced degree in it” system like Darcs, it can be your best friend, saving you time and again from almost certain inconvenience. Getting the most out of your revision control system can be difficult, but it’s a skill worth mastering. Today I’m going to share something out of my personal bag of tricks that I think developers everywhere can benefit from.

The idea is relatively simple. If you have code that you aren’t using any more, delete it. If it happens that you need it again, get it out of the revision control system. Simple as that.

Compare the following sample bits of code:

 public void foo( /* String filename */ )  
 // throws CannotMakeItWorkException
 {
   // try {
   //   if(null != filename) {
   //     FileWriter fw = new FileWriter(filename);
   //     String buffer = "Hello World";
   //     fw.write(buffer, 0, buffer.length());
   //   } else {
   System.out.println("Hello World\n");
   //   }
   // } catch(IOException ioe) {
   //   throw new CannotMakeItWorkException("*shrug*", ioe);
   // }
 }

and

 public void foo() {
   System.out.println("Hello World");
 }

Indeed, both functions do the same thing. One is relatively straight forward. The other could stand some pruning. Is it worth knowing that foo() once took the name of an output file as an argument and wrote “Hello World” to that file when the argument was non-null? Maybe. Does keeping that information around in the soruce make foo() an absolute pain to read? Without question.

The grand thing about revision control systems is that if it turns out that you in fact do need foo()’s advanced file writing capabilities, you could without too much difficulty pull an old version out and use its code.

So remember that if you’re using a revision control system — and you had better be — that you can go ahead and delete dead code. Your coworkers will thank you for it.

Happy Coding!

Pasadena loves cycling. No, wait: it doesn’t!

Tuesday, July 31st, 2007

The route for the 2008 Tour of California was released a few days back. Pasadena was lucky enough to score the final stage – a road race from Santa Clarita to Pasadena, concluding with a circuit race in Pasadena. Cycling isn’t a really popular sport in the US, but Pasadena is sure to rake in considerable cash when fans in the states come to see one of only two Hors categorie events in the US. (The Tour de Georgia is the other one.)

Of course, Pasadena doesn’t always love the cyclists. From the July 30th City Council Agenda:

(1) PELATON BICYCLISTS – ROSE BOWL

Recommendation of Rose Bowl Operating Company: It is recommended that the City Council approve and direct the City Attorney’s Office to prepare a City ordinance to prohibit bicyclists from riding more than two abreast on any public street in the City other than pursuant to a City permit issued for an event or activity, including the area around the Rose Bowl.

The staff report pretty well comes right out and says “we don’t like those people who ride at the Rose Bowl.” Which seems odd, as those are Pasadena’s hard-core bike racing fans and the city is poised to rake it in from a bike race.

I can understand where the city is coming from, though. From what I’ve heard, the Rose Bowl ride is pretty intense. I’ve heard several horror stories about people just trying to get across the parking lot and almost being run down by speeding cyclists. Is banning it (which banning riding in a peleton may or may not do) the right way to solve the problem, though? These are “50-75 people” getting geeked about a sport. They’re not selling drugs or stealing cars. They’re riding bikes. In our generally obese and out of shape society, you would think that Pasadena would be peeing itself with glee over the public health benefits of a few dozen people getting out and exercising on a regular basis. Especially with a major race coming to town, potentially getting more people in to the sport.

I say deal with the cyclists the same way you deal with skateboarders. They’re a damn nuisance at the mall, but it’s absolutely great that kids are out skating instead of at home playing Halo, so you build them skate parks. Maybe the Rose Bowl riders put some people out, but banning them isn’t a good answer, especially when what they’re doing — getting some exercise, being in the outdoors, being social — is something that more people really should be doing. Figure out a better way for them to do their thing and everybody wins.

As an aside, if I could make one note to cyclists in the SGV: Could you at least try to obey traffic signals and signs? I would say that nothing gives cycling a black eye more than riders breezing through stop signs and lights, making cars that have the right of way slam on their breaks.

Help me find a new bank – Wells Fargo sucks

Monday, July 30th, 2007

I need a new bank. Wells Fargo has committed unforgivable sins of customer service, so I’ll be switching within the next week. Does anybody really like their bank? I’m looking for a pretty vanilla checking account with a branch that I can walk in to. (Because I like walking in to the branch.)

The story started about three weeks ago when I ordered new checks. I had changed the address on the account some months ago and asked twice to confirm the address both on the account and on the checks. The current address is on the checks, and we’re sending them to your current address. Wells Fargo sent the checks to my old address, anyway. Thanks, guys. You’re great.

So now there’s a box of my checks sitting god knows where in Temple City. Wells Fargo graciously offered to put a 60 day stop payment on the whole box — an offer I took them up on — but after that: nada. Nothing they could do, the banker told me. They offered to switch me over to a new account, but that would mean that I would have to fiddle with my direct deposit and with the external accounts I have drafting directly out of my checking account. If I have to go to all of that trouble, why wouldn’t I just move to a bank that doesn’t send my checks to the wrong address?

The best part? At one point the banker tried to bust my chops for waiting as long as I did to ask about the checks. Hello? Would we be having this conversation in the first place if you didn’t send my checks to the wrong place?

For all you banks playing along at home, here’s what you’re supposed to do in a situation like this:

  • Apologize. Up front. Don’t demand that the customer remember the name of the teller they spoke to before you admit that you screwed up.
  • Put a permanent stop payment on the checks in question.
  • Next day — and by next day, I don’t mean “third day” — a new box of checks to the customer in question.
  • Apologize again. Seriously.
  • Give the customer a tracking number for their checks. “It’ll get there in seven to 10 business days. Trust me.” doesn’t cut it.

So while I will graciously accept Wells Fargo’s tree-freaking-day air checks (The banker told me “next day” not once but twice while she was trying to make up for what she admitted to be their mistake. Thanks again!), I’m not staying with them any longer than I absolutely have to. If you love your bank, I’d love to hear why.

Fox Sports is awesome

Thursday, July 26th, 2007

Here’s the lead from today’s “Dime daily blog” on Fox Sports:

Last night the Dime crew was up at Rucker Park for something unprecedented and pretty cool: 2K Sports’ motion capture session for NBA 2K8 on the world famous playground court with Andre Iguodala, Gerald Wallace, Rudy BLEEP and 2K8 cover guy Chris Paul. Chris Bosh was also in the house, but he was just there to kick it …

And here’s the same thing once you use the site’s “censor settings” to allow naughty words.

Last night the Dime crew was up at Rucker Park for something unprecedented and pretty cool: 2K Sports’ motion capture session for NBA 2K8 on the world famous playground court with Andre Iguodala, Gerald Wallace, Rudy Gay and 2K8 cover guy Chris Paul. Chris Bosh was also in the house, but he was just there to kick it …

Rudy Gay was one of the best rookies last year. Too bad his name is apparently inappropriate. I wonder if he can get the name on his jersey changed to BLEEP.

Why the US shouldn’t have formal relations with Iran

Wednesday, July 25th, 2007

Or why they should! This can’t be true, but if it is, it’s the best thing to happen ever.

From a batshit crazy story about SQUIRRELS INVADING IRAN on the Washington post:

“A few weeks ago, 14 squirrels equipped with espionage systems of foreign intelligence services were captured by [Iranian] intelligence forces along the country’s borders. These trained squirrels, each of which weighed just over 700 grams, were released on the borders of the country for intelligence and espionage purposes. According to the announcement made by Iranian intelligence officials, alert police officials caught these squirrels before they could carry out any task.

“Fixing GPS devices, bugging instruments and advanced cameras in the bodies of trained animals like squirrels, mice, hamsters, etc, are among modern methods of collecting intelligence. Given the fast speed and the special physical features of these animals, they provide special capabilities for spying operations. Once the animals return to their place of origin, the intelligence gathered by them is then offloaded. . . .”

What would you do if somebody you had on a “Rogue nations” list started (supposedly) saying stuff like this? You’d take them out to a bar and get them drunk, that’s what you’d do! Because seriously, if they can come up with this sort of stuff sober, imagine what they can do after a few rounds. Maybe surreptitiously put some ocelot fur on your jacket before you meet up with them just to see if you can totally freak them out. You could even make a game out of it. For every genus they accuse of espionage, you drink. Just make sure that you’re taking a cab home if you’re out with Iran.

I don’t know how much international diplomacy actually takes place in a pub, but if this story is true much, much more of it should.

The United States *owns* the Tour de France

Wednesday, July 25th, 2007

As of today, the US Discovery Channel cycling team has riders in first and third — Contador and Leipheimer respectively — in the GC at the Tour de France. They lead the team race by nearly 17 minutes. Contador will hold rights to both the white (by 13:31 over Soler) and yellow (by 1:53 over Evans) jerseys tomorrow morning. It is hard to say that the US is not the dominant force in professional cycling.

Of course, Contador was back by over three minutes from Rasmussen before his team kicked him out for missing an off-season drug test and lying about his summer whereabouts. Oh, and Astana was winning the team race by a couple of minutes before their top rider was busted for doping and the whole team pulled out of the race.

Still, We’re so #1 it’s not even funny.

De-fault! De-fault! De-fault!

USA! USA! USA!

The Rasmussen news really is a shame, as he’s been having a spectacular race. His stage 14 finish with Contador was amazing. I haven’t even seen today’s stage; supposedly he pulls 25 seconds off the other leaders in the last km. I don’t feel so bad about Vinokourov, as he was busted for doping during the race. (Why this is somehow different than skipping out on off-season testing I can not say. Seems like it shouldn’t be.) The whole Astana team quitting, on the other hand, seems odd. I guess the teams are serious about some of their stated “zero tolerance” policies. (Update: Astana was asked to leave by the tour. Oh well.)

One thing I do wonder about: is drug testing technology today really that much better than it was two, three or four years ago? From everything I’ve read, Lance Armstrong was tested before and after every single stage for the last few years he rode in the tour, yet he never had a positive result. If he actually was doping, why was he never discovered while Landis and Vinokourov and so many others were. (The simple explanation, of course, is that he wasn’t doping, which I buy based on what I’ve read about his training and the teams that were put in place around him. But that leaves out all sorts of fun conspiracy theories, so forget that.)

Oddly enough, I still find the Tour compelling even as so many riders get sacked for the EPO or whatever it is they’re mixing in to their coffee in the morning. The races are all against the rest of the field, so even if you kick out the supposedly juiced-up super-riders, you’re still going to have good, competitive races between everybody else. Contador and Soler alone would have made this year’s tour for me. (Just so long as they don’t get kicked out as well!)

I am a published photographer

Saturday, July 21st, 2007

Well, sort of. The Schmap web travel guide used a photo I took for their San Diego Art & Entertainment page. Which, you know: cool.

This is one of the neater uses of Flickr I’ve seen. Seems like if you’re just putting low-res pictures up on the web you can get away with a snapshots taken by some guy two beers in to a football game. Schmap emailed a bunch of people they found on Flickr and asked if they were cool with being included in the guide. I was, so there I am.

White on black or black on white?

Wednesday, July 18th, 2007

Whenever I use the web or write email, my working environment displays in black on white and I’m just fine with that. When I edit text, black on white just seems wrong and I always switch things around to be white on black. This never struck me as odd until today. Does anybody else think it’s odd that one color scheme would make perfect sense in one context but come off as very wrong in another rather similar context? Or is it just me?

Fair Dice (for Settlers of Catan and other games using dice)

Sunday, July 8th, 2007

I love games, but I hate dice. They vex me so. Especially while playing Settlers of Catan. If you’re twice as likely to roll a seven as you are a four, then why in the hell has four come up five turns out of the last six? Etc etc. You get the idea.

Inspired by Erich’s dice-by-cards Catan variant (and also by not having a spare deck of playing cards, and also by having recently taken pictures of a six-sided die) I put together Fair Dice. It’s a goofy little JavaScript application that will roll all thirty-six combinations of two dice once in random order. When it’s done, it will do it again.

Now, is this sort of thing useful? Who knows. Probably half the fun of a game like Settlers is watching people fume when threes and elevens come up over and over and over again while those sixes and eights that they so wisely choose at the beginning of the game go fallow. So you know me: I like to destroy fun.

A random non-gaming aside: How do people write web pages without FireBug? I looked briefly at making sure that this works correctly on IE and Safari, and I couldn’t tell what in the world was going on. For the longest time the page didn’t do anything because apparently Safari and IE (IE 6, at least) don’t understand the “const” keyword in JavaScript. Infuriating! Anyway, if you’re having to contend with JavaScript, I can’t recommend FireBug quite enough.

(Fair Dice)

MPL “family read-along” night

Friday, July 6th, 2007

My most infamous middle school moment came while we were reading Shakespeare. Richard III, 8th grade. I didn’t get in to it. It was just so dreary and boring. Every day we read it felt like somebody was dropping an anvil on my balls. From an airplane. Or maybe from space. At the end of the play, our teacher asked us what I though. “Shakespeare should be shot,” I told her. If she ever wrote a book, she promised me, I’d be in it for saying that.

When I came home today, I found out that The Kid had drawn “family read-along” as his next book type in the MPL summer reading program. Stephanie and the kid were pitching me really hard for reading A Midsummer Night’s Dream, which, given my previous experience, I was skeptical of.

Stephanie has been telling us for years now how much fun reading Shakespeare aloud is. I trust her (and I was outvoted), so we gave it a shot.

It was great!

Getting in to the characters, doing the voices, and periodically getting quick story or history explainer from somebody who studied as much was a ton of fun. We read the first act tonight. Stephanie read Hippolyta, The Kid read Egeus and I read Theseus, and we divvied the rest of the parts up as we got to them. It was tremendous fun! It’s astounding to me that something I hated quite so much growing up quite be quite so much fun with the proper crowd and the proper attitude. I can’t wait to read the other four acts.

My only question at this point: is doing Bottom as William Shatner over the top? Perhaps so.