## Posts

Showing posts from November, 2009

### Sorted and aggregated disk usage script

I've been asked for this script many times lately, so I'll publish it. It lists the disk usage of subdirectories in a given directory in descending order, right justified and suffixed with kilobytes or megabytes appropriately. #!/bin/sh display() {  local DIR=$1 du -sk$DIR/..?* $DIR/.[!.]*$DIR/* 2>/dev/null |   sort -n |   awk '    {     size = $1; sum += size; name =$2;     if ($1 < 1024){ printf("%9ik %s\n",size,name); } else { printf("%9.3fM %s\n",size/1024,name); } } END{ print sum " kiB" } ' } main() { local DIR=$1  if [ "$DIR" = "" ] then display$HOME   quota  else   display $DIR fi } main "$@"

### Rapid serial visualisation for portable book reading

I've received the following link recently that I believe I have already stumbled upon earlier. Rapid Serial Visual Presentation (Wikipedia) I didn't see much perspective for it before, but I've given second thought now. Just imagine a tiny note taking device which combines the above speed reading technique with a chorded keyboard (like the DataEgg )!

### Converting between Bird-literate and plain Haskell

Literate programming is a good idea, and there exist many creative ways in which you could take advantage of it, like one described in Literate Haskell with Markdown and Syntax Highlighting . However, if you're using the text editor Geany version 0.18, you will be faced with a bug that makes it unable to interpret Bird-style literate source. As a simple fix, I provide two programs to convert between simple Bird-literate and non-literate source code. You could also convert your Bird-literate to TeX-style . # bird_lhs2hs sed '   s/^>//   t   s/^ *$// t s/^/-- / ' in.lhs > out.hs # hs2bird_lhs sed ' s/^-- // t s/^ *$//   t   s/^/> /  ' in.hs > out.lhs