Install this theme
In Case of Emergency, Your iPhone Should Help

Last week, a friend was in a serious car accident. His family wasn’t notified because he didn’t have any In Case of Emergency info on him, and his phone was locked with a passcode. When his family found he hadn’t come home, they called the police, who said he was in the hospital. He’d been either unconscious or medicated since arriving, and couldn’t tell the police anything. The good news is, he’s now recovering after surgery to repair a couple of broken vertebrae.

I know people have suggested turning your ICE info into a JPG and using it as lock screen wallpaper, but that’s kind of ugly. There should be a way to designate ICE contacts and to have them accessible from the iPhone’s Emergency Call screen.

Accordingly, I’ve filed rdar://11505181. Please consider doing the same. It’s important, and it can save you and your family a lot of grief.

Automator Actions with Xcode 4

Using previous versions of Xcode to develop Automator actions, you could just click the Run button, and Automator would launch using the just-built version of your action. However, this broke in Xcode 4, for both existing and new projects.

Looking around, I found an article with a solution (via Stack Overflow). Here’s a summary.

  1. Open the project in Xcode 4.
  2. Under the Product menu, choose Edit Scheme…
  3. On the Edit Scheme sheet, Choose the Run Automator.app from the list on the left.
  4. Under the Info tab, change the Executable to Automator.app. You may first have to choose Other…, then navigate an Open dialog to /Applications/.
  5. Under the Arguments tab, change the Expand Variables Based On option from None to your product.
  6. Click the + under Arguments Passed On Launch and add
    -action "$(BUILT_PRODUCTS_DIR)/$(FULL_PRODUCT_NAME)".

Now, when you Run the product, Automator will launch as before, and your new action will be available for debugging. I used this approach to freshen my Automator Pack.

I filed a Radar bug about the problem. Feel free to file a duplicate.

Great Strides 2012

We lost our cousin Sophie Temou to cystic fibrosis in 1996. However, the prognosis for CF sufferers gets better every year thanks to advances in medical science and thanks to the money raised by events such as the CF Great Strides Walk. We’ve named our team Sophie’s Striders in her memory.

That’s Sophie in a photo “taken one year ago” (as she wrote on the back of her copy).

We’ll be participating in the CF Great Strides walk at the Toronto Zoo on Sunday, May 27, 2012. Thanks to your donations last year, we raised over $4,000! Here are some photos of our day at the zoo.

You can contribute and help us beat 2010’s record total. Please donate securely by credit card here, then follow our progress on our Great Strides page.

You can join our team and raise money among your friends and family. Please contact me for more information.

Thank you.

WWDC Tips

I’ve been to WWDC a few times, and I’ve learned a few things. Here’s a condensed list.

Registration

  • WWDCs sell outs are faster every year. If you’ll be needing your boss’s permission (payment approval, or just for the week off work), get it now.
  • Keep an eye on Moscone Center’s events calendar. WWDC is usually first listed as a week–long “Corporate Event” happening in late spring or early summer at Moscone West. Follow WWDC Alerts to hear as soon as tickets go on sale.
  • If you’re a student, Apple usually offers a limited number of free passes through the Student Scholarship.

