Baptiste Fontaine’s Blog

How to Speed-up Vim’s Command-T Plugin

Command-T is a wonderful Vim plugin which allows you to open files with a minimal number of keystrokes. It’s really handy in a large codebase where you only have to type <leader>t, then a couple letters and press enter to open your file. It’s based on a fuzzy matching, which let you skip letters without worrying.

I recently installed the plugin on another machine and noticed it was really low: I had to wait a couple seconds to get the files list everytime. My computer has 8GB RAM so the problem wasn’t there.

How to Remember the Difference Between Conj and Cons in Clojure

When I started writing Clojure, I couldn’t memorize the difference between conj and cons and always used one instead of the another. Their name are similar, but cons is used to add an element at the beginning of a vector, while conj is used to add an element at the end of it. How can one memorize this? I found a mnemonic trick over the time that helps me remember this. Here is it:

Fixing Gnuplot-py’s “unknown Aqua Terminal” Warning on OSX

When plotting with gnuplot-py on OSX, I got an annoying warning saying that terminal aqua is unknown or ambiguous, even when I use a different terminal (e.g. postscript). This terminal doesn’t exist on my Gnuplot installation (4.6.3). In fact, gnuplot-py uses slightly different files depending on your platform. OSX’s one is exactly the same as other UNIX-flavored OSes but its default terminal is aqua. There are two ways to fix the warning, a hacky one I used before this blog post, and a clean one I discovered while writting this post. Hope this help!

Using Coveralls With Clojure

Coveralls is a service that keep track of your tests coverage for you. It can notifies you when your coverage decreases under a custom threshold, and their bot comments on pull requests to report their tests coverage. Like Travis-CI, it allows you to add a badge to your readme with an up-to-date tests coverage percentage.

If you already test your GitHub projects with a CI server like Travis, it’s very easy to add Coveralls to your workflow. Unfortunately, they have a library for Ruby, a couple user-provided libraries for other languages such as PHP, Java and Python, but nothing for Clojure. Fortunately, they provide an API for unsupported languages like Clojure. Here is how to use it.

Function-level Black-box Testing

Black-box testing is a method of software testing that examines the functionality of an application (e.g. what the software does) without peering into its internal structures or workings (Wikipedia). While it’s usually done at a system level, I think the most obvious place it should be used is at the function level. It’s even more efficient if you write tests for someone else’s code.
Here is how I write unit tests for functions.

Local .vimrc’s

I discovered a great feature in Vim today. While we generally use the same Vim settings everywhere, we sometimes (have to) contribute to projects with a coding style different of ours, and because nobody wants to edit their .vimrc everytime to switch between configurations, Vim allows you to have per project .vimrc’s.

Use a Custom Tld for Local Development

In this post, we’ll create a custom TLD for local development, and configure Apache to work with that. It’ll allow you to work on your local version of mysuperwebsite.com with the local domain mysuperwebsite.dev, with the exact same URLs, except that little .com which is replaced by .dev.

Get RFCs in Your Terminal

When working with Internet protocols, we have to read RFCs a lot. They can be found on the Web, but it’s better to have them directly in the terminal. Ubuntu provide some packages to have them offline, but if you aren’t a sudoer, you can’t install them with apt-get. So I needed a little script to fetch RFCs from IETF’s website and read them locally.

Get the Urban Dictionary in Your Terminal

The Urban Dictionary website is pretty useful when one wants to know the meaning of any familiar or slang word. Users can write definitions for any words, and upvote or downvote them. Unfortunately, the website doesn’t have a public API, and I couldn’t find a command-line tool for it. So I wrote one.