Monday, November 30, 2009

Python: Adopting Perl's given and Smart Matching

Python doesn't have a switch statement. This makes it relatively unusual among modern languages, but it's not terribly shocking. It has never been entirely clear what the useful equivalent of C's very efficient and elegant switch should be in high-level languages. However, one useful signpost is Perl's late addition: given.

In Perl 5 (released around the dawn of Python) there was no switch equivalent. Many of the same hacks that are used in Python to work around this were suggested to Perl users. However, when crafting a spec for Perl 6, a switch statement was high on the list of user requests, so "given" was introduced. Later, as Perl 6 prototype implementation features were scrutinized for back-porting to Perl 5, given was selected as a useful bit of low-hanging fruit that didn't require massive changes to the language. In Perl 5.10, the given statement is now available with the use of a special pragma. Presumably, this pragma will be removed in future versions.

So, back to Python. Is given the right way to go? Perhaps. Given assumes a lower-level tool called smart-matching, and Python currently has no such mechanism. The introduction of smart-matching has the potential to be disruptive to the language if done poorly. Great care should therefore be taken, but a minimal approach should be acceptable.

(read on for the proposal...)

First Flight in Dragonblight

World of Warcraft is a beautiful game, but sometimes the grind-heavy aspects of the game make it easy to forget that. Today I took my Turbo-Charged Flying Machine for a spin for the first time (my engineer finally got around to making one), and I decided to Fraps up a movie of the experience. The music is by Celestial Aeon Project, from their albums Aeon 2 and Mind's Eye, both of which are distributed under a Creative Commons license at

Friday, November 13, 2009

Followup on Droid

As you know if you read this site, I got a Verizon/Google Droid to replace my iPhone last week. Having had a full week to play with it, here's my followup on my original take:

  • The keyboard is nowhere near as annoying as I thought. I am back to iPhone typing speed, and perhaps a bit faster.
  • The camera app is still annoying. It's hard to press the camera button long enough to get the app to come up without having it snap a shot immediately, and saving a photo will cause music to skip.
  • Initially I thought the lack of a sleep mode (for playing music when I go to bed) was going to annoy me, but as Apple says, there's an app for that.
  • Music management is more tolerable since I started using MediaMonkey, an iTunes-alike that handles just about any device. This also does smart playlists ala Apple, but the free version doesn't have that feature ($20 for the pay version).
  • Dropped WiFi connections are still a bit of a pain, but not as bad as I'd feared. The phone takes longer to recover than the iPhone, but it does so. Weak WiFi is actually more of an issue, especially for file transfers (e.g. app installation).
  • A week in, and I'm getting used to the combined messaging features, but popup would be a nice option.
  • I do like the Exchange integration for the iPhone better than for the Droid, but that's a relatively minor issue. They both work.

I still don't think the Droid is an iPhone killer, but then it doesn't have to be. There will always be a core loyal audience for the iPhone, and if this phone cured cancer, I don't think they'd give it up. On the other hand, the Droid is comparable on every level, and better in a few key areas such as navigation and openness.

If you have a Google Apps account (e.g. for work, school or a vanity domain), then you really should get an Android phone. It's capable of syncing from both your normal Google account and your Apps account for mail, calendar and contacts, which is pretty huge. Oddly, though, it won't do IM through Apps as far as I can tell.

USB Droid: Can't Connect?

When I first got my Motorola/Verizon/Google Droid phone, I thought it was broken because it wouldn't talk to my laptop. I tried plugging it in to multiple USB ports, resetting, searching for drivers, etc.

It turns out that it's really easy to get this working, and once you do, you'll understand something that's critical about your new phone: everything important shows up in the notice bar at the top of the screen.

When you plug the Droid in to a USB host like a laptop or desktop system, it brings up a notification (USB logo in the status bar). Place your finger off the screen, above this notice, and swipe directly down onto the screen. This will bring up the all-important notification menu. Here, you'll see things like "USB Connected" and various app installation notices if you've recently downloaded anything. Touch the USB notice now and it will bring up a dialog box that asks if you want to mount the SD card on your host computer. Press "Mount" and you'll have full access to the SD card from your system. When you're done, you can either repeat this process or just unplug the USB cable to force it to re-mount internally.

