Thursday, February 2, 2012

Embedding iPython, redux

I've posted about iPython as an embedded debugger before; it turns out that the syntax has changed a bit:
  import IPython
  IPython.embed()

Friday, January 20, 2012

hdiutil and OS X data recovery

Your hard drive fails, so the first thing you do is grab dd and pull a byte-by-byte copy of the drive's contents:
   dd if=/dev/bad_drive of=bad_drive.img conv=noerror,sync

Problem is, if the drive was from a Mac and you want to use a recovery tool like Data Rescue or Drive Warrior, you'll probably need to attach your drive image as a loopback device, and double-clicking the file to mount it doesn't work when the filesystem is fragged.

Enter hdiutil:
   hdiutil attach -nomount bad_drive.img

Wednesday, December 21, 2011

Resuming truncated 'cp's

I'm sure this isn't too hard to do w/ dd, but let's say you've got some slow network disk mounted under /mnt/crappy_SMB_share and were 100 gigs into a 101G file when the Windows server went down, and now you want to finish off that last gig.

  cd /mnt/crappy_SMB_share
  curl -C - -O file:///original/file/location

from here.

Tuesday, September 27, 2011

AirPlay: streaming from iTunes and your iPhone to a Linux box

So I've got a Debian machine as a WiFi access-point / file-server, and I decided to plug some speakers in and stream music from my iPhone.

I tried Erica Sadun's AirPlayer, a Python script that, as it turns out, implements version 2 of the AirPlay protocol -- the one that supports video and images.  What it DOESN'T support is sound, at least not without the appropriate crypto key.

Which led me to Shairport, vessel of the secret sound-support sauce.  Shairport only implements AirPlay v1, which can't handle images of any kind.  Which means that the video portion of YouTube can be streamed from my iPhone to AirPlayer, and the audio portion to Shairport, but I have to choose one.  Huzaah.



This worked well enough for iTunes, but iOS, ie, my iPhone, didn't work until I disabled IPv6 on my Linux box.

Friday, June 3, 2011

Yet more Crescent City


Those giant game-of-jacks pieces are called dolos.

Wednesday, May 4, 2011

Another in a series of brief tests of Wolfram Alpha

If you've spent the last couple of years behind a few inches of lead, protecting you from the nerd-radiation of the Wolfram|alpha launch,well, you should read up on it.  It claims to be, not a search engine, but something smarter, a compendium of systematic data (temperature records, physical constants, business data, you name it), and the algorithms necessary to process that info.

I've been disappointed thus far.  I tried another reasonable-seeming query today: "kinetic energy of a ring with mass 1 kg and radius 1m rotating at 100 rpm"

(If you're wondering, I was hanging out by a centrifuge, which just begged the question, ya know?)

And what did Alpha have to say? "and (English word)"

It recognized the word "and" as English. That's it.

The answer didn't show up until the 8th hit in google's results, but there it was,

   E = 0.5 * I * ω
   I = m r2

etc etc.  Granted, I still have to do the math, but at least it's something.