Category Archives: Programming

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);

?>

Growl Notification for Subversion

I’ve written a little shell script that can be used to poll a Subversion repository and notify you via Growl when new revisions are added.

To start using it, download svn-growlnotify from github, copy svn-growlnotify.sh somewhere so you don’t lose it, make sure it is executable (chmod +x svn-growlnotify.sh), and set up a crontab entry to run it with your repository URL:

* * * * * /path/to/svn-growlnotify.sh -s http://your.repository.url/ 1>/dev/null 2>&1

Here’s the source code:

Subversion with LDAP on Windows Vista

At 2Advanced we are using Subversion to manage project files, using LDAP for authentication on our Windows domain and Exchange server.

This system works very well, but when we switched to Windows Vista we started having intermittent issues on various workstations. TortoiseSVN, our svn client of choice, will occasionally fail with an “Unauthorized” error or other similar error message when doing a commit. We noticed that this normally happens during a longer commit, and TortoiseSVN will usually re-prompt for a username/password partway through the commit before failing. I’m not sure why, but sometimes Tortoise will use the Windows user’s credentials to access the repository, but sometimes it will prompt you to enter a username/password. In order to avoid getting the error message, you need to ensure that, if you are prompted to re-enter your username/password, you use the exact same string (matching case) that was used initially. If the strings dont’ match exactly, the commit will fail because it thinks two separate authors are sending the same commit.

I’m mostly posting this for my own reference because I keep forgetting exactly what’s causing this strange problem.

Another key when setting up SVN with LDAP on a Windows domain is to create a group for each user – including all possible permutations of that user’s username

username = DOMAIN\Username, DOMAIN\\Username, Username, DOMAIN\username, DOMAIN\\username, username

MyGroup = @username, @otherusername

[/MyClient/MyProject]
@MyGroup = rw
* =

FavTwits, a Twitter tool

FavTwits is a tool I just wrote that explores your relationships with other Twitter users through your and their use of @username tweets. Find out who you are tweeting with the most, and plot the results on a weekly activity chart.

Comments, suggestions? Let me know. Want to help me out w/ a decent design? Go for it!