Archive for January, 2007

Finding the longest common prefix of an array of strings in Python

Saturday, January 6th, 2007

This is in response to wootest's post on finding the longest common prefix of an array of strings in Ruby.

files = ['/foo/bar/xyzzy_one', '/foo/bar/xyzzy_two', '/foo/bar/xyzzy_three/four']

No change here. For relative paths, use os.path.join(os.getcwd(), path) to convert each path to an absolute path.

We follow this up with:

import os lcp = os.path.commonprefix(files)

*bows*

*walks off*

You know MWSF2007 has started when…

Friday, January 5th, 2007

It's finally here: The MWSF 2007 Edition of Keynote Bingo is out. Just in time for the start of the Expo!

It's very small — the whole disk image is about 57 K, using UDIF+bzip2 format. As you may guess from that, the disk image requires Tiger; there won't be a Panther version this time, because the app requires Tiger too (for PDFKit and NSError presenting). Instructions are included on the disk image, in the README file.

I would encourage you to download your copy now, or at least very soon. When I released the WWDC 2006 version, the vast majority of the downloads came within the half hour or so before the keynote started. At the time, I was on GeoCities, so that drove me straight into the hourly bandwidth limit. I don't have that problem anymore, being on TextDrive now; even so, you should get your copy now to help the server and its pipe not be swamped come the keynote.

Here's hoping you get a bingo!

Free stuff on iTunes: PBS science pilots

Thursday, January 4th, 2007

