This is BrainLog, a blog by Dan Sanderson. Older entries, from October 1999 through September 2010, are preserved for posterity, but are no longer maintained. See the front page and newer entries.

July 2007 Archives

July 31, 2007

Indenting Source Code in Emacs

Most Emacs programming modes include automatic indentation facilities. If you press the tab key on any line, Emacs pushes the line into an appropriate place according to the structure of the code around it.

In most cases, the amount of indentation to use for any given line of computer source code is purely a matter of style that only human beings care about. Most programming languages use other grammatical elements, like curly brackets { and }, to represent code structure. The layout is just to make it easier for humans to follow:

for (int i=0; i < lst.length; i++) {
    initializeFlubber(lst[i]);
    if (isFlubberReady(lst[i])) {
        print("READY #%d: %s\n", i, lst[i].desc);
    }
}
destroyAllFlubbers();

Since indentation style is arbitrary, different programming communities tend to use different styles. Emacs modes have default indentation behaviors that are largely acceptable by most communities, both because the defaults were based on existing popular styles, and because the defaults tend to influence popular style because it's easier to use the default than to change it to something else.

Of course, if your community uses a different style, you can customize Emacs to do it your way.

continue reading...

July 30, 2007

YSlow, a Firefox+Firebug plugin for performance analysis of web pages, from Yahoo. YSlow rates any given web site on rules for high performance web sites.

Poetry in documentation.

July 27, 2007

Movable Type 4 now at Release Candidate 1. This release fixes all of the high priority known issues with MT4, including all of my personal high priority bugs. It's still not quite the final release, but it might as well be, thanks to a lot of hard work by Six Apart. Movable Type 4 is officially awesome.

The beauty of LaTeX. Nice short article on LaTeX's quality typesetting.

July 26, 2007

Social Networking In Plain English [YouTube].

July 24, 2007

W2, a little wiki optimized for iPhone.

July 23, 2007

On the Teeth of Wheels, on gears and computation.

July 13, 2007

Will It Blend? - iPhone. The latest in the ever-popular Will It Blend? series from Blendtec, makers of the blender used in the films. Never gets old.

July 12, 2007

FCC chairman favors unlocked devices for new spectrum.

iUI, a JavaScript library for the iPhone, including a method for detecting the screen orientation.

Remote Firebug for iPhone. "Basically, it is a little Python web server which acts as a bridge between your iPhone and the Firebug console running in the browser on your computer. When you call console.log() on the phone it sends your log message to the server, which reflects it back to Firefox (or Safari or whatever), which displays it in your nice big Firebug console. You can also enter JavaScript commands in the command line in Firefox and have them sent to the phone, evaluated, and sent back to Firefox. It all works surprisingly well!" Yay!

I've been complaining about Firefox being slow on a Mac for years, and all this time I should have been using Neil Lee's Mac-optimized build. The speed increase is noticeable and welcome. Downsides: The form widgets aren't identical to the original Firefox (though not bad), the app name and logo are different due to Mozilla Foundation rules (don't use the official logo on unofficial builds), and you have to get it from some dude's web site instead of a more official source. Totally worth it.

July 11, 2007

Flight of the Conchords on YouTube; Flight of the Conchords 12-part HBO television show, video clips on the site; Flight of the Conchords Wikipedia entry; official site; MySpace page; fan site, fan site, album, album.

(Thanks Mom.)

July 10, 2007

I had to do three things to get my old but nice Canon CanoScan N650U flatbed scanner to work with Adobe Photoshop CS3: 1) I had to download the latest driver for this model, which included a Photoshop plugin. 2) I had to manually move the CanoScan Photoshop plugin into /Applications/Adobe Photoshop CS3/Plug-ins. 3) I had to run Photoshop under Rosetta, the PowerPC emulation layer in Mac OS X for Intel Macs, because Canon's drivers do not yet run directly on the Intel hardware.

To run Photoshop under Rosetta, find /Applications/Adobe Photoshop CS3/Adobe Photoshop CS3, right-click (or control-click) on it, select Get Info. In the panel that opens, check the "Open using Rosetta" checkbox. From now on, Photoshop will open under the (slower) Rosetta PowerPC emulator. The loading screen (with the logo and the status messages) will say "Running under Rosetta".

Conkeror is a keyboard-driven Mozilla-based web browser, "no compromises," with a focus on Emacs work-alike keyboard commands and programmability.

July 9, 2007

JavaScript and CSS for iPhone web apps that look like native apps. The JavaScript claims to support the swipe motion, not sure how it manages that.

