Rocking the blogosphere

Archive for the 'Programming' Category

Xcode/iPhone error 0xE8000001: problem and fix

As you all probably know, I’ve written a word game for the iPhone called Word Up!

<shameless-plug>
reacquainted - 288 points
</shameless-plug>

Tonight, I started getting an error while trying to run my app from Xcode on my device (provisioned for development). The error was:

Your mobile device has encountered an unexpected error (0xE8000001)
during the install phase: Copying file.
Try disconnecting and powering off the device; then power the device
on and reconnect it.

I tried resetting the device a number of times and rebooting my MBP as well to no avail. It was beginning to look like I was going to have to do the dreaded restore and then lose all the cool jailbreak stuff that I’ve become so accustomed to. And then that made me remember that because my device is jailbroken, I can ssh to it and poke around. I wondered if a previous failed copy left some garbage on the device that was causing subsequent copies to fail.

iPhone:/ root# find . -name 'Word Up*'
./private/var/mobile/Media/PublicStaging/Word Up!.app
iPhone:/ root# cd /var/mobile/Media/PublicStaging/
iPhone:/var/mobile/Media/PublicStaging root# rm -rf Word\ Up\!.app/

Bingo. That fixed it. So if you hit this problem and you happen to have access to the filesystem of the device, give it a shot.

Python ternary operator

Today’s Python discovery:

Python doesn’t have the C style ?: ternary operator (e.g.: cond ? valueIfTrue : valueIfFalse).

But as of Python 2.5 it has a ternary operator with its own syntax: value_when_true if condition else value_when_false

For example:

>>> 'a' if 1 == 1 else 'b'
'a'
>>> 'a' if 1 == 0 else 'b'
'b'

This is actually clearer and more Pythonic than that ?:

Unfortunately, for Python versions < 2.5, you don’t have this. I’ve seen people use: (condition and [value_when_true] or [value_when_false])[0]

IMHO, this is clever – in a bad way. Yuck. Personally, I think I’d rather just do:


def if_cond_val1_else_val2(cond, val1, val2):
   if cond: return val1
   else: return val2

This adds 3 lines to your program (or 1 if you stick it in a module that you import from your programs) and won’t cause your colleagues to hate you.

SD West 2008

This week I’m at SD West 2008. I’m hoping to learn a few things about C++, especially C++0x and Boost.

Setuid demystified

Interesting that the Unix calls for setting user ids of processes are so varied and so complex, that they warranted an entire paper. I only skimmed, but I did get a pretty good description of the “saved uid” parameter of the setresuid call.

Setuid demystified (PDF)

TiVo HME SDK for Python

Just stumbled up on this (via TiVoBlog who in turn found it via TiVo Lovers) and will have to give it a try sometime:

From TiVo HME SDK for Python:

An implementation of TiVo’s HME (Home Media Extensions) protocol for Python, as a module (hme.py), a simple server (hmeserver.py), and examples (mostly ported from TiVo’s Java HME SDK). Everything is released under the LGPL 2.1+, except where noted. (Most of the examples are Common Public License.)

I developed this in Python 2.5.1, and haven’t tested it with other versions, but it does nothing exotic. (hme.py depends only on the struct module. hmeserver.py is a bit more demanding.) But I have tested it in Linux, Mac OS X, and Windows XP.

Perl->{’5.10′} += (”//” && > Operator[s])? =~ /amusing/

A snippet from the latest freshmeat.net announcement of Perl 5.10 that landed in my email inbox:

This version includes a new smart match operator, a switch statement,
the // defined-or operator, regular expression improvements, and
other language changes…

Funny, I was just thinking that what Perl needs most is more operators… :-)

Darcs 2

Chris pointed out that Darcs 2 is available for testing:

http://wiki.darcs.net/index.html/DarcsTwo

Next Page »