a glob of nerdishness

November 27, 2010

Building CouchDB for PowerPC on Mac OS X 10.5 Leopard

written by natevw @ 8:52 pm

My first Mac was a G4 mini which now mostly just serves an external drive to our home network as a Time Machine backup destination. Since it’s powered up 24/7, I’ve been wanting to make a bit more use of it as a server, which means Couch of course.

Unfortunately, the process wasn’t terribly “relaxing” — I couldn’t find a PPC build of CouchDB for Mac OS X on the ENTIRE INTERNETS. Yet fortunately, after who knows how many hours of blood, sweat and swearing under my breath, I was able to coax out a working build. For the 3 other CouchDB fans out there who still have a PowerPC machine plugged in and enjoy sysadmin pain, here are my build notes:

  1. First, install git if necessary and follow the instructions for the build-couchdb helper scripts until the “rake” part.
  2. To avoid a mktmpdir issue in rake, you’ll need to get a Ruby 1.8.7 version of Rake working. I don’t recommend this route, but when it was all said and done I moved aside /usr/bin/ruby, /usr/bin/rake and /usr/bin/gem (each to /usr/bin/X-orig) and then followed the first few steps of these instructions to get newer versions working out of /usr/local/bin instead.
  3. To avoid an unsupported architecture crash-and-burn, you’ll need to go into build-couchdb/tasks/erlang.rake and comment out a 64-bit option line: #configure.push '--enable-darwin-64bit' if DISTRO[0] == :osx
  4. The CouchDB build doesn’t like the Leopard version of libcurl, so build and install the latest from source. Temporarily move /usr/bin/curl-config to /usr/bin/curl-config-orig so the build process will use the right curl libraries. (Again, there’s maybe a better way to do this, but I wasn’t feeling picky at this point…)

If any of that made any sense, and I didn’t forget anything, you may even be able to reproduce this on your own PowerPC Mac at your own risk. PLEASE PLEASE PLEASE let me know if there’s a better way to get build-couchdb using the right versions of Ruby and libcurl without desperately mucking around in /usr/bin like I did.

November 16, 2010

Fourth generation iPod touch camera focal lengths

written by natevw @ 9:16 pm

Late one night soon after I bought my fourth generation iPod touch, I did some sloppy measurements to try figure out the 35mm equivalent focal length of each of its two cameras. Here is a sloppy summary of my findings.

View from the iPod

The display on my MacBook is 11 5/16 inches wide (287.3375 mm). It fills the back (”720p”) camera width at a distance of 14 3/16 inches (360.3625 mm). It fills the front (”FaceTime”) camera width at distance of 11 inches (279.4 mm).

iPod focal length setup

Using some basic trigonometry:


a = 2 arctan (d/2f) # a = angle, d = dimension (my "width"), f = focal length, or, subject distance

…we can find each camera lens’s angle of view:


2*Math.atan2(287.3375, 2*360.3625) = 0.7587331199535923 radians (43.47 degrees)
2*Math.atan2(287.3375, 2* 279.4) = 0.9498931263447237 radians (54.42 degrees)

Standard 135 film is 35mm wide, and it is on this format I wanted to figure out the iPod lens equivalent. I massaged the angle of view calculation into a form that could yield a focal length based on an angle:


tan(a/2) = d/2/f

For 35mm equivalent, I plugged in 35 for d (”dimension”, my “width”) and solved for focal length as a function of angle:


tan(a/2) = 17.5/f
f = 17.5/tan(a/2)

So, the front (”720p”) camera has a focal length equivalent to a 44.9mm lens on a 35mm film camera body (or a 27.44mm lens on an APS-C body). The back “FaceTime” camera is wider, equivalent to a 34.0mm lens on a 35mm film body (or a 21.25mm lens on an APS-C body)

Then I looked at the EXIF metadata to see what it says about the camera. For the 720p camera, the metadata records a focal length of 3.9mm. If my 35mm equivalent focal length calculations are correct, this means a crop factor of 11.26 and thus a 3.11mm sensor width.

Now for the FaceTime camera, the EXIF metadata records a focal length of 3.9mm. Again? So allegedly this would be a 8.72 crop factor and 4.02mm sensor size. However, this camera is lower resolution (640×480 versus 960×720) and I have a hard time believing that it is a larger sensor. (If it were, the per-pixel area would be significantly larger and I’d expect much better quality and low light performance than the back camera.) I suspect the focal length metadata is (or at least was when I first looked…I should check again on the latest iOS) simply wrong for pictures taken with the FaceTime camera.