#!/usr/bin/perl -w
#
# Graph the state of Top 100 SETI folks in Ireland. I'm in red. Gives
# deltas for the last time checked: position change (negative for
# moving up the ranks) and number of units completed. Needs to be
# hacked to cope with what happens when I run off the right-hand side
# of the graph. Also would be nice to cope in the event of me falling
# off the top 100 (continue and find out where I am, I guess)
#
# March 2003: crude hack to left-shift
# colour people doing better than me vs. people doing worse
use LWP::UserAgent;
use HTML::Parser;
use Date::Parse;
use Storable;
use GD;
use Getopt::Long;
my %rankings;
$| = 1;
# Load up the database, if possible
my $oldest = time;
my $maxcount = 0;
my $graphonly = 0;
eval {
my $foo = retrieve( $ENV{'HOME'} . "/.setiranks" );
%rankings = %{$foo};
for my $name ( keys %rankings ) {
my $data = $rankings{$name};
next unless $data;
my @points = @$data;
if ( @points ) {
for my $p ( 0..$#points ) {
my ( $t, $c, undef ) = @{$points[$p]};
if ( $t < $oldest ) {
$oldest = $t;
}
if ( $c > $maxcount ) {
$maxcount = $c;
}
}
}
}
};
my $ua = new LWP::UserAgent;
$ua->agent( "GeekToy/0.1" . $ua->agent );
$ua->env_proxy();
my $notable = 0;
my $interest = 0;
my @fields;
my $update;
my $dead;
my $SCALE = 5;
my %seen;
my $im = new GD::Image( 100 * $SCALE, 100 * $SCALE );
my $white = $im->colorAllocate(255,255,255);
my $black = $im->colorAllocate(0,0,0);
my $red = $im->colorAllocate(255,0,0);
my $blue = $im->colorAllocate(0,0,255);
my $yellow = $im->colorAllocate( 0,255,255 );
$im->fill( 0, 0, $black );
$im->transparent( $black );
my $verbose = $ENV{'DEBUG'};
my @list;
my $myrate = 0;
GetOptions( "graphonly" => \$graphonly,
"verbose" => \$verbose );
open( HTML, ">$ENV{'HOME'}/public_html/misc/seti.html" );
print HTML <<"EOH";