Joe Maller.com

WWDC 08 wrapup

WWDC 08 was incredible. While the iPhone gold rush euphoria contributed, everything just seemed especially good this year.

I’ve been quietly disappointed in Leopard since it shipped. It just seemed too rough around the edges and somewhat rushed, especially compared to the polish demonstrated by the iPhoneOS. Because of that, I’m probably more excited about Snow Leopard than I was about Leopard. Besides the promise of generally improving the overall experience, the under-the-hood OpenCL and “Grand Central” additions are truly revolutionary advances for desktop OSs. The idea behind OpenCL being able to utilize the largely untapped parallel processing power of the GPU has the potential to radically reorganize the entire idea of computing, moving things distinctly towards a brain-like collection of specialized processing units. I’ve been joking this is OS X SP1 but that’s just not true, Apple is mainlining some serious innovation into the backend of Snow Leopard and this should be a very, very good release.

My plan for this year worked very well. I managed to set aside the week prior to essentially cram on Cocoa and Objective-C. While that was originally supposed to be three weeks, the time I eeked out still helped a great deal. I also maintained a very disciplined focus about which sessions I went to. In the past I’ve flitted around trying to get a taste of every subject that interested me — which is almost everything. This year’s deliberate focus and pre-study nearly eliminated the blank-stare drift I’d experienced in the past and left me feeling more confident than ever about building stuff with Cocoa, writing FXPlugs and making things for iPhone.

But far and away the best thing about this year was the people. Twitter made a lot of this possible by starting conversations beforehand. I think I probably met half my twitterstream in person, which was awesome and kind of funny. The social dynamic of first meeting twitterers is sort of one where everyone treats everyone else like a celebrity. It ended up being this wonderful abstracted feeling of recognition which wasn’t nearly as creepy as it sounds like it would be. My only regret is not meeting the handful of people I knew were there but never crossed paths with.

There are just too many people to call out, but I was blown away by just about everyone I met.


Home movies as iTunes TV Shows

Update: At some point, probably with iTunes 8 though I didn’t notice at the time, iTunes added support for batch changing video format, making the script featured in this post obsolete… as it should be.

itunes_multiple_info

Original post follows.

We usually keep our home movies in iPhoto, but recently I’ve started moving some select clips into iTunes. Unfortunately, the list of Movies quickly becomes unmanageable. These kinds of videos are much easier to work with when grouped as TV shows, but unfortunately iTunes won’t batch convert Video Kind.

So I wrote a script. In addition to defining selected movies as a show, it also tags their season with the current year and sets the Show Title. Here’s the script: (Open in Script Editor)

set showTitle to display dialog “Enter TV Show Title” default answer “Family Videos” buttons {“Cancel”, “Ok”} default button 2

set theYear to year of (current date) as integer

tell application “iTunes”

copy selection to tracklist

repeat with theTrack in tracklist

set show of theTrack to text returned of showTitle

set season number of theTrack to theYear

set video kind of theTrack to TV show

end repeat

end tell

 

To use that, just select some movies in iTunes and run the script. Whatever’s selected will be tagged and grouped under the title you entered.

Now our home movies are all grouped together and easily synced to iPhones or other iTunes fed products like iPods and Apple TVs. To view videos on any of those devices, the movies will need to be converted to iPod compatible format. QuickTime can do it, but iSquint/VisualHub can do it much faster.

This could have been done with AtomicParsley, but AppleScript is easier and pre-installed on every Mac.

What would be really great is if iTunes and iPhoto could talk to one another and pull video content out. iPhoto has supported movies for years now, why can’t they talk to each other? (because neither was designed for handling video formats?)

There’s plenty of room to improve this, if you do please post a link in the comments.


Fixing a Palm duplicate disaster

I recently came across an absolute disaster of a Palm Desktop data file while helping someone setup a new iPhone. It had 13,572 contacts, mostly duplicates. Judging from the number of obvious duplicate entries, my guess is the actual number will be somewhere around 2500 (it was).

Here is the process I used to automatically remove a lot of those duplicates and import the remainder into the Mac’s Address Book.

