David Findlay

a man, a plan, a cake: nirvana

From iSight to Chumby with love

Since my wife got her Chumby, I've been reading up on ActionScript. It's not been a terribly amusing process, and I haven't had much time to devote to it, so I haven't gotten any further than a prototype recipe chumbifier widget so far.

Then the other day I was perusing the available widgets on chumby.com and came across, in the web-cams sections, a widget that will display and poll an arbitrary image given a URL. I thought it might be fun to make a self-spy cam, as it were, and have my MacBook upload the iSight camera image every few minutes while I was work. Then my ugly mug would show up on my wife's Chumby, between Chuck Norris Facts and the San Diego Zoo's panda cam.

My first thought was to use Automator for this task. It has iSight support, and Transmit has Automator support, so it should have been pretty easy to take the picture and upload it to one of my websites. But Automator apparently insists on doing the 3-2-1-beep/flash means of taking a picture, as in Photo Booth. Putting up with that every few minutes would be irritating to say the least. So I did a quick google and came across isightcapture. isightcapture is a command-line application that captures an image from your iSight camera and saves it to file. It was a simple matter to put together a shell script to capture the image and then use scp to upload it to my web host (I already had SSH public key authentication configured on the host, so I didn't need to worry about having to enter a password).

This is pretty good; we have our image automatically taken and uploaded, ending up with something like this:

Raw

Tweaking the Image
So far, so good; but there is room for improvement: 1) at 640x480 it's twice as big as the Chumby wants; 2) how would my wife know when the picture was taken? isightcapture can resize the picture, but let's pretend it can't. My wife likely doesn't care when the picture was taken, but let's pretend that she does. Humour me here, okay?

Is there something out there that could solve both of these problems? Something free? Why yes. Enter ImageMagick. ImageMagick is an excellent full-featured image manipulation toolkit; indeed, you will see it prominently featured in the Acknowledgements section of Pixelmator, for example. It also is command-line driven, which is perfect for what I wanted to do here: resize the image and annotate it with a timestamp prior to uploading it. So, I built ImageMagick via via MacPorts and added a call to its convert tool to my script with the following options:

+contrast +contrast +contrast -noise 3 -resize 320 -stroke blue -fill white -pointsize 18 -font Arial-Bold -annotate +20+20 "$(date '+%a %m/%d %H:%M')"

That's a bit of a mouthful, so let's break it down:
+contrast +contrast +contrast bumps up the contrast a little, as my iSight happens to face a window in my office;
-noise 3 denoises the image, which looks pretty pixelly in the poor light of my office;
-resize 320 resizes the image proportionally to a width of 320 pixels;
-stroke blue -fill white sets the text to be white with a blue outline;
-pointsize 18 -font Arial-Bold sets the text to be 18pt Arial Bold;
+20+20 sets the text origin at 20 pixels in and down (respectively) from the top left-hand corner;
"$(date '+%a %m/%d %H:%M')" runs the command-line date program to get the timestamp in the format that I want: Sun 05/04 23:28

Running convert on our raw image with those options gives us:



Great! We now have an automatically-annotated image.

Automation
Now all that remains is to automate the process of running the shell script every few minutes, so that the image the Chumby will download from the website will actually change.

You could use cron or launchd for this. Unfortunately, Apple recently changed things so that isightcapture wouldn't work from background daemons, likely as part of some security update. Fair enough, I suppose. To get round this we must introduce another quirk: a little AppleScript to make our script execute in the user's 'face', so that it can access the camera. To do this open up Script Editor and create a script with a line similar to the following:

do shell script "/Users/dave/bin/grabme"

Save your script out as an application. In my case I made it grabme.app.

Now we can set up cron to run our AppleScript for us, by adding a line to our crontab:

0,15,30,45 10-17 * * 1-5 open /Users/dave/bin/grabme.app

This example will take a picture every 15 minutes between 10am and 5:45pm, Monday through Friday.

On the Chumby
So now we have our image automatically captured and uploaded when we want it to. The next step is to configure the Chumby to display the image. In the widget selector on chumby.com, go to Webcams and then choose Load Image From URL. Put the widget in the channel you of your choice and then customize it with the URL your image is available at. Be sure to select the prevent Caching radio button.

After all that you should be "rewarded" with:

iSight on Chumby

MythTV on mac

I repurposed my Pentium 4 HT tower a while back (no more Windows!) to run knoppmyth, a custom Linux distribution for MythTV that makes it as easy as possible to set up a beige box as a PVR. In our house, this box's primary purpose is to record Spongebob Squarepants ad infinitum, with the occasional Daily Show with John Stewart thrown in for the adults. It works great; I don't even have a monitor hooked up to it anymore, just the TV with the Hauppauge 350's IR sensor hot-glued to the front.

MythTV is often used just like this, with a single machine hooked up to a single television or monitor. However, it can also act as a media server for your network, making all the recorded shows, your music files and pictures available to any other machine on your network running the MythTV frontend. So, I was pleased to fine pre-built binaries of the MythTV frontend for OS X over on their wiki. I downloaded one from The Snider Pad and didn't have too much trouble getting it up and running. All I had to do was change the permissions in the MySQL configuration file on the MythTV box to allow non-localhost connections (set bind-address to 0.0.0.0 in /etc/mysql/my.cnf). After that, I could sit on my bed with the MacBook on its 802.11b connection and watch any of the recorded shows, or live TV even, remotely from my MythTV box.

Here's the main menu:

MythTV menu on the MacBook

From there I'm only a couple of clicks from:

A yellow sponge character on MythTV

...wait, that's not the Daily Show...but I haven't seen this episode before...

New Hitachi Drive