It appears iPhone's RSS reader doesn't like feeds with empty titles. Like mine. An item without a title cannot be clicked. Though I like the little "blub" animation you get when you try to double-tap on something that isn't tap-able.

I had thought Movable Type 3 was helping out by faking a title with the first few words of an entry. I'm not sure if that was ever the case, but MT 4 is definitely leaving the field blank. Other aspects of the MT4 user interface are distinctly unhelpful when entries don't have titles. Are titleless weblogs a dying breed? Do I really have to conjure up a self-important title for every little thing I want to mention on my blog?

July 6, 2007

Apple's official iPhone developer site. Features an embarrassing use of the phrase "Web 2.0," as well as some good information on optimizing web sites and building web applications for the iPhone.

Danny Goodman, author of at least two must-have books on web development, has iPhone development notes and a little page where he'll be posting his experiments. All the more admirable for its modesty.

Gems for the iPhone, a game.

Telekinesis, from the author of Quicksilver, runs a small web server on your Mac that delivers a nice menu of options to your iPhone, as a sort of "iPhone remote" for your computer. It's just a demo (possibly security problem), but it's a cool idea.

Wlt Mossberg on iPhone accessories and "software" (web apps). Walt calls out a Sudoku game and a movie times lookup site as two early decent examples.

iPhoneWidgetList.com, a decent list. iPhoneApplicationList.com is ugly and has pretty much the same stuff, but it's another list.

July 4, 2007

iPhone development secrets revealed in a pre-launch leak. Some interesting info on Safari run limits, like 5 seconds max of JavaScript.

Morfik Builds First iPhone Development Tool. I entirely understand the desire to be "first" for anything related to the iPhone, not just to capitalize off of the launch, but to build momentum for a product and be one step ahead of competitors. Developing an app based on speculation and rumor about a platform you can't test with is better than not developing an app at all. If your app is completely broken on launch day, it'll take you less time to fix it than it will someone else to build it from scratch. Nevertheless, I think I'll wait a few weeks before taking claims about development toolkits seriously.

37 Signals Ta-da lists for iPhone.

Mocking Microsoft Surface.

July 3, 2007

Google Video works on iPhone. Select the "Download iPod video" option, and it buffers straight into the QuickTime player. Yes!

Key Washer, a short film from Coudal Partners.

Cute bug in iPhone's calculator.

July 2, 2007

iPhone Bits

So I got an iPhone after all. Thanks to Apple's inventory tracker, I noticed the University Village Apple store would have some on Saturday morning. There weren't many customers there at 9am on Saturday, and the few that were there were bouncing—as in up and down—out of the store in disbelief that they got iPhones. I scored an 8GB for myself and one for my wife, and as the guy handed them to me, another guy radioed to the floor staff that they just ran out. Based on other reports, they may have had more deliveries throughout the day. This weekend was one damned impressive show of retail coordination, at least by Apple.

I'll spare the review-every-feature bit that everyone else is doing. It's awesome, you should get one.

I do have some minor points that I'll mention because they interest me:

