Labels. They're Not Just for Forms Anymore.

Think semantically, not dogmatically. Labels can be used to describe data as well as form fields. I can’t tell you how often I’ve seen something like this:

<div id="image-info">
   <span class="label">Name:</span><span>myimage.jpg</span>
   <span class="label">Size:</span><span>5KB</span>
   <span class="label">MIME Type:</span><span>image/jpg</span>
</div>

The obvious red flag here is that the name of the class is also the name of a tag, but a lot of examples aren’t quite so obvious. Nonetheless, when labeling data, use the label tag to do it. I’ve never seen any indication that it’s incorrect in any way.

Disable the System Bell in iTerm

Spend enough time in a terminal session and eventually the system “bell” will drive you nuts. I honestly don’t remember it being this much of an issue on my old Macbook Pro, but it’s been maddening since I got my new one a few weeks ago. Because of its bookmarks feature, iTerm is my emulator of choice and there’s nothing in its preferences (I’m using Build 0.9.6.20090415) that even acknowledges a system bell exists, much less allows me to disable it. I did a clean install when I got my new machine, so maybe this is a recent change. I haven’t looked at the release history to determine why it’s not there, I can only be sure that it’s not.

In a fit of desperation this morning, I decided to scour the plist file to see if there was anything I could do at a slightly lower level to quiet my terminal sessions. Fortunately, I found an answer:

  1. Navigate to ~/Library/Preferences.
  2. Open net.sourceforge.iTerm.plist in your favorite plist file editor. I use Property List Editor.app because I have XCode installed and the app is available to me. There are other plist editors out there or you can just open the file in a text editor – it’s just an XML file with a fancy extension.
  3. Navigate the XML nodes (different editors may offer different means of drilling down) to Root > Terminals > Default > Silence Bell
  4. Click the checkbox to enable that property.
  5. Save the change.
  6. Restart iTerm.

Enjoy the silence.

MacPorts, MySQL 5 and the Launch Daemons

Update, 7/29/2009: In response to my question about this on StackOverflow, Mike Richards offered an infinitely better solution. Apparently MacPorts is effectively deprecating the mysql5 +server path in favor of a new mysql-server package. I can’t confirm this personally, but it sounds reasonable enough.

That sounds a little bit like a Harry Potter title, but the content isn’t nearly as entertaining. For the past year or two, I’ve been using a MySQL installed via MacPorts, the (pseudo-) apt repository for Mac ports (get it?) of Unix applications and utilities. MacPorts has been fantastic and I haven’t regretted the decision to move away from either OS X’s native MySQL install or from MAMP, an all-in-one solution that I had used previously. The last few times I’ve installed MySQL, though, I’ve noticed that I haven’t been able to get MySQL to start automatically when I login.

Following Chad Kieffer’s excellent tutorial for installing & configuring a MacPorts MySQL install, I would get myself to the point where I execute launchctl to load the plist file that will start MySQL automatically:

$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist

Unlike Chad, I want MySQL to start automatically. Admittedly, my work-life balance sucks; I’m more than likely doing something work-related if I’m sitting behind the keyboard. Given that, the server might as well be ready to respond, right? Except that the plist I’m trying to load…isn’t there to be loaded.

The first time that I did the install, the plist was there and loaded as expected, but the last 2 or 3 times that has not been the case. I don’t know what changed with the MacPorts bundle, but that plist simply isn’t there. Fortunately, I still have my old install around, so I faked it.

