Monthly Archive for November, 2006

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("")



Switch to our mobile site