## 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

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)!

And of course we all know what xkcd: Real Programmers use.

### 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

A note to myself. I've figured this out few years ago, but it looks like I forgot it... :-D

Always use the Delete() method on the DataRow object instead of Remove(DataRow) on the DataRowCollection, or else the corresponding SqlDataAdapter.DeleteCommand won't trigger for an Update.

So deleting from the table won't work, no execution will be done.

### LALR-1 parseable C++

In The Design and Evolution of C++, Stroustrup observes that "within C++ there is a much smaller and cleaner language struggling to get out" [Stroustrup, B., The Design and Evolution of C++, Section 9.4.4., Addison-Wesley, 1994.] and foresees the development of "other interfaces" to C++.

A Modest Proposal: C++ Resyntaxed by Ben Werther & Damian Conway (Department of Computer Science, Monash University)Significantly Prettier and Easier C++ Syntax (Wikipedia)

### Eee Keyboard PC - C=64 rebirth?

Well, what do you know, it looks like history does repeat itself:

Eee Keyboard splayed, detailed by FCC (Engadget)Trends Are Cyclical: the Asus Eee Keyboard (OSNews)ASUS Eee Keyboard (Wikipedia)