If anyone else is having the same issue, here’s how you too can fake it:

  1. Create a directory for the launch scripts.
    $ mkdir -p /opt/local/etc/LaunchDaemons/org.macports.mysql5
  2. Download the files that no longer get installed, mysql5.wrapper and org.macports.mysql5.plist. I’m making mine available since I don’t know where else to get them. Save both files to the directory you just created.
  3. Set the proper ownership and permissions.
    $ sudo chown root:wheel /opt/local/etc/LaunchDaemons/org.macports.mysql5/*
    $ sudo chmod 755 /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper
    $ sudo chmod 644 /opt/local/etc/LaunchDaemons/org.macports.mysql5/org.macports.mysql5.plist
  4. Create a soft link to the newly downloaded plist file in /Library/LaunchDaemons.
    $ cd /Library/LaunchDaemons
    $ ln -s /opt/local/etc/LaunchDaemons/org.macports.mysql5/org.macports.mysql5.plist org.macports.mysql5.plist
  5. Load the plist file, as indicated in Chad’s instructions and duplicated above. For the sake of keeping it all in one place:
    $ sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
  6. Reboot.
  7. Verify that MySQL has started.
    $ sudo ps -ef | grep mysql

You should see output that looks something like this:

    0    65     1   0   0:00.00 ??         0:00.00 /opt/local/bin/daemondo --label=mysql5 --start-cmd /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper start ; --stop-cmd /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper stop ; --restart-cmd /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper restart ; --pid=none
    0    85     1   0   0:00.01 ??         0:00.01 /bin/sh /opt/local/lib/mysql5/bin/mysqld_safe --datadir=/opt/local/var/db/mysql5 --pid-file=/opt/local/var/db/mysql5/rob17.local.pid
   74   111    85   0   0:07.48 ??         0:19.75 /opt/local/libexec/mysqld --basedir=/opt/local --datadir=/opt/local/var/db/mysql5 --user=mysql --pid-file=/opt/local/var/db/mysql5/rob17.local.pid --socket=/tmp/mysql.sock
  501  3370  3145   0   0:00.00 ttys003    0:00.00 grep mysql

If you do, then you’re golden. If you don’t, then you probably made a mistake. If the mistake is mine, please let me know in the comments and I’ll make the appropriate adjustments.

Friendly Project Names in Komodo Edit

For several years now, Eclipse has been my primary IDE. I’ve used it to write in a number of languages on a number of platforms and was more or less happy with it. In the last six months or so, the scales of justice began to tip away from more and towards less until a couple of months ago when I finally hit my breaking point. I decided that I’d had enough of trying to dedicate enough system resources to keep Eclipse happy. I’d had enough of trying to keep my installs on several machines using several operating systems synced up properly. I felt like Eclipse was taking over my life rather than making it easy.

I started looking around with only a couple of key requirements:

  1. Responsive. Not necessarily fast, just responsive.
  2. Cross platform. I’m cross-platform and I need my key software to be cross-platform too.
  3. Power user friendly. By that, mostly I mean a rich set of keyboard shortcuts and snippets.
  4. Free-ish. I’m happy to pay for good software, but I’m not willing to plunk down hundreds of dollars if there are almost-as-good options.

After trying a number of IDEs and text editors, I finally settled on Komodo Edit. It’s a text editor that’s lightweight and snappy the way that a text editor should be, but it has just enough IDE-like features to meet my minimal needs. It met all of my needs.

For me, one of the huge tipping points was that it is a project-based editor. I loved that particular metaphor once I started using Eclipse and it’s not something you see in a lot of text editors so I was happy to get that support. What I didn’t like was that, unlike Eclipse, I couldn’t enter a “friendly” name for my projects. Eclipse has its .project files and Komodo Edit has a projectname.kpf file, but in the latter there was no way to set a nice, human name for each project. Cracking open the .kpf project file showed me that it’s just an XML config file and that there’s a name attribute on the project root element, but changing that changed nothing.

I asked about this on the forum and one of the developers suggested that I enter an enhancement request. I did and, to my surprise, a patch was made available the same day – within an hour, if I recall correctly. Since doing so, the change has been rolled into the latest version (v5.1).

To give your Komodo Edit friendly project names that will show up in the project explorer:

  1. Create a project (if one isn’t already created).
  2. Open the .kpf file in a text editor.
  3. Set the value of the name attribute to the friendly value of your choice.
  4. Save, close and restart Komodo Edit.

Here’s what one of my .kpf files (scratchpad.kpf) looks like:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Komodo Project File - DO NOT EDIT -->
<project id="714c52ec-687a-0241-b5ef-eb09952b79d5" kpf_version="4" name="Scratchpad">
<preference-set idref="714c52ec-687a-0241-b5ef-eb09952b79d5">
  <boolean id="import_live">1</boolean>
</preference-set>
</project>

Clear All Growl Notifications

When IM errors occur, I have Adium’s Growl alerts set to remain onscreen until I dismiss them. Unfortunately, sometimes I accidentally leave Adium online when I go to work. When I get back home, I have a huge number of notifications waiting to tell me that my user for service X is logged in from multiple locations.

As it turns out, there’s a simple way to close all notifications at once—just hold the Option key before clicking on the first notification.

Take that AOLSystemMessage guy.