Archive

post modern programming contest 2 – horoscopes

Charles Weir and yours truly made a small script to combine multiple horoscopes into one (the exercises some people come up with….:)

We completed a minimal implementation – only for taurus (could easily be parameterized in the next bit). It consists of a shell script that downloads a horoscope from yahoo, and downloads one from astrology online. It’s two scripts, since we extracted the extraction code for astrology online to a script called …extract.pl.

rm -f taurus*
rm -f daily.htm*
wget http://www.astrology-online.com/daily.htm 2> wget1.out
./extract.pl daily.htm > first.txt

wget http://astrology.yahoo.com/astrology/general/dailyoverview/taurus 2> wget2.out
cat taurus | grep Quickie  | sed 's/<.*b>(.*).*>/1/' > second.txt

cat *.txt

extract.pl :

#!/usr/bin/perl -w

while ( <> )
{
if (/CHANGE TAURUS/)
{
$printing = 1;
next;
}
if (/END TAURUS/)
{
$printing = 0;
}
if ($printing)
{ print ;}

}

postmodern programming contest

I’m at the postmodern programming conference in London today (pomopro) . Part of the day consists of a scrapheap challlenge – you might know the program scrapheap challenge from Discovery Channel.

Part of the challenge is we post our results on a blog… so here goes…
Emmanual Gaillot and yours truly paired up to produce something that plots a graph of the sloppiness of a progam in a subversion repository over time. We had ninety minutes to do so.

Emmanuel learnt svn, pmd and cpd (copy paste detection). I learnt grep -c..
here is the code:

#!/usr/bin/ruby
require 'fileutils'
revision = 54

#puts system('svn co http://stclass.tigris.org/svn/stclass/trunk/src_4x/src/java/org/stclass/runtime --username guest --password "" -r' + revision.to_s)

FileUtils.cd 'runtime'

outputs = []

(20..59).each do | revision |
	`svn up -r #{revision.to_s}`
	result = `java net.sourceforge.pmd.cpd.CPD --minimum-tokens 10 --files . |  grep -c "^Found a" `
	outputs << revision.to_s + "t" + result.to_s
end

puts outputs.join("")

The Rails bandwagon keeps moving

It seems the number of weblog engines written in Ruby on Rails is slowly but steadily increasing, seeing choosing a rails blogging engine. For programmers who read german, there is a free book on beginning with rails .

Travelling e-mail with Cached IMAP

I’m working on a user story form myself:

As a travelling consultant, I would like to have a public or
semi-public agenda on the web, so people around me can see where I am’

As a consequence, i’m looking into web calendaring software. I found a few most notably webcalendar and egroupware) that can synchronize with desktop calendaring and mail software (e.g. outlook, kontact, evolution). Therefore, I’m looking into kontact again. Kontact is kde’s personal information manager, with the mail application kmail and agenda softaware korganizer as main attractors.

Looking at kmail again turns out to be a pleasant surprise. I switched from kmail to thunderbird as my main e-mail client over half a year ago. I switched, so I could assist people who were switching to thunderbird on other platforms (unlike kmail that runs only on linux, thunderbird runs on all major operating systems). I like thunderbird for its easy adaptive junk-mail filtering system and the simple and powerful ways it has for searching and sorting e-mail.

The one thing I do not particularly like about thunderbird, is the way it handles the IMAP protocol for downloading mail. When I use IMAP, it does not automatically refresh all my mail folders, only my inbox folder. I have over 20 folders outside my inbox, for instance separate folders for some organizations I work for. I have missed e-mail sent to me by colleagues, because I did not see there was new mail in their folder.
I have thought about removing all folders, except the one for mailing lists, and just working with an inbox. That would be simple, except for the spam I’m still getting – all the filtered folders are virtually spam-free.

Anyway, kmail has this new feature called cached IMAP. Googling for it, I found this term mentioned only on pages about kmail, so I assume this is experimental. What it does is it combines the best of IMAP (all mail stored on server, so accessible anywhere, e.g. from my laptop(s), deskttop and webmail) and POP (mail stored on the client, so it e.g. travels on thetrain).

So far, I’m happy with it. It seems somewhat slow at times, as the server side
seems to have no support for caching and synchronizing differences. It is stable, unlike an earlier (uncached) implementation of IMAP in kmail, which was another reason I switched to thunderbird.
I’m going to try it out for a while, and let you know how it goes. Have to go now, my train has arrived at the station ;)

Refactoring long legacy methods

Refactoring long methods without tests can be difficult, adding tests for long methods requires Refactoring… In order to break this bind, Michael Feathers is working on a tool for Java that seems promising: Vise .

Vise enables a programmer to inspect values inside methods, and then test (with unit tests) and inspect these values, so at least when refactoring the programmer can be sure nothing has changed, and can get some confidence that all branches have been covered.

Vise should lower the barrier for testing and refactoring legacy code – when old complex code is not refactored, new more complex code is ‘wrapped around’ it, and no-one dares touch the old code anymore.

wordpress antispam measures

I’m getting slightly tired of spam comments on me.andering, so I’m trying out an automatic way of fighting spam – akismet. It comes with wordpresss – apparently it gets information on spam messages from a central site, for which I needed to create a wordpress.com account – registration was simple and friendly, and you can host free blogs there as well. I had 35 spam comments today (that comes together in less than a week). Let’s see what next week gives.

recovering a lost linux root password

A friend of mine lost her password and root password for her laptop. My favourite way to recover that is by using a linux livecd. Of course others have found this too, but searching this with google took longer than coming up with the answer… This post on everything2 explains how to do it, and it links back to some other solutions (without using a livecd, but slightly more difficult ).

Small talk in Paris

I’m in in Paris tonight, on my way back home from a holiday, seeing some of my friends here enjoying small talk and a discussion on smalltalk. Bernard Notarianni from Octo Technologies is hosting a presentation by Eric Winger on gemstone/smalltalk.

It’s been a while since I last programmed in smalltalk, and its nice to see there’s ongoing development. Especially if the vendor presenting does so in an open way, going into questions and openly giving answers – I wish more vendors presented like this.

Even though I haven’t programmed in smalltalk for a while, most of it still makes sense – I guess that is what stable technology looks like.




Switch to our mobile site