The first step is to get out of Palm Desktop as soon as possible. Select all contacts and export to a group VCard. This one was 3.4 MB.

Most of this will happen in Terminal, but a quick stop in BBEdit or TextWrangler will save a few steps later on. (TextMate tends to choke on big, non-UTF files.) The Palm export file is encoded in MacRoman. It’s 2008, pretty much any text that isn’t Unicode should be. I used TextWrangler to convert the encoding to UTF-8 no BOM (byte order marker).

VCards require Windows style CRLF line endings. While we could deal with those in Sed, we might as well just switch the file to Unix style LF endings in TextWrangler too. The TextWrangler bottom bar should switch from this:

MacRoman CRLF

To this:

utf8 LF

Now comes the magic.

While this could be done as an impossible-to-read one-line sed command, it’s easier to digest and debug as separate command files.

Here are the steps:

  1. Use Sed to join each individual VCard into a single line using a token to replace line feeds, output to intermediate file
  2. Sort and Uniq the result to remove obvious duplicates.
  3. Replace the tokens with line feeds

Below are the two sed command files I used. I ran these individually but they could easily be piped together into a one-line command.

vcard_oneline.sed:

# define the range we'll be working with
/BEGIN:VCARD/,/END:VCARD/ {

# define the loopback
:loop

# add the next line to the pattern buffer
N

# if pattern is not found, loopback and add more lines
/\nEND:VCARD$/! b loop

# replace newlines in multi-line pattern
s/\n/   %%%     /g
}

Run that like this:

sed -f vcard_oneline.sed palm_dump.vcf > vcards_oneline.txt

Then run that file through sort and uniq:

sort vcards_oneline.txt | uniq > vcards_clean.txt 

vcard_restore.sed:

# replace tokens with DOS style CRLF line endings
s/      %%%     /^M\
/g

# add the <CR> before the LF at the end of the line
s/$/^M/

Run that with something like this:

sed -f vcard_restore.sed vcards_clean.txt > vcards_clean.vcf

After that last step, you should be able to drag the vcards_clean.vcf file into Address Book to import your vcards.

Suggestions for improvement are always welcomed.

Notes:

In VIM, type the tab character as control-v-i (hold control while pressing v then i), type the line break by typing control-v-enter.

iconv could be used to convert from MacRoman to UTF-8. TextWrangler just seemed easier at the time.

Palm Desktop appears to dump group VCards in input order, so duplicate entries were not grouped together. Running the output through sort visually reveals a ton of duplicates and makes it possible to use uniq to remove consecutive duplicates.

I had to quit and re-open Address Book once or twice before it would import the files.


iTransmogrify update

The main iTransmogrify! script has been updated with a bunch of new functionality:

  • YouTube.com pages are now supported (see notes)
  • Daily Motion videos are supported for new-style urls (see notes)
  • Kink.fm player and listings page are now supported
  • Sideload.com play links are now supported
  • WordPress Blogs using Viper Video QuickTags are supported for YouTube
  • All media links now open into new windows, so you won’t have to re-transmogrify a page with several media files after playing one. Note that this is dependent on the iPhone, sometimes it will blank other windows)
  • Some content in iframes will now be converted.
  • MotionBox, Viddler and Vimeo embedded videos, while not supporting iPod/iPhone alternate content, now link to their respective detail pages.

The main bookmarklet code was updated. This was necessary to workaround a frustrating oversight with Google Code hosting. Everyone will need to update their bookmarklet, in the future all updates will be automatic.

This has turned out to be far bigger than I ever imagined. Thank you to everyone for the links, feedback, compliments and ideas.

Known issues

LiveJournal pages redefine a bunch of core JavaScript functionality, breaking all kinds of stuff including jQuery. Additionally, they’re serving media in an iframe from a different domain, meaning JavaScript couldn’t access the frame even if they hadn’t broken it.

Notes

YouTube Internal pages
Because of a strange iPhone quirk, these links all need to go through the Google redirector, otherwise they bounce back to uk.youtube.com instead of playing.