So, within 10 days of me buying Hitachi's Travelstar 7K200, they have come out with a Travelstar 5K320. Luckily for me, that 5K prefix means that it's only 5400RPM though.

Travelstar 5K320

New Drive: Update

So I've had the 200GB, 7200RPM, Hitachi Travelstar™ 7K200, in the MacBook for almost a week now. The first night I had it, I had it copy our entire iPhoto and iTunes libraries from the PowerMac. I"ve also added a Fedora Core 8 VM to go with my Windows XP VM, and I've turned on iDisk syncing.

So what's left now:

Hitachi drive, after one week

- 56GB, which means I've gobbled up 80GB with the aforementioned stuffed, but still a goodly amount left for more cruft - huzzah.

On the speed front, it seems to be peppier, but I could be imagining that since it never felt all that slow anyway, even with the 5400RPM Toshiba in it. I also don't notice any more noise or heat. I haven't yet run off-grid long enough to see if battery life has been reduced.

So far though, I couldn't be happier with the upgrade. I now have all of the movie files from our digital camera on the MacBook, so I can put them together in the new iMovie; I couldn't do that on the PowerMac as it's too old for the new iMovie to install on. It's also nice to have all of our music with me, since I sync my Nano to the MacBook (mostly just for podcasts for my commute, but occasionally I'll listen to some tunes).

You don't know the power of the darkside MacBook

I was catching up on some work tonight. I had a Visual Studio 2005 application running on an XP machine, connected via TCP/IP to a Java server application running on a Fedora Core 8 machine. During compilation, and commits to source control, I was going through my news feeds in NetNewsWire on my MacBook.

No big deal, right? Well, the interesting thing is that only the MacBook was a real machine: the XP and Fedora machines were actually virtual, and running on the MacBook courtesy of VMWare Fusion. It hit me just how much computing power we have at our disposal these days: a 15-month old consumer-grade laptop running 2 virtual machines plus its own applications, all simultaneously and without any perceptible slowdown: this is not even a MacBook Pro!

Here's what my Spaces-plus-Expose view shows me (Spaces is Leopard's multiple-desktop implementation, and Expose is OS X's way of showing you all the active windows on your desktop, so you can pick one to switch to; in true Apple-cool fashion, if you bring up the Spaces view and then ask for the Expose view it shows you the Expose view for each one of your desktops simultaneously):

Spaces plus Expose view of my MacBook

In the top-left we have space number 1, where: I have started to write this post in RapidWeaver; iTunes is running (that's Californication from Red Hot Chili Peppers at the front, if you were wondering); Transmission is seeding the Fedora Core 8 DVD ISO; OmniFocus, iChat, Terminal, Mail and Safari are all doing their thing; and Activity Monitor is letting me know how this is all going. It's not shown, (eggs, chickens and what not) but I had Pixelmator going as well, long enough to blur a couple parts of the screenshot to protect the innocent.

In the top-right, the Fedora 8 VMWare Fusion virtual machine is running a Java server application and its database backend.

In the bottom-left, NetNewsWire is keeping me up-to-date.

Finally, in the bottom-right, the XP VMWare Fusion virtual machine is running Visual Studio 2005 debugging an MFC application; by the way, I don't know MFC.

Here's a close up of Activity Monitor, with the memory tab active, sorted by descending order of use of real memory:
Activity Monitor

The big hitters, unsurprisingly, are the two virtual machines, weighing in at around 500MB each. They were both configured with 512MB of RAM, so that makes sense. Next we have the kernel, close followed by RapidWeaver (the application that I use to write this). From there you're down in the weeds of measly 60MB chunks of RAM here and 40MB chunks of RAM there. From the stats at the bottom, you can see that there's 369MB (sum of free and inactive) of RAM free (see this Apple article for an explanation of the different categories of memory).

And just think, if you buy a MacBook now you can fit 4GB in it and the integrated graphics are faster than mine. How many VMs can you run?

New Hard Drive

lots of free space!

I replaced the hard drive in my MacBook today with a new 200GB, 7200RPM, Hitachi Travelstar™ 7K200. I had read several reviews, all favourable, and supposedly it doesn't use much more power, or get much warmer, than the stock Toshiba 80GB. I use VMWare Fusion to run an XP VM and an OpenSolaris VM, so the 74GB on the stock drive wasn't cutting it. I ordered the new one from MacSales and picked up a Newer Technology USB 2.0 Universal Drive Adapter at the same time; it lets you hook up just about any bare drive to a PC or Mac via USB 2.0.

I hooked up the new Hitachi via the adapter and used Disk Utility to create a single 185.99GB partition. I set it up with 'GUID Partition Table' as the Partition Map Scheme, since that's required on Intel Macs for boot volumes. I then had SuperDuper make a bootable image of my existing hard drive, which took a couple of hours.

Once I had that, I rebooted while holding down Option so that it would let me choose a boot volume on boot. The Hitachi showed up - a good sign - and I selected it. It came up, I logged in, and everything looked good, so I shut it back down and proceeded to swap the drive out. Fortunately Apple makes this about as painless as it could possibly be; providing you follow common-sense precautions for ESD you shouldn't have any trouble. I printed out the instructions at
MacInstruct and headed over to our hardware lab at work, since it has copious amounts of static-mat-covered workbenches and the Torx T8 you need to get the shield off the old drive. 10 minutes later I was up and running on the new drive.

I should have named the new drive 'Macintosh HD' to match the old one, but I didn't and both Time Machine and Spotlight got a bit excited when I booted up. But my old Time Machine drive isn't going to be big enough for long, and I don't need any of the history that's on it anyway, so this wasn't a big deal for me.

I'll report back on whether the RPM bump affects battery life and performance.