Travel

  • Book your flight and hotel as soon as you buy your WWDC pass. Prices increase as airlines and hotels learn there’s a large conference that week.
  • If your passport is expiring in the next few months, renew it now.
  • Join a frequent flyer program like Aeroplan or Air Miles, and use a credit card that rewards with miles. If your boss isn’t paying, your next flight to WWDC can be free.
  • Before you leave, get a Y38 card, listing all the valuable items you’re planning to bring with you on your trip and don’t want to get taxed for upon return. Avoid delays at the airport by visiting the CBSA office in the government building at Front & Yonge. Compile a list of the items and serial numbers, and bring the list along with the items to the CBSA. The agent can transfer all the information to the green card. Keep it with your passport.
  • Flying out of Buffalo can be much cheaper than YYZ, but you’ll have to take a connecting flight to get to the Bay Area, you’ll also have to get to Buffalo somehow. If you drive, you’ll have leave your car somewhere, but long-term parking is cheap, and many hotels have sleep-and-fly promotions. Another option is the bus from Toronto to BUF.
  • Pearson Airport has an up-to-date page with info for US-bound travellers.
  • There are a number of ways to get from SFO to downtown San Francisco. The better way is BART, from the station at SFO. You can either walk from your arrival terminal (about 10-15 minutes), or take the free SFO AirTrain. The trip from the airport station to downtown is only around 45 minutes, and costs around $8.
  • CocoaDev has a list of San Francisco hotels, arranged by distance from Moscone Center. Check the usual travel web sites for deals. BetterBidding is useful for decoding the anonymous hotel listings on Hotwire or Priceline.

The Conference

  • The Sunday before the keynote, you can pick up your conference badge and paraphernalia from Moscone West. Keep your badge safe! You’ll have to wear it visibly at all times during events, and replacing a lost badge is pretty much impossible.
  • For a good seat at the keynote, arrive early, and line up around the block. The doors open at around 7 a.m. Line up a few times as you ascend to the top floor. At around 9:45 a.m., they open the auditorium doors, and there’s a mad dash for seats. Or, just skip the keynote altogether.
  • If you have a development problem, make an appointment at the appropriate lab and bring your laptop, along with the project in question. You’ll get help from the engineers who built the frameworks and tools. For many, the labs are the most valuable part of WWDC.
  • There’s wifi network in Moscone West during the conference, and there are lounges throughout with ethernet and power strips. Most presentation rooms have power strips in the seating areas. If there are developer previews available after the keynote, you’ll have to download them by ethernet. Bring a USB-ethernet adapter if you have something like a MacBook Air.
  • If you don’t plan on visiting a hands–on session, or getting help at a lab, leave your MacBook at the hotel and use an iPad for notes and internet access. It’s much easier to carry around.
  • Bring an external hard-drive or re-partition your internal HD before leaving home, in case there’s a preview version of a new OS.
  • Apple posts up-to-date schedules at the attendee site, but before the keynote, there are a lot of TBA blanks. Log in to customize your schedule as the holes are filled. There’s also usually a WWDC iOS app, with up-to-date personalized schedules, maps and news.
  • Stump the Experts is a chaotic Mac development trivia contest pitting the audience against a large panel of Apple notables. Get there early, as it’s usually crowded. You may want to attend the Apple Design Awards too, because Stump takes place afterwards in the same auditorium, making it easy to move to a better seat.
  • The last session usually ends by midday Friday, so you save a bit by checking out of your hotel and taking a late flight home. Apple offers a luggage-check at Moscone.

If you’re hungry for more, Quora has huge list of tips.  Not enough? Just Google.

Better Ad Blocking and Privacy

A while back, @chicagobob tweeted about the MVPS hosts file. It blocks unwanted parasites by redirecting them to 127.0.0.1. To automate updating to the latest parasites list, I wrote* this bash script  (warning: it’s not for the faint of heart, and I make no guarantees):


#!/bin/bash

# Downloads the MVPS hosts file, and appends it to the system hosts file
#
# If you want to make any manual persistent changes to the system hosts
# file, run this script first, then make sure that the change is in
# /etc/hosts.orig.

if [ "$(whoami)" != "root" ]; then
echo "Sorry, this script must be run as root."
exit 1
fi

# Back up the original hosts file
if [ ! -f /etc/hosts.orig ]; then
cp /etc/hosts /etc/hosts.orig
fi

# Create tmp dir
if [ ! -f /tmp/update_hosts/ ]; then
mkdir /tmp/update_hosts/
fi

# Download the MVPS hosts file
curl http://winhelp2002.mvps.org/hosts.txt > /tmp/update_hosts/hosts.mvps

