Web 2.0, according to the SF Chronicle

Monday, January 30

From the San Francisco Chronicle, this is probably the first mention of Web 2.0 I’ve seen in mainstream media: So, what’s next? Why, Web 2.0 naturally is Verne Kopytoff’s attempt to explain the Web 2.0 to regular people.

Some parts were especially amusing, including the following reference to AJAX:

Ajax, a kind of software that makes Web site features faster to use, is a staple of Web 2.0 companies.

I’ve been wondering when the general public was going to be informed about the web’s new version number. If there is indeed a revolution raging, nobody’s told my dad.

Two Things I didn't know about TextMate

Friday, January 20

The TextMate Manual was recently published and I made some time today to go through it. I always seem to work with an editor for far too long before I realize there’s some handy shortcut I’ve been ignorant of. Anyways, an editor like TextMate is full of these hidden gems—clever macros and commands that make life easier. Here are a couple of things I didn’t know.

CMD-T: Go to File

Until this moment, I had no idea the ‘Go to File’ window existed, let alone its CMD-T shortcut. I hate taking my hands off the keyboard to click on files in the project drawer, so the ‘Go to File’ command makes my day. It opens a window containing a flat list of all the files in your project, with a live, abbreviation-enabled search.

[This] window lists all text files in the project sorted after last use, which means pressing return will open (or go to) the last file you worked on. So using it this way makes for easy last-recently-used switching.

From 2.3 Moving Between Files

CMD-Return: Save some keystrokes

You know how when you type an auto-paried character, like a quote, or a brace, your caret ends up in between the pair? Well, this is generally useful, but really sucks when you’re at the end of a line because you have to move all the way to the end before making a carriage return. You can imagine my excitement when I learned about CMD-Return. CMD-Return will move to the end of the line and insert a newline for you. How great is that?

From 4.1 Auto-Paired Characters

Comfortable, Color CLI

Friday, January 13

Torn as I now am between my iMac and my laptop (Ubuntu linux), I invariably find myself using both: OS X at the desk, Ubuntu on the couch. My brief tenure in linuxland taught me to embrace the CLI (Command Line Interface), and upon returning to mactopia, I find I use the CLI almost exclusively. (That and VIM. I decided early on that rather than waste time learning yet another GUI editor, I’d take the opportunity to learn VIM and promptly fell in love. I’m typing this in VIM right now, even as my TextMate icon stares up at me from the dock.) For me, Linux and Darwin are sufficiently similar that I’m at home on either and I’ve come to respect their subtle differences.

That said, one thing I really liked about the default bash terminal in Ubuntu was its color, so I sought to bring this feature over to my OS X Terminal. Using ls with color makes things faster—colors can tell you about files in ways that ls -F never could. To enable this in OS X (bash), you’ll need to add some options to your .profile:

export CLICOLOR=1
export TERM=xterm-color

The first line turns on color, and the second ensures that your terminal is declared as color capable. While this will work as advertised, it won’t necessarily look very good if you use a dark background. By default, directories are listed in blue, and while this looks good in Ubuntu it’s just too dark on the Mac. For those of us who rock a black background, you might want to change the ls colors.

export LSCOLORS=gxfxcxdxbxegedabagacad  # cyan directories

In the above example, I’m using cyan for directories; this is a fair compromise and looks nice in both OS X and Ubuntu. If you want to know about each of the color codes above, they’re listed in the ls manual (man ls).

For the complete linux effect on OS X, a green prompt will also be necessary. Without getting in the sordid details of customizing your prompt (it’s a long and arduous tale that I’ll save for another article), I offer this:

export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\$ '

When we put it all together, we get a comfortable and portable CLI that looks quite nice, no matter where you’re logging in from.

# colors
export CLICOLOR=1
export TERM=xterm-color
export LSCOLORS=gxgxcxdxbxegedabagacad  # cyan directories
export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\$ '

MacBook: the first intel macs are out

Tuesday, January 10

It’s arrived: the new MacBook Pro. And it looks about as badass as its product page.

You’ve dreamed about it long enough. Now it has a name: MacBook Pro. Powered by a dual-core Intel engine. Up to four times the speed of the PowerBook G4. Eight times the graphics bandwidth. With built-in iSight for instant video conferencing on the move. And Front Row with Apple Remote to dazzle everyone in the room. Wait no more.

Apple claims the 1.83GHz MacBook is 4x faster than the Powerbook G4. And it comes fully loaded with a 256MB ATI Mobility Radeon X1600 and 1GB of RAM. The display has a resolution of 1440×900 (we saw this in the last generation Powerbooks too), but is apparently 67% brighter.

Having convinced myself that I need a new computer (my iMac case has tiny little cracks in the clear plastic that keep me up at night) I have been waiting for word on the Powerbook’s successor. Now I can bequeath the iMac to my wife (who will surely welcome it over her sluggish PowerMac G4) and return to the land of laptops where (I must admit) I’m much more at home. I’ve concluded I just don’t like working at a desk.

Update: Engadget has a hands-on first take with some photos. See Hands-on with the MacBook Pro

Sweeping strategies in Rails

Monday, January 09

The caching mechanism in Rails is delightfully simple: add a caches_page declaration for a given controller action and a static copy of the rendered view is automatically saved to disk. Subsequent requests for the page are served without invoking Rails. As many have noted, sweeping the cache can be a pain.

Enter two recent articles that discuss some practical sweeping strategies: Lazily sweeping the whole Rails page cache from Thijs van der Vossen, and Rick Olson’s Referenced Page Caching

Both strategies advocate relocating the cache directory to a subdirectory of public (i.e. public/cache), a brilliantly simple solution that makes complete expiry of the cache trivial. I especially like Thijs’ laziness: FileUtils.rm_r(self.page_cache_directory)