The Soapbox

Rants on science and technology

Mercurial Queues, or MQ for short, is one of, if not the most useful Mercurial extension, and is something I cannot program without.

What is it?

You should read the article about it, but the idea is that besides the regular version control your code is under (you are using SCM, right?), MQ helps you manage a set of patches on top of it. So that you can be working on several different ideas at a time, and commit to the main repo only when a coherent unit is finished. This helps you organize your commits much better, and thus keeps your repo history in a cleaner state.

This is the basic idea behind the Git index (and the stash feature), with the difference that it only allows you a single level of buffer, while with MQ you’re limited only by the number of patches you’re using.

I should point out that this idea is not new or exclusive to Mercurial. Patch queues and software to manage them have been used for many years in software development. There exists an analog in just about every VCS out there. For example:

  • Quilt is a generic patch manager for any VCS.
  • Guilt is a Git plugin built on top of Quilt.
  • StGit is another Git patch management tool which stores patches as Git commit objects.

Read More »

After a long blogging hiatus, and my original site shutting down after I decided not to renew my domain, I started working on a different approach to blogging to what I was using before.

Let’s go through a bit of history here:

  • ~2007: First attempt using Drupal and hosted on A Small Orange.
  • 2008: Switched to Wordpress, still on ASO.
  • 2008: Still Wordpress, but switched to Webfaction.
  • 2013: Flatline…

Until now!

I’m proud to say that the site is running on 100% more Python, mostly based on Flask-FlatPages, which gives me much more flexibility than before. The theme is custom built by myself, and as you can tell, I’m not the greatest designer, but I like the way it looks for now.

There are still some quirks I need to resolve, but I decided to publish it anyway. So if you spot any issues, I’m probably working on it (though let me know anyways)!

Besides the engine and domain change, I also decided to change hosts. This time to Digital Ocean. WebFaction was starting to feel restricting and I’ve wanted my own VPS for a while now. Digital Ocean attracted me with their price and features (SSD!), and so far I’ve been very pleased with their service.

So, to both of you reading this: expect more content here soon. I’ll try to update more frequently than before, with less fluff posts (we have the social networks for that!).


I was recently watching one of my favorite TV shows and decided to make a GIF from a particular scene… for the lulz.

I’ve never really done this before, and I knew I could accomplish it with VLC and Photoshop, or some such. But my geeky side prevailed and I decided to use ffmpeg and ImageMagick, both outstanding open-source apps.

So, let’s get WEIRD!

First off, you need to find out some basic info about your video file.

You can find the framerate with ffmpeg itself using:

$ ffmpeg -i *S03E01*.mkv

…or with your favorite video player, which you’ll also need to use to find out the precise time and number of frames you want to extract. In my case this was 23.98, 00:05:07.015 and 28.

Once you have that info, you pass it to ffmpeg with the following command:

$ ffmpeg -i *S03E01*.mkv -r 23.98 -an -sameq -vframes 28 -ss 00:05:07.015 ew-%02d.jpg

This will create 28 JPG files in your current directory, all neatly numbered.

Then you run the following ImageMagick command to resize, crop and convert your extracted images to GIF:

$ convert -resize 47% -gravity east -chop 210x +repage -dither none -coalesce -layers optimizeplus -matte -depth 8 -colors 128 -loop 0 -delay 1x24 *.jpg anim.gif

The actual values for -resize and -chop were found out through trial and error in order to make the GIF be under 2MB, so it could be uploaded to imgur. So make sure you play with these values for your particular video and needs.

And here’s the final result!

I’ve been using Grooveshark since 2008 and haven’t had much complaints after moving to their premium service a year later. But recently, the disorganization (duplicate tracks, mislabeled or wrongly tagged tracks), plus the very low quality mobile streaming (even on WiFi) has left me searching for an alternative.

Enter MOG.

While definitely not a newcomer to music streaming services, coming from a music-oriented blog and community way back from 2005, MOG is nowadays probably one of the largest industry-backed services of its kind. Their claimed library of 11 million songs is impressive, and from a quick search, I could easily find all but the highly obscure artists or those difficult to license (no Metallica or The Beatles here, but it has some missing from Grooveshark: Pink Floyd, The Chemical Brothers and Korn).