# Remove the stuff at the top
tail +26 /tmp/update_hosts/hosts.mvps > /tmp/update_hosts/hosts.mvps.tail
cat /etc/hosts.orig /tmp/update_hosts/hosts.mvps.tail > /tmp/update_hosts/hosts.dos

# Convert DOS line endings to UNIX
tr -d '\r' < /tmp/update_hosts/hosts.dos > /etc/hosts

# Clean up
rm -rf /tmp/update_hosts/

# Flush DNS
dscacheutil -flushcache


Save it to a file somewhere, make it executable and run it using sudo from time to time. (I’ll leave scheduling it regularly as a launchd daemon as an exercise for now.)

Combine that with a few free** Safari extensions - Safari AdBlockJavascript BlacklistIncognitoDisable Google ClickTrackerDoNotTrackPlus- and you have a reasonably effective ad blocking and privacy arsenal.

* Thanks to Peter Hosey for the dscacheutil suggestion.

** Safari AdBlock is donation-ware. It’s well worth whatever you want to donate.

Uncrustify with Xcode 4 on Lion

A while back, I gave a presentation at tacow about using Uncrustify to prettify your source code in Xcode 3.2. Then Apple released Xcode 4 and rendered much of that presentation obsolete. Now, I finally have it working in Xcode 4.1.

First, get the source for Uncrustify from its github repository, then build and install it, using these Terminal commands:

Then create a uncrustify config file and save it somewhere. You can start with the sample ones in the uncrustify project. Here’s mine.

Then, create an Automator service to uncrustify selected text in Xcode. I used Tony Arnold’s workflows, but they didn’t work for me by dropping the files; I had to create one manually.

  • launch Automator and create a new service
  • set its options to: Service receives selected text in Xcode; ☑ Output replaces selected text
  • add a Run Shell Script action; set its shell to /bin/bash and Pass Input: to stdin
  • set the script’s source to: /usr/local/bin/uncrustify -l OC -c /EXPLICIT/PATH/TO/uncrustify.cfg -q | cat
  • save the service as Uncrustify

Finally, open Keyboard System Preferences, go to the Services section of the Keyboard Shortcuts tab, and set a shortcut for the Uncrustify service (I use ^U).

Now, when you select text in Xcode, the Xcode > Services > Uncrustify menu should be enabled. Select the menu, or hit the keystroke, and your code will become a thing of beauty.

(Once caveat: it doesn’t seem to correctly align colons on multi-line method invocations. Using Xcode’s Indent command (^I) following Uncrustify fixes that nicely.)

Speculation on RIM’s future

As a Canadian, it’s sad to see RIM’s rapid fall from grace. Their products have devolved into too little, too late, and too buggy. Their once-mainstay corporate customers are defecting to iOS and Android devices, seemingly en masse, and their consumer offerings show a distinct misreading of the market. So, here’s what I see in the ol’ crystal ball.

The board will axe the co-CEOs by the end of this year. Their replacement (singular, it’s to be hoped, and not one of the incumbents) will publicly try to turn the tide, but really he’s there to cut costs and find an acquirer while their shares still hold some value. (To be sure, his golden parachute will be sweet, contingent on the deal he makes.)

Why would anyone want to buy them? Their IP may hold some attraction, but mostly it would be for BlackBerry Messenger. It’s their only remaining differentiator, and the only thing keeping people on BlackBerry (see network effect).

Apple built iOS 5’s iMessage app as a BBM-killer; for that reason, they don’t need RIM. Google doesn’t seem to me a good fit either — if they added advertising to BBM, people would head to iPhone in droves.

It would have to be someone with an existing smartphone platform into which they could integrate BBM while preserving support for legacy BlackBerry devices, at least until they could sell them a new phone. Microsoft comes to mind, and a couple of years ago they’d have been the obvious choice.

However, I think that within two years, RIM will be acquired by HP. They’ll build BBM into webOS and make it interoperate with legacy BBM. They’ll also try to sell a metric crapload of phones. It’ll probably be too late by then to become more than a niche player, but they’ll try.