Mail Server Down, All Apple Mail Rules Unselected, Fix with TextMate


There I was, working on our mail server and it was off for a couple of minutes.

Restarted, went back to Apple Mail, and all my messages were piling up in my Inbox.

But I have rules for all these messages!
[Continue Reading...]

Using the Unix `find` Command to Locate Files and Stuff’em up Your Editor

When I’m working on things, sometimes I have experimental directories along the way where I don’t want to fiddle with version control, I just want to try something out, extract the working part to stick into my actual project, and throw the experiment away.

Sometimes, when I do that, I accidentally leave behind a piece of working code that just didn’t make it over the fence into the real project.

For example, I’ve been working on cloud server deployment lately and, particularly, on Fabric scripts for getting them set up just so.

I recently got back to my main project and found a little note to myself:

def aptitudeAllVCS():
    Install latest versions of all major D/VCSes
    # sudo aptitude install subversion git-core bzr mercurial

Now, I’m sure I actually had the command working at one point, so it’s in a somewhere.

to find them all, it’s a simple matter to just do a quick:

# find . -name

Yup, I’ve left around a few files. Like about 10. Now…where the heck was that finished routine?

I could try grepping around, hit or miss, but what I really want is to open them all in TextMate and look around to see what else I left around.

So, here’s a cute Unix trick I’m pleased to report works just fine with TextMate. Note, you’ll have to have installed the `mate` command line utility for this to work. If you haven’t, just go into TextMate’s preferences and install it before trying this.

# mate `find . -name`

The backticks execute the enclosed command and the output from that command are passed as command line arguments to `mate`.

And, sure as shootin’ there they all are! I found my missing code in short order and also found a couple of gems I left behind during my experiments. Yay!

There are several other ways to do this, and you might have to use one of them in some versions of *nix where command line argument length is limited. See the Wikipedia xargs entry for a few variations.

Inconsolata Font, Panic Sans Font

So, I’ve been using whatever the system provided for fonts forever. The other day, I was searching for something else and came upon this post.

If you spend a lot of time in a text editor, do yourself a favor and try Inconsolata.

Looks great, prints well, good all around.

Reading through the comments, someone mentioned Panic Sans.

I have Coda, and I could use the font in Coda, but the font didn’t show up in the font dialog in any other program.

Turns out it’s buried inside the Coda application bundle.

Go to in Finder, Right-Click->Show Package Contents, then Spotlight “Panic Sans” by file name.

Double the click and install it when it comes up in Font Book and it’ll be available everywhere.

I haven’t decided between Inconsolata and Panic Sans but I’m liking them both better than Monaco which I’ve been using for years.

Using reStructuredText with TextMate’s Browser Preview

I’m working on several open and not so open source projects in Python these days and am using Sphinx for documentation.

TextMate has a Browser Preview window with the ability to pre-process the editor contents through a script before rendering.

The Sphinx standard input format is reStructuredText as handled by Docutils.

You can install Sphinx with:

	# sudo easy_install docutils sphinx

To get TextMate to pre-process the reStructuredText properly before display, check the “Pipe text through” checkbox in the Web Preview window and put the into the textbox for the name of the script.

Picture 2.png

There will be some issues with “Unknown interpreted text role ‘data’” type things but you’ll pretty well be able to see what it’ll look like.

I may explore making this more accurate and flexible but, for now, this’ll do.

TextMate Trim Trailing Whitespace, Finally!

I’ve been using TextMate for several years now and it has always annoyed me that it doesn’t have a way of automatically trimming trailing whitespace on save.

I tried the instructions in the documentation, and found another reference to the same ruby method on another blog but they only worked once. The second time I tried to save the file, I got a ruby traceback:

OSERROR: -10000
MESSAGE: Apple event handler failed.
COMMAND: app(”/Applications/”).documents[0].save({:in=>MacTypes::Alias.path(”~/file_that_has_changed_in_textmate”)})
from /opt/local/lib/ruby/gems/1.8/gems/rb-appscript-0.5.1/lib/appscript.rb:642:in `method_missing’
from strip.rb:16:in `save_current’
from strip.rb:26

Apparently some other people did too and the blogger said he’d look into it but that was in December of 2008 and he’s never posted a solution, nor have I found one elsewhere.

Finally, I found this simpler, but less obvious way to accomplish the same thing and it works like a charm.