PBS is looking at three science-show pilots, and can't decide which one to order as a full series. So they've made all three pilots available, for free, and ask your opinions on them (perhaps by iTunes commenting — I haven't watched the videos; there may be instructions within them or something). Each show is a full hour. They are:

  • “Wired Science”, from KCET (channel 28 in Los Angeles — have I mentioned that I'm in the LA TV market?) and Wired Magazine.
  • “Science Investigators”, from WGBH. Possibly related to History Detectives?
  • “22nd Century”, from Towers Productions and Twin Cities Public Television.

On initializing static variables

Thursday, January 4th, 2007

Did you know that you don't have to initialize static variables? (If you've done any Cocoa programming, you know that statics are commonly treated as class ivars, most commonly to hold singleton instances.)

Quoth C99 (§6.7.8 paragraph 10):

… If an object that has static storage duration is not initialized explicitly, then:

  • if it has pointer type, it is initialized to a null pointer;
  • if it has arithmetic type, it is initialized to (positive or unsigned) zero;
  • if it is an aggregate [array or structure —PRH], every member is initialized (recursively) according to these rules;
  • if it is a union, the first named member is initialized (recursively) according to these rules.

And I've prepared a test app that shows that gcc 4.0.1 on OS X 10.4.8 does seem to comply with this handy part of the standard.

Happy not-initializing!

The list of strings

Wednesday, January 3rd, 2007

Here's what I have for MWSF 2007 Keynote Bingo. This is the entire list, including old strings from the WWDC 2006 edition (except for the ones that I pruned).

If you're still kicking around a string idea, or you think of one while flipping through this list, consider this the eleventh hour. This is the last call for new strings. ☺


These strings are from the original WWDC 2006 card by John Siracusa:

  • Universal Adobe or MS Office demo
  • “Boom”
  • Virtualization in Leopard
  • New video iPod
  • New iPod Nano
  • Mac Pro model <= $1,499
  • “Otomatic”
  • “New” Finder in Leopard
  • New case for Mac Pro
  • Movie rental service
  • iPhone
  • Mac Pro model >= $3,499
  • New MacBook Pro
  • “One more thing…”
  • New desktop Mac (not Mac Pro)
  • New kernel in Leopard
  • Resolution Independent UI in Leopard
  • iPods with cameras
  • Quartz 2D Extreme enabled in Leopard
  • New file system in Leopard

New strings for WWDC 2006!

  • At least one white product
  • At least one black product
  • At least one brushed-metal product
  • At least one product in multiple colors
  • HD/HDTV mentioned (HD-DVD doesn't count)
  • Blu-Ray
  • Bluetooth 2
  • HD-DVD
  • New displays
  • New display size
  • Any display size discontinued
  • Mac mini accessory
  • Intel Core 2 Duo
  • ATI dropped
  • ATI not going away
  • Xserve with Intel
  • 500 GB drive
  • 750 GB drive
  • New iPod model
  • Apple Bluetooth headphones (no mic)
  • Apple Bluetooth headset
  • iPod with Bluetooth headphone support
  • iPod flea/pico
  • Touch-screen iPod
  • Finger-hover- operated iPod
  • Tablet iPod
  • Tablet MacBook (Pro or otherwise)
  • iPod accessory
  • Tie-in between Quartz and any GPU maker
  • Mac engraving
  • New incarnation of AirPort
  • Nike+iPod mentioned
  • USB telepathy adapter
  • FireWire dropped from all Macs
  • Safari 3.0
  • RSS/Atom /podcasting added to any app
  • Updated iLife (not just iTunes)
  • HyperCard 3.0
  • Growl included in Leopard
  • Growl cloned in Leopard
  • Safari RSS replaced with Vienna
  • Safari RSS replaced with Feed
  • Safari RSS replaced with NetNewsWire
  • Safari RSS replaced with NewsFire
  • Safari RSS replaced with NewsMac
  • BitTorrent in Leopard (in any form)
  • BitTorrent in Safari
  • BitTorrent in iTunes
  • BitTorrent in iPhoto
  • BitTorrent in Pages
  • BitTorrent in Keynote
  • BitTorrent in Software Update
  • BitTorrent in Chess
  • New Sudoku application
  • New Sudoku widget
  • BitTorrent tracker in OS X Server
  • New Pro app
  • One or more updated Pro apps
  • Grapher 2.0
  • Writable FTP in Leopard
  • FTP client
  • New iApp
  • OpenOffice Document support in Pages
  • OpenOffice Document support in TextEdit
  • Updated iWork
  • New app in iWork
  • Spreadsheet
  • Crash during demo
  • iTunes DRM changing
  • iTunes DRM going away
  • iTunes Store music sales
  • One or more new APIs in Leopard
  • ZFS in Leopard
  • ZFS in Leopard explicitly denied
  • ReiserFS in Leopard
  • Writable NTFS in Leopard
  • Any of ext[234]fs in Leopard
  • BeFS in Leopard
  • New UI theme
  • New QuickTime codec
  • Mouse gestures
  • Hand gestures (via iSight, like EyeToy)
  • Focus- follows- mouse
  • New API added to Quartz
  • Copy of Windows to be included with every OS X disk
  • Copy of Windows to be included with every Mac
  • New anti-virus app introduced due to Windows
  • New .Mac features
  • .Mac price dropped
  • .Mac price raised
  • Backup 4.0 (.Mac)
  • .Mac SDK 2.0 released
  • Music is played during an app demo
  • Musical guest
  • Video conference
  • Apple Store data presented
  • Third party application talked about
  • Phil Schiller on stage
  • Roz Ho on stage
  • Paul Otellini on stage
  • Wil Shipley on stage
  • Chris Forsythe on stage
  • Apple employee number 8 (Chris Espinosa)
  • Steve with beard
  • Steve without beard
  • Steve with no belt
  • Shot of audience
  • Audience member yells “BINGO!”
  • Audience member whispers “BINGO!”
  • Audience member ejected from auditorium
  • Audience member ejected for yelling “BINGO!”
  • Audience member not ejected for yelling “BINGO!” (special dispensation from Jobs)

New strings for MWSF 2007!

  • Apple's cell-phone: “iPod phone”
  • Apple's cell-phone: “iMobile” (Kevin Ballard, referencing iPhone Insider)
  • Apple's cell-phone bundled with new Macs
  • Illuminous (new UI instead of Aqua)
  • Keynote ends without “One more thing”
  • Parallels bought by Apple, bundled with Leopard (Kevin Ballard)
  • iPod phone socks (Kevin Ballard)
  • Spreadsheet in iWork 2007 (Kevin Ballard)
  • Spreadsheet's name is Numbers (Kevin Ballard)
  • Name of iTV announced
  • Release date for iTV (Kevin Ballard)
  • .Mac discontinued
  • Beatles on iTunes Store
  • Paul McCartney on stage
  • Representative of Apple Records on stage
  • Bertrand Serlet on stage
  • “Top Secret” Leopard features revealed
  • iTunes Store TV show sales
  • iTunes Store movie sales
  • iTunes 8
  • GPS in the iPod (Andy Kim — he was joking, but I like the idea. Also, I will accept a GPS add-on (see the Belkin voice recorder for an example).)
  • New “adult” section in iTunes Movie Store (Luc Pellissier)
  • New iLife app
  • One or more updated iLife apps (including iTunes)
  • LED backlight on notebooks (DigiTimes.com: Apple and HP to launch LED-based notebooks)
  • Bruce Chizen (Adobe CEO) on stage (Jesper)
  • Steve to Bruce Chizen (Adobe CEO): “What took you so long?” (Jesper)
  • Steve in Nike+ shoes (Jesper)
  • Steve in New Balance shoes (Jesper)
  • Steve in shiny business shirt (Jesper)
  • Nike+ for more iPods (Jesper)
  • Nike+ for iPod phone (Jesper)
  • “The back of our computers looks better than the front of our competitors' computers.” (Jesper and Andy Kim)
  • Potshot at Vista (Jesper)
  • Announcement of one or more movie studio deals for iTunes (Andy Kim)
  • No announcement of movie studio deals for iTunes (Andy Kim)
  • Adobe CS3 release date announced (Andy Kim)
  • 802.11n compatible Airport or Macs (Andy Kim)
  • New displays with built-in iSight (Andy Kim)
  • iPod games mentioned
  • One or more new iPod games
  • HD content on iTunes (Dan Benjamin: Regarding Macworld 2007)
  • New, smaller laptop (Dan Benjamin: Regarding Macworld 2007)
  • Beatles special-edition iPod (Dan Benjamin: Regarding Macworld 2007)

UPDATE 2006-01-07: See also “Now, 4% more bingo!”, in which I announce version 1.0.1. Version 1.0.1 adds a net total of 8 strings.

Keynote Bingo MWSF 2007 Edition page is up

Tuesday, January 2nd, 2007

The keynote looms ever closer, and so does the bingo! I've now posted the MWSF 2007 Edition page, complete with the sneak preview. (You can tell that seed numbers are now printed — this one is marked “Card #0”.)

It's still not too late to think of things to put into those cells. You can propose new strings either by commenting on my “Call for strings” post or by emailing me (my address is on my front page).