Sending commands from vim to a separate tmux pane

Sometimes I’d rather send a command to be executed on a separate shell than from inside vim. Here’s how you do it:

mkfifo /tmp/cmds

Now in one of your tmux panes run:

while :; do bash < /tmp/cmds && echo "== OK =="; done

Now make a vim mapping:

map <F4> :exe '!echo "cd ' . getcwd() . ' && make" > /tmp/cmds'<CR>:redraw<CR>

This simply sends a make command to the other pane.

Press F4 and watch it go!


This is great for build system which take a long time and you dont want to block your current vim session.

Haskell curry second argument

Two ways

(`map` [1,2,3,4]) $ \n -> ...
flip map [1,2,3,4] $ \n -> ...

Hardest part is deciding which one to use

Vim indent text objects for Coffeescript and Python

Do you write a lot of Coffeescript, Python, Jade templates, Haskell, or any other language that uses indentation? If you are like me, you may be sad to find out that your trusty ciB does not work anymore in Vim. ciB is “change inside block” which only matches inside () and {}. This is no good when we are dealing with languages like Python that use indentation instead of curly braces for block structures.

Luckily there is a plugin that adds this functionality:

Once you install this you can use vii or vai to see how it works. Use cii to change an entire indentation block.

Here’s a quick screencast to see how it works:

Good luck and happy Vimming!

Iteratee Hello World

This entire blog post is in literate Haskell, you can clone it from the gist to try it out:

git clone git:// iteratee-hello-world

This is the simplest example of an Iteratee that I could think of. It simply reads from an stdin/file Enumerator and spits it out to an stdout Iteratee. The stream is transformed to uppercase characters using an Enumeratee.

I put this together to figure out how to apply the Iteratee abstraction in everyday situations, hopefully this will serve as a jump off point for people looking to learn about Iteratees.

Using Haskell’s QuickCheck to generate random test data

QuickCheck is a random testing library written in Haskell and is typically used for fuzz testing code. The main typeclass provided by QuickCheck is the Arbitrary typeclass. When you make one of your data types an instance of this typeclass (by implementing the arbitrary function) you can generate random samples of those data types

I recently needed a way to generate a large number of Serial numbers of a specific format, QuickCheck turned out to be perfect for this.

I started out by creating a new data type representing my serial number:

data Serial = Serial String Int

The String represents a random prefix (eg. “ABC”), and the Int represents some number which could represent the order number, etc. Implementing show allows me to easily convert this data type to a string:

instance Show Serial where
  show (Serial prefix number) = prefix ++ show number

Now to generate Serials we implement Arbitrary for our Serial type:

instance Arbitrary Serial where
  arbitrary = do
    prefix <- vectorOf 3 $ elements ['A'..'Z']
    number <- choose (10000, 99999)
    return $ Serial prefix number

The magic happens during the call to arbitrary. arbitrary returns the type Gen Serial which represents a computation that generates a random Serial. Gen is a Monad, so that allows us to use do notation to build our generating computation.

The first line in our do block is a call to elements, which chooses a single element out of a list of elements. The vectorOf 3 says to apply this generator 3 times and assign it to prefix. As you can probably guess by now this generates a random string of length 3 with random characters between ‘A’ and ‘Z’.

The second line in the do block is a call to choose which chooses a single value between a range of values.

Finally we return our serial with the generated prefix and number.

We can now generate a list of random serials by using unGen:

serialGen :: Int -> [Serial]
serialGen seed = unGen arbitrary (mkStdGen seed) 9999999

Some data from this function:


Naturally you can apply this method to any data type you can think of, the Gen Monad is a great DSL for generating random test data!

The full program:

F# CSV Parsing with FParsec

I needed a .NET CSV parser for work, and since I don’t trust most .NET code I find online I wrote one in F# with FParsec!

This handles both quoted and unquoted cells. It even supports escaped characters (including commas)!

For example,

HOME_DESCRIPTION, Hello\, welcome to our site!, Bonjour\, bienvenue sur notre site