Networking

  • Before the launch, many were complaining about the EDGE data network being very slow, including all of the major hands-on early reviews. Rumors of AT&T beefing up the network in the past week notwithstanding, I've concluded that only people who have experienced faster cell data networks like 3G will really notice. Me, I'm coming from the Stone Age before there was cellular data. It's slower than wi-fi, sure, but I was expecting a terrible experience with EDGE, and so was satisfied when I actually tried it. Update: I think I'm going to eat these words.

    I wouldn't YouTube on it, and I might not browse casually on it, but I can't imagine it'd discourage me from using it for reference. Maybe experience will change my mind, but it's not a deal breaker simply in principle, and early testing indicates it may not be an issue for me, personally. If 3G truly is more battery intensive as Apple claims it is (their reason for not using it), I'd take extra battery life over faster cell data.

    Point taken, however, that choosing an older technology for cell data means Apple will probably need to focus on getting 3G working in the near future to stay competitive. Perhaps that increases the likelihood that the 2nd-gen iPhone will come out in the next 12 months, and will have 3G capability. Perhaps that means it's sensible for some people in the market for an iPhone to live without one until that happens. For me, cell data is a tertiary feature, and everything else improves my life so dramatically that I wouldn't have regrets if a new 3G-network iPhone came out 6 months from now.

  • I was worried AT&T coverage would be worse than Verizon. So far, it's about the same. I get 1 bar in my basement. I haven't gone to the office yet. Update: 4 bars in the office.

  • Amusingly, AT&T's user agreement expressly forbids conference calls. You can only use the phone for "conversations between two people," or somesuch. That's funny, because the conference calling feature is one of the first things that Steve Jobs demoed back in January. (Sorry, I lost my screenshot, you'll have to find it yourself.)

The Web

  • iPhone's version of the Safari web browser is mostly fantastic, especially the double-tap zoom-to-a-column bit. Genius, works everywhere, and there's always manual pinch-zoom when it doesn't. When zoomed to a column, there's a little bit of give if your finger slips to the side while scrolling down, so you don't lose your place. It stays lined up in the column unless you intentionally push it out.

  • iPhone's Safari has no Flash or Java, but it has QuickTime. Any web site with a direct link to an MP3 audio file or QuickTime movie can buffer it in and play it. That's a big deal, and I wasn't expecting it. It can't download or save files, and you can't leave the browser while a media file is playing (like you can with iPod audio), but you can leave the media file sitting in the browser while using other apps on the phone.

  • Safari has no cache, so pages require reloading far more often than is typical. This makes it annoying to set up a page for reference, such as a bus schedule. This is where EDGE will annoy me most, probably.

  • iPhone's Safari doesn't like the Gmail web interface. As of yesterday, Gmail serves the same rich text editor to iPhone as to Safari 3, and iPhone doesn't like newfangled rich text areas at all. I've started iPhone's built-in stopwatch to see how long it takes Gmail to start serving a plain textarea to iPhones.

  • Sadly, Safari doesn't like Movable Type 4's text editor, either. I guess it's time to write a plugin that replaces MT4's editor with a plain textarea when viewed from an iPhone.

  • Safari scrolling is sluggish while Safari is loading a page. it's the only time I've noticed where scrolling violates the iPhone's physics. In other cases, you can keep scrolling even when the redraw can't keep up with you.

Email

  • iPhone supports accessing a Gmail account with the (very good) mail application, but the support is sub-par. If you have Gmail filtering messages out of your Inbox, those messages are thrown in together with the rest on the iPhone, including unimportant messages from mailing lists and such.

    However, IMAP support is good, including folders. So I've reverted my mail set-up back to IMAP with hosting, which I had replaced with Gmail a few months ago.

  • If you're doing most of your spam blocking in your mail reader, such as with Apple Mail or SpamSieve, prepare to start deleting your spam by hand. iPhone's mailer does not have a spam blocker. I'm filtering spam on the server side (SpamAssassin on my email host), though a few still get through.

    I'm really going to miss Gmail's spam filter. I'd mostly forgotten about spam with Gmail's top notch automatic spam filtering, but now, even with SpamAssassin, a few are getting by every day. It's already starting to piss me off, and I might even be willing to give up folders and mailing lists altogether just to be able to use Gmail's filter. Guh.

  • Productivity tip: Create a "Needs Response" folder and use it to stash messages that need closer attention when you're at a full keyboard.

  • You can view image attachments on email messages, and you can send photos taken with the iPhone's camera to someone else by email. You cannot add an image from an email to the iPhone's photo library. Instead, you have to wait until you get home, detach the attachment in a mail reader, drop it into iPhoto, then add it to an album that syncs to the phone.

Music and Video

  • Podcasts are mixed into the music indexes, like artist and composer. This is unlike the iPod, which kept Podcasts separate. This is a big step backwards, and makes the music indexes difficult to use when your 8 gigs are half-music and half-podcasts, like mine are. I'll have to rely on playlists just to get around this, and maybe that's what they're assuming I'm already doing.

  • On the iPod, the "Music" indexes (sometimes?) also include video podcasts. Selecting a video podcast from one of these lists plays the audio of the file, but not the video. To play the video, you must back out to the "Video" section and find the same file there. I've always assumed this was a bug in the iPod interface, but it looks like the iPhone has a similar problem: Video podcasts show up everywhere, but unless you're looking at the "Videos" view, you'll only get audio if you try to play it. This is especially problematic in the case of the iPhone, since video podcasts show up in 8 of the 9 possible views in iPod mode, but the video will only play in 1 of them.

    I may not be stating the problem quite right. I'll need to do more testing. It might be limited to MP4 files, for instance, I'm not sure. If anyone can explain to me why this might be a feature and not a bug, I'd greatly appreciate some clarification. I can't think of a popular case where I'd want only the audio of a video file to play.

  • Unlike the iPod, you cannot drag items manually to the iPhone in iTunes. They can only sync everything, or sync one or more playlists. This is also true with photos and iPhoto albums. I immediately created a "For iPhone" playlist and a "For iPhone" photo album to get around this. I also created a "For iPhone" email folder for documents.

  • No manual item drop also means all music and video on the iPhone must exist simultaneously on your computer, but for only a few gigs, that's not as big an issue as it would be on an iPod.

  • My complaint about the video iPod not indicating which TV episodes you haven't seen is fixed in iPhone. Unwatched eps get blue dots.

  • My complaint about the video iPod's search feature being broken when looking for an album no longer applies because iPhone does not have an iPod search feature. That's not a fix.

  • The built-in speaker works for all audio, including music and videos, so it's entirely usable without headphones. One notable exception: Voicemail will not play back through the speaker, only the earpiece. That makes sense: Phone calls don't go through the speaker unless you tell it to on a call-by-call basis. But I don't see a way to tell it to play voicemail through the speaker.

  • In the usual portrait orientation, the volume buttons are on the left. The upper button turns the volume up, the lower turns it down. In the landscape orientation, the volume buttons are on the bottom. However, the meaning of the buttons doesn't change in landscape mode, so the now-left button turns the volume down, and the now-right button turns it up—the opposite of the convention used by the Mac-like volume level indicator that pops up when you adjust the volume. I bet that was a long fight in front of a whiteboard.

  • Overall, while the iPod mode of the iPhone is definitely prettier and uses the touch screen well, and the wide screen is stunning for videos, I'm very surprised it's otherwise not much of an improvement over the last video iPod. Since this is where I expected to get the most out of the leap to an iPhone, I can't help but feel a bit disappointed with this aspect of the phone.

Data Entry

  • The virtual keyboard was a complete non-issue for me, Mr. Land Before Blackberries Who Doesn't Know Any Better. Others are reporting a learning curve, but I was comfortably fast in the first hour.

  • The main text keyboard has nice audible feedback, but not all keypad-like interfaces have it.

  • As previously reported, there's no clipboard (copy and paste). As predicted, it's a pretty notable omission. Without a clipboard, there's no way to send a URL to someone by SMS or email without memorizing it and typing it manually.

  • Text entry auto-complete works well, but only for English text. It's useless (and turned off) for URLs.

  • When you select a dropdown widget on a web page, Safari presents it as a cute flick-able spinner thing. However, the spinner has a fixed width, and long menu options get middle-truncated, with no good way to see the full phrase from the spinner itself. You have to select it, then go back to the page to see it in the context of the page, assuming the page is designed to show the whole phrase once selected.

Other Features

  • iPhone can view PDFs attached to mail messages. However, unlike Safari and web pages, the PDF viewer does not rotate into the landscape orientation. For most printable PDF documents, a column of text in the portrait orientation is too small to read, so you have to zoom and flick back and forth to read sentences. That makes it mostly a failure as a PDF reader—which is a damned shame, because text at a reasonable size otherwise looks gorgeous on the high resolution screen.

  • As mentioned, the notepad is lame. The font is unappealing and not configurable. You can't put notes on the phone from another source, and the only way to get notes off is to send them by email. And it's a difficult feature to ignore, because it's the only good way to create, store and revise drafts of text on the phone, at least until I put together an iPhone-specific wiki web site. Hopefully the notepad will be integrated with the new Mail in Mac OS 10.5 Leopard, due out in October—but I'm skeptical, since Leopard Mail notes are stored on your mail server, so they can't behave as local notes very easily.

  • Lots of people are complaining about the in-set headphone jack that's inaccessible to most nicer pairs of headphones without an adapter. Me too. I have expensive headphones I keep at work for music, and they won't fit without a jack extender bit, sold separately.

  • The maps feature is amazing, a perfect marriage of multi-touch and Google Maps. The no-GPS tap-for-next-step driving directions would work better if the phone could read the directions aloud. Apple promo material on the subject always mentions that someone else is (read: should be) using the phone while you're driving.

  • Visual Voicemail is awesome, even if I don't get much voicemail. No more pressing "7" at a phone-tree menu just to listen to a message.

And lastly: It fits in my pocket. Previously I conjectured that its size would change my relationship with my cell phone/pocketwatch, since I assumed I'd have to keep it in my backpack or something. As with pretty much every iPod-like thing Apple has produced, it's much smaller in person than I assumed it would be from press photos. The screen is durable enough that I'm comfortable keeping it in a pocket with my keys, without wrapping it in a case. Instead of being an iPod that's also a phone, it's a phone that's also an iPod. And a bazillion other things I've never had before.