Sunday, October 28, 2007

Tasks Bundle for TextMate

I keep my To Do items in a simple text file, for lots of reasons (including the Prags advice to "Keep knowledge in text" from the Pragmatic Programmer). Because I'm a developer, I have lots of tricks to manipulate text, especially in TextMate. Thus, my to-do stuff consists of loosely categorized lists.

The other day, I found a simple but very cool TextMate bundle that provides a couple of commands and syntactic eye candy (the visual equivalent of syntactic sugar) for simple to-do lists. Now I can keep my to-do list in plain text and still get the pretty categorization and other stuff I want. More support for my contention that TextMate is the Swiss-army chain saw of Mac OS X.

Saturday, October 27, 2007

Tweaking TextMate Groovy Bundle

When using TextMate to work with Groovy code, I use the Groovy Bundle. When you run your code, the default behavior of the bundle is to popup a window and display the results in it. This can be a minor inconvenience to problems at times. For one, to quickly see the output especially during a presentation, I find the popup window annoying. Furthermore, the output may not be what you want to see. Take the example of the following Groovy code (saved in sample.groovy):

bldr = new groovy.xml.MarkupBuilder()

bldr.html {
body {

When you press Apple R to run it, the popup window shows "foo" instead of the actual HTML output.

A little tweak to the bundle can fix this problem and make things more convenient. In TextMate, go to Bundles -> Bundle Editor -> Show Bundle Editor and navigate down to the Run command under Groovy.

Change the exit_show_html to exit_show_tool_tip. Close the Bundle Editor and back in the TextMate editor, press Apple R to see the output appear as tool tip.

Buying a New Mac

Most of the people reading this already know this, but to those who don't, here's an important public service announcement. I just bought a new Mac. No, wait, that's not the announcement. The way I bought it is.

Instead of just going to the Apple site and buying it, I joined the Apple Developer Connection first with a Select Membership. This membership gives you preview software, developer tools, and some other cool stuff. It also gets you a hardware discount for 1 system per year. Aha! The membership cost me $499. But, the discount on the laptop I bought saved me around $750. Not only did I get a bunch of extra stuff for year (the ADC goodies), but it saved me money in the end. I tend to buy a new laptop every 18 months, so even with a yearly subscription to ADC, I come out exactly even with the money, and I get all the Apple software goodies to boot. Sounds like a good deal to me!

Edit in TextMate Option

A cool trick that appears in the excellent TextMate book from the Prags is the "Edit in Textmate" menu item. If you go to the TextMate sub-menu under "Bundles", you'll see an option to Install "Edit in TextMate". The ensuing popup walks you through the steps to do this. Now, in some applications (like Safari), when you go to a textbox on a web page, you can issue the added Edit | Edit in TextMate command from Safari. TextMate will pop up, and now you have the full editing power of TextMate for your entry. When you hit "save", you'll see the browser's textbox update.

What's even better is that you can make it understand custom syntax. The popup that walks you through installing this option tells you how. So, for example, I'm typing this entry in TextMate, using HTML mode, but it is being automagically saved in the entry field on Blogger. By creating a simple ".plist" file in a special place, you can create custom bundle associations based on the URL you typed in the browser. Or, if that's too much work, the first time you launch a file from a particular web page's textbox, manually set the mode and TextMate will remember it for you. This is the way I type stuff for web pages anymore.

iPhone iPod Trick

Last week I was listening to music on my iPhone when I wanted to quickly pause the music to hear the announcement at the airport gate. Sure, the quickest way I found at that time to stop was to remove the earphone from my ears! I said to myself, there's got to be a easier way to pause the music than pressing the home button (my iPhone is locked most of the time), sliding the bar, pressing iPod key and pressing stop.

Last night I discovered a feature accidentally! When the iPhone is locked, press the home button twice. While it remains locked, the iPod play music slide bar pops up. You can start/stop music, switch to next/previous song, adjust volume using slider (though I prefer using the switch on the side to adjust volume). Now I can easily and quickly pause the music and resume after the interruptions!

iPhone Keypad trick

Switching between the alphabet keys and number/symbol keys on the keypad can be a bit annoying, especially when you want to quickly insert a number or symbol and continue typing text (alphabets).

You can avoid a few extra keystrokes if you press the ".?123" key and then without releasing drag over to the number or symbol you want.

Assume you are typing an email. You want to type "Let's meet at 3." You can type the word Let, then press and hold the key ".?123" and drag over to the single quote and release. The keypad will return back to alphabets after the single quote is inserted. You can type the rest of the message and when you're ready to insert the 3, repeat the same steps this time selecting 3 before you release.

Thursday, October 25, 2007

Neal's Lint: TextExpander

I've been asked several times about the prodigious amount of "lint" I have on my menu bar (those are the little application icons to the right, in what would be the task tray in Windows). So, I'm gonna tell everyone.

First up, TextExpander. This is a key macro utility. Think live templates for your entire operating system. You save whatever text you want to type under an abbreviation and TextExpander automagically expands it for you inline. For example, I type the words "No Fluff, Just Stuff" a lot, so I have a shortcut for it. I'm genetically incapable of spelling the word "Selenium", so I have another for that. I also have chunks of command-line goodies that I used to have as bash aliases, but I got tired of fighting the single-double quote war with bash. Now, I just type the abbreviation to get this:

svn st | grep '^\?' | tr '^\?' ' ' | sed 's/[ \t]*//' | sed 's/[ ]/\\ /g' | xargs svn add
What's even better is that you can determine where you want the cursor to end up by placing a magic marker there. For my Ruby on Rails talk, I need to create a database keyed to the city I'm in, so I use this TextExpander goodie, which leaves my cursor right before "_development".

/opt/local/bin/mysqladmin5 -u root create %|_development
What's more, you can create abbreviations for stuff like dates. Life's too short to be typing the bloody date all the time, so it looks like today is 2007-10-25.

TextExpander is a great example of a "$20-ware" Mac OS X utility (see, I just typed "Mac OS X" with an abbreviation). There are some others like this (like Typinator), but I prefer TextExpander.

Monday, October 22, 2007


My 2-year old MacBook Pro's hard drive started making a really scary sound a couple of days ago anytime I try to put it to sleep (and sometimes just locks up). Bad news! But, hey, it's 2 years old, and I'm getting a new one in literally a week (and my wife is eying my current one with a scary look in her eyes).

So, I bought a replacement hard drive for it and installed it today. Turns out, it's pretty complicated (and verboten by Apple; you void your warranty if you crack your computer open). Along the way, I found this great site: iFixIt. This site walks you through each step for common upgrades, with pictures. I could have figured it out, but this site made it much easier (and let me know that I needed a Torx 6 tool before I started). A lifesaver.

Thursday, October 4, 2007

The Quicksilver Files: Emacs(!) Keybindings

As we all know, emacs is the One True Editor. And, if you've used it, you know that you spend lots of time holding down the CTRL key. Many hard-core Mac/emacs users have re-wired the CAPS-LOCK key (which is useless anyway) to be another control key, saving wear and tear on the wrist and little finger of the left hand. (This by the way can be accomplished in the Keyboard preferences pane.)

The other day I accidentally used the emacs "down one line" command (CTRL-N) while using Quicksilver to navigate the file system...and it worked! Now, I use CTRL-P (up one line) and CTRL-N all the time because it's easier when typing to not have to move to the arrow keys.

Quicksilver: wysiwyg asap