Photo of Dave Peck
Hi. I'm Dave Peck, a freelance software developer and hobbyist musician hailing from Seattle, WA.

 

Generating iPhone UIEvent Timestamps

March 08, 2010

If you're an iPhone developer, you've no doubt noticed that UIEvent has a timestamp value. According to the documentation, this is the time (in seconds) since system boot.

So what happens when you want to generate an equivalent timestamp somewhere that you're not using UIEvent?

I did a little digging; here's what I came up with:

#import <mach/mach.h>
#import <mach/mach_time.h>

+ (NSTimeInterval)timestamp
{
    // get the timebase info -- different on phone and OSX
    mach_timebase_info_data_t info;
    mach_timebase_info(&info);

    // get the time
    uint64_t absTime = mach_absolute_time();

    // apply the timebase info
    absTime *= info.numer;
    absTime /= info.denom;

    // convert nanoseconds into seconds
    return (NSTimeInterval) ((double)absTime / 1000000000.0);
}

This will give you NSTimeIntervals that are meaningfully comparable to those collected from UIEvent instances.

A Steve Reich Primer

March 03, 2010

Thinking about getting into Steve Reich? Here's my suggested order of operations:

  1. Music For 18 Musicians (ECM)

    Generally considered Reich's first masterpiece, 18 Musicians broke Reich away from the strictly "minimal" and process-oriented pieces he had previously written.

  2. Tehillim (ECM)

    A setting of Hebrew text to stunningly original orchestration, Tehillim is the piece that made me a life-long Reich devotee.

  3. Electric Counterpoint

    Counterpoint is Reich's multi-layered masterpiece written for, and performed by, Pat Metheny. You might recognize it as an eternal source of samples, notably first with The Orb's Little Fluffy Clouds and later from several RJD2 backing tracks.

  4. Different Trains

    On the same CD as the previous, Different Trains was one of Reich's earliest (and greatest) experiments with composing around the pitches present in human vowel sounds.

  5. City Life

    A five-movement piece built around field recordings taken by Reich on the day of the original World Trade Center bombing, City Life is strangely beautiful and affecting.

  6. The Desert Music

    Perhaps one of Reich's most difficult pieces, The Desert Music is complex, at turns claustrophobic and expansive, and worth many repeat listens.

  7. You Are (Variations)

    Written while Reich was approaching 75 years of age, I think You Are is one of Reich's later masterpieces.

  8. Early Works

    I've optimized this Reich ordering for easing into his music rather than studying him academically. That said, no Reich collection would be complete without a CD that highlights Reich's early philosophy of music as a gradual process.

Reich has written many wonderful pieces not included in this list, but I believe if you're serious enough about him to purchase these eight CDs you will probably end up like me and collect the rest. Enjoy!

Sayonara, DreamHost!

February 02, 2010

Meet the new blog... same as the old blog.

Well, not quite the same. I've been a DreamHost customer for nearly a decade. I wanted something stupid cheap; I got something both cheap and stupid. To be fair, I'd been warned. The people behind DreamHost are friendly and responsive, so even though my MX records sometimes disappeared for a few hours, or my blog crumbled under even moderate load, or somehow an extra $7.5 million unexpectedly left customers' pockets... well, I stuck with it.

No more. Even for my modest business homepage I need a setup that is:

  1. Reliable. My sites don't go down and they handle loads.
  2. Repeatable. I can easily move between providers without complex setup or import/export processes.
  3. Easy To Maintain. I have full source control over my sites and they use the simplest formats and tools possible.

As a result, I've moved my entire web presence into the "cloud." Specifically, I'm hosting all of my sites via git repositories; I'm hosting most of them via GitHub Pages.

For the majority of my sites, the move to GitHub Pages was painless. The exception, not surprisingly, was this blog: it is now built with Jekyll. Jekyll is a great tool and I highly recommend it. What hurt was exporting from WordPress. I ended up writing several custom python tools; Jekyll's built-in exporter was next-to-worthless. In the interest of time, I dropped the old comments (there weren't many.) Now that I've made the leap, I'm extremely excited to author my blog from emacs, in markdown. It's far easier for me than fighting the WordPress text entry area.

My remaining sites, like Go and WhereBeUs, are hosted via Google App Engine. (Of course, the code is managed in git, too.) Only my large MP3 files have escaped source control; they're hosted on Amazon S3. (Alas, git's performance with large binaries is not too hot.)

Finally, I've moved to Zerigo Managed DNS to handle the growing complexity of my domain name needs. In addition to having a great control panel for hand-editing DNS entries, Zerigo offers a killer REST API that is well-supported by both Python and Ruby. I couldn't be happier.

As for mail, I'm in the process of moving to hosted gmail -- if over the weekend you get a bounce, you'll know what's up.