The first thing I noticed is how well organized the music is. No duplicates here, everything is nicely tagged, all albums have high-quality covers and everything is easily browseable.

The other impressive thing when compared to Grooveshark is the high bitrate streams and downloads. Everything is 256-320 kbps, and you can really tell the difference from Grooveshark’s (probably) 96-128 kbps. The albums are flawlessly ripped, no skipping or cut up tracks, the quality is really top notch from what I’ve seen so far, be it on mobile or the site.

Speaking of mobile, the app is highly streamlined with very little eye candy, contrary to Grooveshark’s more intuitive mobile client.

The asking price of $5/mo for web/STB/TV/Roku/Boxee/Sonos streaming is very reasonable. For $10/mo, though, you get the mobile (iOS/Android) clients, which is just $1 more than Grooveshark’s Anywhere. You can sign up for a 14-day trial here.

All in all, I’m very impressed so far with MOG and will be putting up my final impressions once my trial is over.

I happen to enjoy using it much more than shell scripts for anything that needs a more complex logic or real data structures. It gives me better portability, a ridiculously large selection of easily installable modules, and the freedom to scale should I need it.

I could say this for Python or Ruby as well (and I certainly prefer using them if given the choice), but Perl is much widely adopted across many different platforms (perhaps because of its age). You can be almost certain a modern server will have at least Perl 5, while you can’t say the same for Python, and good luck with Ruby.

Sure, you can shoot yourself in the foot easily with Perl, and TMTOWTDI causes confusion, but the beauty of Perl is that you can easily start with the features you’re comfortable with and use everything else as you need it. Ruby also has this distinction.

A common complaint I hear is that Perl code is difficult to maintain.

I can say this for any language. If the author wasn’t a sadist that purposely obfuscated code, and the code is well documented, there’s no reason why Perl code would be any less maintainable than any other language.

AWK would also be a good choice for some things, but Perl has a more standard syntax, is of more general use and is (I think) comparable in speed.

Recently I’ve been interested in purchasing a new car radio, as my current one has no auxiliary input and is basically a rudimentary device. Thinking about different options, and even considering a carputer project, it occurred to me that there should be a car radio that would be powered by your smartphone and allowed seamless integration with the car.

Read More »

So after a recent Arch upgrade, Samba mysteriously stopped working, and I really wasn’t in the mood to troubleshoot what broke it. I have always disliked Samba (and CIFS as a whole), so was pleasantly surprised to learn an NFS client has been shipping with Windows for like, ever, now.

After installing and configuring NFS in Arch (a bit more involved that I would’ve liked but not too painful), and installing the NFS client service in my Windows machine, I was able to connect and browse the share, but had no write permissions (despite it being configured as rw).

This was of course related to the awesome Unix file permissions. Depending on the UID/GID the client authenticates with, it will have the permissions as specified by each file’s mode. By default, the Windows NFS client connects with -2/-2, which maps to ‘other’ on the Linux side, so you’d need write permission for ‘other’ on every file. This is a problem unless all your files have it, but mine default to 644 (read-only for ‘other’), which is a pretty common and safe mode.

There’s a couple of ways I tried to fix this, and only the last one worked.

The NFS server has the ability to force all anonymous connections to a specific UID/GID. This is done using the following share options:


What all_squash does is basically treat all clients as anonymous, whereas anonuid and anongid assign a single UID/GID for these anonymous connections. For some reason, this didn’t work for me. I’m guessing it has something to do with the Windows client, but I still couldn’t write to the share.

Luckily, I found the following tip/hack:

  • Start Registry Editor (regedit.exe)

  • Locate HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default

  • Create two DWORD values named AnonymousUid and AnonymousGid

  • Set these values to the UID and GID you would like this NFS client to use

  • Restart your Client for NFS service using the Microsoft Services for NFS MMC snap-in

