haskell
A simple music library browser using dmenu
On 17, May 2016 | No Comments | In code | By admin
I have a large music library, and all programs that I have tried (in Linux) are sluggish. Mostly I just want to select an album to play, and I want to do that quickly. I cooked up my own solution, a Haskell script that launches dmenu to select an album. It is instantaneous, I can get to an album from anywhere in the system in 3 or 4 seconds (I have the script assigned to cmd-alt-m). It requires generating a text file with all the music folders in the disk which should be updated regularly, I have also created a Haskell script for this. It uses the excellent turtle Haskell package for scripting. It also keeps track of the history of played albums.
script for generating list of folders:
toggle lcd backlight linux
On 10, Mar 2016 | No Comments | In code, linux | By admin
When working on music it’s nice to toggle the lcd backlight with a key press:
Making a tiny web server in Haskell
On 09, Mar 2014 | No Comments | In code | By admin
Recently I have been having fun in my spare time discovering how to implement a tcp server / client in Haskell. It’s incredible easy to implement just a couple of lines of code. Building on top of that, today I learned how to implement an http server. Turns out http is just sending and receiving text (and other content) over tcp. As a nice application, I quickly coded a program that given a port and file path starts a web server which will display a webpage with a link to the file which when clicked sends the file to the client’s browser. This is very handy to quickly transfer a file to a friend over a local network. I was impressed with how little code it was needed to implement this in Haskell, and how high level and elegant that code was.
ubuntu and btrfs backups using send receive
On 30, Jun 2013 | No Comments | In code | By admin
Since I’ve moved to Ubuntu Linux I’ve been mostly using btrfs for all my filesystems. btrfs makes it super easy to create snapshots of subvolumes and to go back in time to a previous snapshot (just use mv). I always create a snapshot before updating packages so that I can easily go back if something breaks.
I’ve been using Back In Time for my backups but this app takes more then 30 minutes for every single backup, no matter how small, and does a lot of disk I/O in the process, even just to transfer 2 or 3 files (I think that happens because it’s creating hard links). I’ve recently discovered that btrfs has a send / receive functionality which allows sending a snapshot to another btrfs partition and it also allows to send just the diff between snapshots. Using btrfs send and btrfs receive it’s possible to setup a backup process entirely based on btrfs.
I found that btrfs send / receive is broken in the current ubuntu version 13.04, so I had to uninstall the btrfs-tools package and compile from the source in git of btrfs-progs. After that btrfs send and btrfs receive seem to work fine. I’m now doing all my backups with btrfs which on average now take just one or two minutes, much much faster then with Back In Time.
Finally I created a Haskell Shelly script to automate my backup procedure. It’s still very incomplete, but I put here in case it’s useful to others. Be careful with this script, it might delete snapshots that it shouldn’t so use at your own risk !