Will parse to:

  ["CODE", "EN", "FR"],
  ["HOME_DESCRIPTION", "Hello, welcome to our site!", "Bonjour, bienvenue sur notre site"]

You can even mix them if you want:

"CODE", "EN", "FR"
HOME_DESCRIPTION, Hello\, welcome to our site!, "Bonjour, bienvenue sur notre site"

This will parse to the same thing

It even handles cases where there are quotes inside unquoted cells!

Since we’re using FParsec, if the parse fails it will tell you exactly where and why. Here is an excerpt from one of my test cases that fails when there’s a comma missing:

Error in Ln: 4 Col: 19
Expecting: end of file, newline or ','

Have fun!

Irssi notifications with

Ever wanted more powerful notification capabilities inside of irssi?

If you use irssi and you’re like me, you might have a setup similar to this:

  • irssi on home desktop or server inside of a screen session

This is an ideal setup for me since it allows me to shell into my box at home from various locations. A lot of the time the IRC ports are blocked so ssh + screen + irssi gets around that.

One things sorely lacking is message notifications, specifically when your name is mentioned in the channel or when you receive a private message. There are a few plugins that will email you alerts when you’re away but what I was really looking for was growl notifications.

The best service for doing this is something called Not only will it forward growl notifications to desktop clients, but you also have the option to send prowl notifications to your iOS devices, jabber, sms, and email.

How irssi + works

I’ve put together a small irssi script that does just this! listens for private messages and channel mentions, and forwards them to your account!

  1. The first thing you’ll need to do is get an account at

  2. Download the script from the github page

  3. Install the script to ~/.irssi/scripts/autorun

  4. Run the command /set notify_io_api_key <key> where <key> is your api key (retrieved from the settings panel on the website)

  5. Run the command /set notify_io_email <email> with the email registered with the account

That’s it! Enjoy.

Static Factorial in Clay

Meta programming in Clay is very intuitive:

Here’s the same thing in C++:

The cool thing about this is that you can have both runtime and compile time (static) overloads at the same time.

Have a function that you can turn into a compile time operation? Simply add an overload that takes a static value and do your custom logic.

Compile-time meta programming is truly a first class citizen in Clay.

Thanks to qx on #clay for showing me how to do this

Print-friendly lesswrong Sequences

I have started to convert The Sequences over at to print and ebook ready formats such as epub and PDF. You can get them on my github page:

Interesting Minecraft-clone Projects

I’ve been following Minecraft development for awhile, and I’ve always wondered what future Minecraft games might look like. Surprisingly, there already seems to be a couple working clones and bunch more in development. I wouldn’t be surprised if major game development are starting to work on their own Minecraft games as well, who knows!

Manic Digger

Manic Digger

Manic Digger is a working Minecraft clone written in C# using (I’m assuming) XNA. It keeps the blocky style from the original minecraft and some new features. According to their wiki:

  • New blocks (Natrium, Platinum, Lead to name a few)
  • New monsters (Dragons, imps, giants!)
  • Monster editor

It’s also open source, if you’re the kind of guy who likes hacking on open source C# projects. It only works in Windows at the moment.



meinKraft is a small Minecraft-like tech demo written in C. He says the source is included but I didn’t see it in the zip.


A C++ Minecraft project! This one looks interesting. RogueMiner looks to be a Minecraft clone built from scratch using SDL and OpenGL.

Ogre3D projects

There have been some interesting discussions on the Ogre3D forums about new efficient Minecraft implementations. A person named Kojack put together a pretty cool tech demo using various shader implementations:


I highly recommend you read his posts on the Ogre3D forums if you’re interested in this stuff.


Can’t say much about this one, it looks to be the most polished Minecraft clone to date. It’s currently in private beta.


Most of the clones I found seem to be trying to emulate Minecraft as close as possible. While this is great and all, what I’d really like to see in future Minecraft titles are:

  • More realistic, immersive gameplay
  • MMO?
  • Infinite depth, harder difficulty the further down you go.
  • Physics?

There’s so many things that you could do in a game like this, I look forward to future projects. I may even take a stab at it.