Tuesday, November 10, 2009

My Photos On the Web

Lemon Dessert Photo by Aaron Sherman (c) 2009, Licensed under CC-By-SA 3.0
I've always put my photography up on the Web under the Creative Commons licensing that allows others to use and distribute them as long as they give credit and allow others to do the same (the CC-By-SA license). Over time, I've seen my pictures used for more and more things that I'd never have dreamed. One church has used a panorama of mine for their banner and I've seen my images used for several news articles, such as the story of tequila being used to make diamonds.

For those who might want to use some of my images in the future, the best place to look is on my Picasa folders. One of these, Misc Photos, contains what I consider to be some of my best general work, though I have other sections for nature photography; specific events like the Tall Ships and Fireworks; and so on. You need only credit me and provide some way for people to find the original in order to use these images.

Sunday, November 8, 2009

Droid Replaces My iPhone

Friday, I went out and got a Droid to replace my iPhone (which I've handed down to someone else). My first impression is that its very nice, but for every iPhone annoyance that the Droid fixes, there's a new one to replace it.

Here are a few:
  • Keyboard is far too prone to multiple keypress
  • Camera is slow, and prone to blurry images
  • The iPhone had a sleep function (timed shutoff) that Droid lacks
  • Music management is horrible
  • Apple's smart playlists are clearly a killer feature
  • Recovery from a dropped wifi connection is not as graceful
  • No popup SMS/messaging notifications (brief scroll on top bar instead)
  • Google Voice / built-in messaging can be confusing (which one am I selecting?)
On the other hand, it has:
  • An open app store
  • Free turn-by-turn navigation with a fairly cheap car-mount
  • A keyboard at all (narrowly a win over none... narrowly)
  • Great email/SMS integration if you use gmail and Google Voice
  • Search by voice for nearly everything
  • "Back" button works across apps
Some things that I think would improve the experience:
  • Add a countdown timer that kills the browser and music player when it goes off
  • Make the music player automatically create playlists from directories on the SD
  • Add smart playlists (see my other post)
  • Build in some software guards against multiple keypress
  • Improve guessing with respect to poking at links on the Web browser (I often get the wrong link)
Overall, it's a great phone, but in some respects, it leaves me longing for my iPhone. I'm sure that over time it will become my favorite phone, but it's not a clear iPhone killer.

How To Use Smart Playlists In iTunes

Do you have an iPhone and many more Gigabytes of music you love than you can fit on it? Do you get frustrated over having to choose what to put on the phone? Here's a way to never compromise your collection while still carrying around only a trivial number of tunes:
  • Create a playlist for a kind of music you want to listen to. You can use one of the built-in smart playlists like "Highest Rated" or build your own (for example, I have a "Quiet" playlist of songs I like to go to sleep to)
  • Now create a new smart playlist and give it the rule: "Playlist", "is", and the playlist from above.
  • Select the checkbox next to "Limit to" enter "50" or "100" for the count and for "selected by" use "Least recently played".
  • Now when syncing your phone, go to the "Music" tab under the iPhone's entry in iTunes. Select the option to only place selected playlists on the phone, and select your new smart playlist.

Monday, November 2, 2009

Blackra1n, Cydia and SBSettings

I've just re-jailbroken my iPhone (mostly to fix a problem introduced by upgrading to 3.1 without first uninstalling the jailbreak - never do that), and I ran into an SBSettings problem. It installs fine, but once it's done installing, it doesn't do anything. I swipe across the top of the screen and nothing happens.

If you just used blackra1n to jailbreak, and SBSettings won't work for you, here's what you do (props to this forum for the fix):
  • Re-install Cydia from the blackra1n interface
  • Re-install dpkg (this may show up as "Debian Package Manager" or similar) from Cydia
  • Re-install SBSettings from Cydia
  • Re-boot the phone
This worked for me, and got my SBSettings install working flawlessly.