Auto-verify your name and email settings in git

Date Category tech

I – like many people, I assume – have a personal email address and a work email address. When I’m working in any particular git repository, one of the addresses will be more appropriate than the other. With git, you can configure your email address pretty easily on a per-repository basis:

git config ""

Unfortunately, what often happens is I forget to do this, and then one or more of my commits to the repository will have the wrong email address as the author. It was enough of an annoyance that I hacked together a git wrapper script that forces you to confirm your name and email address on every git clone or git init. (It’s also written sort of generally, so you could adapt it to hook into other git commands as well.)

For example:

$ git clone git://
Cloning into 'rails'...
remote: Counting objects: ...
remote: Compressing objects: 100% ...
remote: Total...
Resolving objects...
Resolving deltas...
Configuring author for this repository...
Author name: [Mike Mueller]
Email address: []
  [rails] git config ""

That’s it! If a value is correct, you can simply hit enter (as I did with my name), and if a value is incorrect, just type the new value (as I did for my email). These are now configured properly inside the repository (does not affect your global git configuration).

Lenovo’s miniPCI whitelist

Date Category tech

Lenovo doesn’t think you should be allowed to install any non-Lenovo wireless cards in your computer.

error message

It’s bad enough my Y500’s touchpad is borderline unusable, but for some reason I’m not allowed to replace the cheapo wireless card with one that can do 5GHz.

Congratulations Lenovo, I won’t be buying any of your products again.

Using bindfs to workaround NFS3 limits

Date Category tech

I have a pretty awesome little network storage drive made by Synology that I use for backups, large media files, and anything I may want to access across more than one computer. It has one unfortunate limitation: by default, my uid (user id) is 1026, and I can’t change it to anything below 1024 without causing problems. (discussion here)

Of course, my uid on most of my computers is 1000, the default for Debian-based Linux systems and probably many others. NFS operates on raw user ids (e.g. 1026) rather than user names (e.g. mike), which essentially requires these uids to line up on all your computers. The “correct” solution would be to change my uid on every OS I run to 1026 (what a hassle), possibly by using an LDAP server to host user accounts (total overkill for a small home network). Isn’t there some hacky solution, perhaps involving duct tape and zip ties?

It turns out there is: bindfs, a FUSE-based filesystem that supports a bunch of permissions and ownership tweaks and transformations.

more ...

Stupid Bash tricks: show git branch in your window title

Date Category tech

First, the code (add to your ~/.bash_profile):

function git-title {
    local title
    if ! title="branch: `git rev-parse --abbrev-ref HEAD 2>/dev/null`"; then
        # Not a git repository
    echo -ne "\033]2;$title\007"

export PROMPT_COMMAND="git-title"

How it works: the git-title function uses the terminal escape sequence to set your title to “branch: foo” if your current working directory is inside a git repository.

The PROMPT_COMMAND variable allows you to run a command every time bash is about to render a new prompt. I think the intent is that you can echo additional information to the terminal to make your prompt more robust, but I’m taking advantage of this hook to just make sure the title updates whenever you have potentially entered a repository, changed branch, etc.

Generate links from the command line

Date Category tech

I’m a command line junkie. Whether that’s a good or bad thing I’ll leave up to the reader. But since the reader is here, I’ll assume (s)he finds command line utilities helpful!

Lately, I’ve found myself generating short URLs for things often enough that I thought it would be nice to have a little script that generates them for me. Then I found python-bitly, an elegant little Python module that wraps the API.

Over the next couple minutes, I unceremoniously hacked that module into a script that you can kick off whenever you want a URL:

Prerequisites: python-bitly requires simplejson (or json), which you can install with: pip install simplejson. After this, register an account at, grab your username and API key from the account page, and paste them into the script (API_USERNAME and API_KEY respectively).

Example session:

(crono:~)$ ''

Short URL:

Get in the habit of quoting the URL, because a URL that contains ampersands (&) or semicolons (;) will cause problems with bash. Grab the script!

supybot-git: An IRCbot plugin for git notifications

Date Category tech

I was looking for a way to get git commit notifications in IRC, and there are several examples of bots that do this. However, being a Pythonista, if I’m going to run an IRC bot it’s going to be one written in Python. The main idea is that I figured I’d probably want to extend it, and in that case, it ought to be in a language I love.

After some investigation, I found Supybot, a robust, extensible IRC bot written in — you guessed it — Python. It has a pretty slick installation wizard to get you up and running without fiddling with any configuration files. It also ships with a robust collection of plugins, and many have written third-party plugins as well.

Since no git notification plugin existed, I went ahead and wrote one. It’s been running on my IRC server for over a year now, and I recently decided to clean it up and open source it. I present supybot-git!


more ...

Share your development server with a reverse ssh tunnel

Date Category tech

Sometimes you want to allow someone access to your development server (e.g. a Django or Rails dev server) running on port 8000 on your laptop. Unless the other person is on the same subnet as you, it’s very likely there’s a firewall between you. (Whether you’re at home, on a company LAN, or at Starbucks.)

Assuming you have access to a Linux host that is publicly accessible, this is easy to work around. I personally have a tiny virtual host that gives me remote ssh access and runs a few little services for me, so I use this host.

This is a quick and dirty way to open up access to your dev server by using ssh and a publicly accessible remote server as your proxy.

more ...

Database file storage for Django

Date Category tech

Django provides a good mechanism for handling file attachments as model fields, using the FileField and ImageField classes. These field types store the path to a file in the database, while facilitating the actual file storage on the filesystem through the Storage API. They even come with the interface widgets to handle uploads in the model admin, so it’s a simple feature to activate. But where can we store file contents?

more ...

Illuminating git workflows (or, -p is your friend)

Date Category tech

Git is a fast, lightweight, and powerful revision control system. One of its strengths is that it is built on simple primitive actions, which can be woven together to build some robust workflows. This can come in the form of third-party tools, or even in the more advanced commands available in git itself.

One such advanced workflow is offered by the -p (--patch) option that is available in several everyday git commands:

more ...