Linux tip: du --max-depth=1

September 27, 2007
28 comments Linux

There are lots of fancy programs for Linux to find out where your gigabytes are sitting and filling your hard drive, the simplest of them is du (from disk usage). The trick is to use the --max-depth=1 option so that you get a view of which folder weighs how much. Try this:


peterbe@trillian:~/tmp $ du -h --max-depth=1
900K    ./Example-Receipts
4.0K    ./Foredettinghelgen
44K     ./IssueTrackerBlogInterface
1.9M    ./IssueTrackerProduct
12K     ./fried-mugshots
2.1M    ./ies4linux-2.0.5
4.8M    ./pyexcelerator
52K     ./levenstein
4.0K    ./newitpdesign
4.7M    ./photoresizing
69M     ./databases
4.5M    ./i18nextract-sa
532M    .

Pretty nifty! That way you can quickly see which folder contains the most junk so that you can free up some hard drive space.

To sort it I don't know how to reformat it into human readable values but there's the command:


peterbe@trillian:~/tmp $ du --max-depth=1 | sort -n
4       ./Foredettinghelgen
4       ./newitpdesign
12      ./fried-mugshots
44      ./IssueTrackerBlogInterface
52      ./levenstein
900     ./Example-Receipts
1856    ./IssueTrackerProduct
2140    ./ies4linux-2.0.5
4528    ./i18nextract-sa
4796    ./photoresizing
4872    ./pyexcelerator
70392   ./databases
544608  .

Spellcorrector 0.2

September 24, 2007
3 comments Python

Unlike previous incarnations of Spellcorrector not it does not by default load the two huge language files for English and Swedish. Alternatively/additionally you can load your own language file. The difference between loading a language file and training on your own words is that trained words are always assumed to be correct.

Another major change with this release is that a pickle file is created once the language file or own training file has been parsed once. This works like a cache, if the original text file changes, the pickle file is recreated. The outcome of this is that the first time you create a Spellcorrector instance it takes a few seconds if the language files is large but on the second time it takes virtually no time at all.

Truncated! Read the rest by clicking the link below.

Ugliest site of the month - The Backyard Comedy Club

September 21, 2007
15 comments Misc. links

Ugliest site of the month - The Backyard Comedy Club It's been a while since I last ranted about some website looking not only totally unappealing but also barely usable. This time it's called The Backyard Comedy Club and it's a quite simply, a comedy club near where I live. The sad thing about this site unlike other sites that I've criticized as being butt-ugly in the past, this one is actually quite new. The footer says "Copyright Backyard Comedy Club 2007 ©".

Maybe the intention is that the whole website is a joke. Kind of to get you in the right mood for the comedy acts.

Vertically expanding textarea input boxes

September 19, 2007
0 comments JavaScript

I've recently improved the IssueTrackerProduct so that when you start to write in the little textarea it expands and grows vertically as the text gets larger and larger. Other sites like Highrise do this too for note taking.

Long story short, here's the demo and here's the solution:


function _getNoLines(element) {
  var hardlines = element.value.split('\n');
  var total = hardlines.length;
  for (var i=0, len=hardlines.length; i<len; i++) {
     total += Math.max(Math.round(hardlines[i].length / element.cols), 1) - 1;
  }
  return total;
}

$(function() {

  // First, for all the textareas that have lots of lines of text 
  // in them, we want to double their number of rows
  $('textarea.autoexpanding').each(function() {
     while (_getNoLines(this) > parseInt(this.rows))
       this.rows = '' + Math.round((parseInt(this.rows) * 1.5));
  });

  // When a user enters new lines, if they have entered more
  // lines than the textarea has rows, then double the textareas rows
  $('textarea.autoexpanding').bind('keyup', function() {
     if (_getNoLines(this) > parseInt(this.rows))
       this.rows = '' + Math.round((parseInt(this.rows) * 1.5));
  });

}

Truncated! Read the rest by clicking the link below.

Nasty human error in Zope ZEO setup

September 14, 2007
0 comments Zope

Together with my colleague Jan we today tried to fix a problem with Zope ZEO server that wouldn't start. Very strange we thought since another ZEO server on the same machine was working fine. We compared zope.conf files and found nothing obvious. Here was the error you get with 'bin/runzeo':


root@da-ovz-vm99182:/var/lib/zope-2.8.9/aragdb-zeo1# ./bin/runzeo 
Error: error opening file //var/lib/zope-2.8.9/aragdb-zeo1/etc/zeo.conf: 
[Errno ftp error] no host given

What?? ftp error??

Long story short, the error was this line in 'runzeo':


CONFIG_FILE="/${INSTANCE_HOME}/etc/zeo.conf"

which should have been this:


CONFIG_FILE="${INSTANCE_HOME}/etc/zeo.conf"

Not so easy to spot because the CONFIG_FILE line is something you rarely look closely at.

Fun Python error message

September 7, 2007
0 comments Zope

I saw this today on the Zope mailing list:


TypeError: open() takes at least 1946389116 arguments (4 given)

For anybody who's ever used Python you'll find this funny.

What art is ...according to Don Van Vliet

September 7, 2007
5 comments Art

What art is ...according to Don Van Vliet I finished a wonderful book about Don Van Vliet called "Captain Beefheart" by Mike Barnes and being a huge Beefheart fan this was a very interesting book. To be honest, I found out things about Don that I'm not sure I even wanted to know. I feel both sorry for and jealous of the musicians he worked with. The book is full of little mind bogging quotes by Don all worth a blog each but one that I did write down was this:

"[Don Van Vliet] told John Yau what painting was to him: 'Fulfilling the absence of space between the opposite meanings. I think that's essentially what I think. That came the other night. It cam blasting into my head. I quickly wrote it down. Yes, that's what painting is.'"

I've thought about it a bit too now and although I don't have to agree or disagree I think it's a very good answer.

Not just the bikini event

August 31, 2007
0 comments Misc. links

Not just the bikini event I've always considered the "personality" test even of beauty competition such as Miss World as a chance to go away and get some food or a toilet break and it's really only the bikini event that matters. It's time to revise that now maybe. Until this clip I've always thought what the beauties say just stupid, now I'm going to consider it amusing instead.

What's South Africa got to do with it?

Proud to be a Swedish atheist

August 29, 2007
0 comments Sweden

I have nothing against religious people and have both friends and family that are religious and I have absolutely no intention of converting them.

Although I've lived most of my adult like in Britain I'm still Swedish at heart and when I see stats like these I feel proud to be Swedish. Not only because of the liberal and modern thought but also the fact that "non-religiousness" is apparently a measure of social wealth.

"[authors of report] who argue that in societies characterized by plentiful food distribution, excellent public healthcare, and widely accessible housing, religiosity wanes."

UPDATE 2018

I am not an atheist. At least not any more. Not religious either.

Printer usability problem

August 24, 2007
1 comment Linux

Printer usability problem I booked an appointment for a computer repair today and there was a reference number and summary that I was told to print two copies of. One to go with the computer and one to keep myself as a reference. The page was one page long. So, in Firefox I clicked to print two copies. Our printer here at work is one of those that prints on both pages and that's where the problem lies. It printed the two copies one of each side. So only one piece of physical paper. Totally stupid.

I don't know what or who to blame for this. Is it my Firefox? My Dell printer? My Linux printer drivers? Surely there was a chance for someone working on this some time ago who chose not to think for a moment.