DailyMotion
DailyMotion videos using new-style urls, which are usually about six digits long, work correctly. Videos using the old-style alphanumeric ID do not work yet. I’m probably just going to resort to building a simple web-service to grab those. Additionally, there is no way to programatically access the mp4 alternate content url, so I just linked to their iPhone pages. I’d prefer embedding QuickTime directly, but it’s just not possible yet.


MWSF 2008 pre-thoughts

Just so I can go on the record, here are my thoughts before the Macworld 2008 keynote.
(more…)


iTransmogrify!

iTransmogrify! is a bookmarklet for iPhone which transforms embedded Flash content into direct links to natively supported formats. That means YouTube videos and MP3s can now be played from the iPhone’s Safari web browser with just a few clicks.

Seeing it work is the best explanation:

On an iPhone? Try it now: iTransmogrify! (works in Safari and Firefox too)

Sorry, it took YouTube a long time to re-encode that for iPhone, here’s a baby panda:

Installation

To install the bookmarklet, just drag the link to your Safari or Firefox Bookmarks, IE users should right click and choose “Add To Favorites…” After adding the link, sync your iPhone.

Grab it now: iTransmogrify!

You can also add iTransmogrify from your iPhone!

More information, source code and bug-tracking is available on the iTransmogrify Google Code page.

    Currently supported content:

  • Default YouTube Object-Embed code
  • YouTube bare Embed
  • YouTube bare Object
  • A variety of Flash-based MP3 players including Digg Podcasts

Lots more added: iTransmogrify update

Support for other embedded media sites will be added as I figure them out. Please report broken sites or suggest additional sources using Google Code issue tracker.

Acknowledgements

The first robust, script insertion bookmarklets I ever saw was Sumaato’s original Flickr GeoCoding bookmarklet.

Other sites also deserving links:

iPhone graphic reference:

Also, John Resig’s amazing jQuery JavaScript library. This project was the excuse I’d been looking for to finally dig in and learn it.

The name came from a late-night brainstorming chat with Bruce and was far more fun and interesting than the utilitarian ones I was thinking of. So thank you Bruce, and of course, Bill Watterson.


Multiple RegisterResource directives broken in Leopard

This is sort of a follow up on the old mod_rendezvous article I wrote for O’Reilly. While cleaning up my virtual hosts I discovered a bug in 10.5’s handling of multiple RegisterResource directives in mod_bonjour. This is expanded from a bug report I submitted to Apple (rdar://problem/5628484).

I keep functional mirrors all my development sites in separate Apache Virtual Hosts. Each one then gets it’s own port, which allows me to check them on local networks, in Parallels and, if I want, remotely via IP address.

To advertise two local vhosts over bonjour, something like this in httpd.conf should work:

&lt;IfModule bonjour_module&gt;
RegisterResource "Site 1" / 9001
RegisterResource "Site 2" / 9002
&lt;/IfModule&gt;

After restarting Apache (sudo apachectl graceful), local copies of Safari should see the two sites, “Site 1″ and “Site 2″ in Bonjour bookmark listings. In 10.4, they show up. In 10.5, only “Site 2″ shows up. No matter how many directives are included, only the last one will be visible.

I’d love to be wrong about this, but it seems that something broke this function in Leopard.

A faster way of checking Bonjour entries is to open a terminal window and run the following command:

mdns -B _http._tcp

That will show a live updating list of current multicast (Bonjour) entries. Under 10.4, I get the following after adding the above directives to httpd.conf:

16:10:14.517  Add     0 local.     _http._tcp.     Site 1
16:10:14.667  Add     0 local.     _http._tcp.     Site 2

However with 10.5, I get this:

16:12:52.597  Add     1 local.     _http._tcp.     Site 2
16:12:52.598  Add     1 local.     _http._tcp.     Site 2
16:12:52.598  Add     0 local.     _http._tcp.     Site 2

What I’d really love to do is figure out how to register and respond to multiple Bonjour names. That way I could have each vhost be a named host and each staged site accessible at a url like site1.local and site2.local. So far I haven’t had any luck getting that working.



Next Page »