Hello, Pelican!

Date Category meta

*tap tap tap* This thing on?

Hello! The blog has been relocated from tumblr to my own host. This site is now generated by a static site generator called Pelican (hey guys, fix your SSL cert pls).

Why move? I chose tumblr because it was supposed to be simple and relieve me of the hassle of maintaining a server. However:

more ...

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 user.email "my.email@example.com"

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://github.com/rails/rails
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: [mike@example_home.com] mike@example_work.com
  [rails] git config user.email "mike@example_work.com"

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

World War M[eta]

Date Category books

[I’ve managed to track down one of the rare haters. Sitting on the N Judah with Mike, he gesticulates wildly, physically pounding his copy of World War Z in apparent frustration. Some of his comments may contain spoilers.]

I don’t get it. Was this supposed to be a serious attempt at a horror novel, some kind of political allegory, or something else entirely? There wasn’t a single moment of tension in the entire book, and it was so clinical in its depiction of zombie apocalypse that it was actually an effort to finish reading the damn thing.

The movie, starring Brad Pitt as a genius / super-soldier / father-of-the-year who instantly figures out what literally all the scientists in the world couldn’t, was actually better. Sure, it glossed over most of the political aspects and invented an entire story from whole cloth, but at least it had a plot, man.

more ...

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 ...

Book Review: The Signal and the Noise

Date Category books

My rating: 4 of 5 stars

I followed Nate Silver’s blog (FiveThirtyEight) closely during the run-up to election day 2012. His premise was simple: grab every public poll possible, attempt to correct for pollsters’ known biases, and produce a forecast based on the result. Somehow no one had thought to do this before. Silver simply crunched the numbers and nailed the outcomes in every state. Meanwhile, pundits, bloggers, and assorted blowhards made predictions based on nothing but gut feeling and partisan hackery, and they mostly missed the mark (often by a wide margin).

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 bit.ly 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 bit.ly API.

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

Prerequisites: python-bitly requires simplejson (or json), which you can install with: pip install simplejson. After this, register an account at bit.ly, 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:~)$ bitly.py 'http://github.com/'

Short URL: http://bit.ly/k7lifz

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 ...