This simply forces the client to identify with your chosen UID/GID (instead of the default -2/-2), which is basically what I needed. You could remove the all_squash and the other options, but I left them there anyway, it works great. This tip is for Vista, but it also works on 7, not sure on previous Windows versions.

Now I have access to all my Linux files from Windows again, and without bloody Samba. The only thing I’m still figuring out is how to automatically connect to the share at Windows startup. I’ll update this post when I have a reliable method.


In case you don’t know, AutoHotkey is an awesome GUI automation tool for Windows. I use it all the time to speed up monotonous stuff I usually do by hand. I’m not that proficient with the language, so it takes me a lot of searching and experimentation to get it to do what I want, but I just finished creating a new snippet of usefulness and decided to share it here.

In the following example I get the selected text and transform it so that it can be used in an SQL list (used as values inside an IN clause). For example, selecting the following text:


… and pressing Alt+G, converts it to:


Which saves me a few seconds of copy/pasting the text in an editor and applying the regex manually. Did I mention I LOVE AHK? :-)

Here’s the snippet:

   tmp = %ClipboardAll%    ; save clipboard
   Clipboard := ""         ; clear clipboard
   Send, ^c                ; simulate Ctrl+C (=selection in clipboard)
   ClipWait, 1             ; wait until clipboard contains data
   selection = %Clipboard% ; save the content of the clipboard
   Clipboard = %tmp%       ; restore old content of the clipboard
   return selection

; Enclose each line in '$1',
; Used to format a list of strings for SQL
Alt & G::
  selection := GetSelectedText()
  newStr := RegExReplace(selection, "m)^(.*)$", "'$1',")
  StringReplace, newStr, newStr, `r`n, `r, All   ; fix newline
  SendInput %newStr%{Backspace}                  ; paste everything and delete last comma

I have already written a bit about the demoscene and chiptune in the past, but I had to write a separate post about these two tunes I keep coming back to whenever I need a fair dose of nostalgia and optimism.

I haven’t heard a lot of chiptune, nor do I know much about the scene, but these are by far my favorite tunes from that culture. If someone knows others that are equal gems as these, please share.

Now, the IT and XM files are in module format that (unless someone converted them afterwards) are the original files as exported by the artist’s software, meaning they’re the lossless versions you should be listening to. In order to do so, I recommend downloading foobar2000 and the excellent foo_dumb plugin, or use any module file player of your choice.

Some years ago I converted and edited both these tracks to V2 MP3s for my own amusement, and to be able to play these universally. You can download these from the links above as well. I took the liberty to loop the tunes twice, and add some fade out at the end.

You can also find these files on (the original installer is found here) where you can download these and more sound files, and I definitely recommend you checking out that site as well as

A little bit of background regarding these two files…

They both come from a game rip installer circa the year 2000 of the game THPS2, from the infamous warez group Class. The installer itself is much more memorable to me because of the quality of this music than the game ever was. ^_^ Both of the authors were actually members of other groups: Zoef of Fairlight, a much more senior group still active today in some way or another, and DataChild of Share and Enjoy, an excellent music-only group, AFAIA.

So there you have it… Enjoy, let me know what you think in the comments, and please share any other gems like these.

Politics doesn’t interest me at all, but I was just listening to Manu Chao’s Clandestino for the umpteenth time, and this quote from “Welcome to Tijuana” rang a bell as much now as anytime I’ve heard it before.

Nuestra lucha es por el respeto a nuestro derecho a gobernar y gobernarnos, y el mal gobierno impone a los más la ley de los menos.

Nuestra lucha es por la libertad para el pensamiento y el caminar, y el mal gobierno pone cárceles y tumbas.

Nuestra lucha es por la justicia, y el mal gobierno se llena de criminales y asesinos.

Techo, tierra, trabajo, pan salud, educación, independencia, democracia, libertad… Éstas fueron nuestras demandas en la larga noche de los 500 años. Éstas son, hoy, nuestras exigencias.

The quote is an excerpt of the “Manifiesto zapatista en Náhuatl”, of which you can read the full version here.

Here’s a great Manu Chao poster with the quote: