Monthly Archives: October 2010

Getting Things Done on Multiple Computers

Things is a great task management app. If you use a Mac and are a fan of GTD, it’s worth a look.

The problem I had initially with Things is that currently, it does not have any sort of support for sharing its library and configuration across multiple computers. This can be overcome using a Dropbox folder as an alternate library location as documented in this DropboxSync wiki. This is great but still leaves one large problem in my mind – Things only seems to write its data to disk when it quits. If you make some changes but forget to quit Things, then open it up on a different computer, you’re probably going to lose some data. I just found a potential solution to this problem: automatically quit Things any time your computer goes idle. Hopefully you haven’t already logged into another machine and launched Things before this happens, and all your data will be safe. I found a nice little open-source project that seems to handle this perfectly: ScriptSaver.

ScriptSaver configuration

ScriptSaver installs as a screensaver and lets you select an AppleScript file to automatically run any time the screensaver is activated. It also gives you an option to then launch a different screensaver after the AppleScript has been launched. A simple AppleScript to quit Things:

tell application Things
    quit
end tell

Paste that into AppleScript Editor and save it somewhere; then point ScriptSaver to that file and you should be set.

Vim, MiniBufExpl, NERDTree and the QuickFix window

Vim has been my editor of choice for many years now, but only recently have I really started tweaking and fine-tuning my configuration and plugins. I was inspired by this HackerNews thread and I now keep my vim configuration in GitHub and synchronized between all my machines. You can even check out a list of my Vim plugins. Some of my favorites, and the ones I’m writing this post about in particular, are:

  • NERDTree, a filesystem explorer
  • MiniBufExpl, an omnipresent buffer list enabling you to easily see what buffers are open and easily switch to and close them
  • Vim Ack, a plugin that provides a simple interface to the excellent Ack utility.

Life is great. Or it was, at least, until I started having strange problems with window layouts when I was waist deep in code. The first lesson I learned is that using Vim’s :bd command to close a buffer causes problems, namely that if you close the buffer in the current window, it will close the window as well. There are two fixes for this. First, after some Googling, I learned about bclose.vim. I mapped <leader>bd to run :Bclose and all was good. I later learned that MiniBufExpl included this functionality all along – simply place your cursor over a buffer in the buffer list and press “d”.

The second problem I ran into was that after using Ack to search through my project, MiniBufExpl would start opening buffers in unpredictable locations such as the NERDTree left vertical window. This was very frustrating and I was only able to get back to a sane editing environment after restarting the Vim session all together. It turns out that the problem was being caused by the way I closed the QuickFix window after browsing through the Ack search results. I was simply using :q, which is my reflex method of closing a window I don’t want around any longer. Some debugging and research shows that the QuickFix window has its rich set of commands, including an open (:copen) and close (:ccl or :cclose). Using :ccl to close my Ack results has solved this problem entirely.

Life with Vim is better than ever. If you’re a Vim user or have even considered it, I’d really recommend checking out some sample vimrc files, finding and installing some plugins you love, and most importantly keeping your configuration synchronized between all of your development machines.

UPDATE: It turns out that :ccl was not the simple fix I was hoping it would be. After using Ack, MiniBufExpl still sends buffers to the NERDTree window. HALP!

Tidy JSON for PHP

I wrote a simple PHP utility that will convert ugly, convoluted JSON into a nicer, standard format. It doesn’t perform any validation and is not optimized whatsoever – but maybe it’s just what you’re looking for. You can find it over on github: Tidy JSON.

Usage:

<?php

require 'tidyjson.php';

$json = '{"foo":"bar","baz":[1,2,5]}';
$tidy = TidyJSON::tidy($json);

?>