Monday, February 28, 2005
Saturday, February 26, 2005
XML::Parser of RSS
I have drunk the XML Kool-aid, also the Perl References Kool-aid.
#!perl -wl
use XML::Parser;
use LWP::Simple;
$content=get("http://earthquake.usgs.gov/recenteqsww/catalogs/eqs1day-M2.5.xml");
my $xml=new XML::Parser(Style => 'Tree');
$f=$xml->parse($content);
exit unless $$f[0] eq 'rss';
@g=&findelement('channel',@$f[1]);
@items=&findelement('item',$g[0]);
for (@items) {
@s=&findelement('dc:subject',$_);
die unless @s==2;
$mag=&intext($s[0]);
$post=&intext($s[1]);
$title=&gettext('title',$_);
$link=&gettext('link',$_);
$date=&gettext('description',$_);
print "$title\n$date\n$link\n$mag $post\n";
}sub findelement {
my ($tag,$val); my @ret; my ($target,$arr)=@_;
@_=@$arr;
shift; #throw away attribute hash
while (@_) {
$tag=shift; $val=shift;
push @ret,$val if ($tag eq $target);
}
@ret;
}
sub gettext {
my ($target,$arr)=@_;
my @t0=&findelement($target,$arr);
&intext(@t0);
}
sub intext {
my @t1=&findelement('0',$_[0]);
$t1[0];
}
Monday, February 21, 2005
Lossy conversion between decimal to binary
Suppose you have random decimal data, for example decimal digits of pi, and you want random bits. Take 28 digits at a time and get 93 bits out (2^93 = 0.99035e28), rejecting if the value is too large.
For the other direction, take 196 bits at a time and get 59 digits out. 2^196=1.004336e59.
Friday, February 18, 2005
Sunday, February 13, 2005
installing athena
Installing Athena on this new machine was a long drawn out process. the bootkit didn't see the motherboard network card, so I borrowed a PCI network card from another machine.
backup /boot /dell /etc /lib/modules/2.4.21-15.EL /usr/X11R6/lib64 /var/lib
backup text of ls -laR, df, rpm -q -a, fdisk p q
I wish I had also backed up rpm --q -a --provides
on partitioning, careful not to blow away the Dell utility partition and the secret reinstall partition. And leave some space for a future operating system partition.
Remember to do advanced custom install to select a multiprocessor kernel.
editing grub and fstab to change hda into sda for this weird SATA is it SCSI or is it not madness.
redhat-config-network to configure the motherboard eth0.
SNOWFLAKE-A-THON
My snowflake entry and source code.

import Complex
import System
type C = Complex(Double)
mandelbrot_eval::Int->C->Int
mandelbrot_eval max_iter c =
length
$ (takeWhile (\z -> (magnitude z) < 2))
$ (take max_iter)
$ (iterate (\z -> z*z+c) (0:+0) )
half_width_pixels::Int
half_width_pixels = 400
scaling::Double->Int->Double
scaling width = (* (width
/(fromIntegral half_width_pixels)))
. fromIntegral
range::Double->[Double]
range width= map (scaling width)
[-half_width_pixels .. half_width_pixels]
iterations::Int
iterations = 200
main::IO ()
main = do{
let {s = show (2*half_width_pixels+1)};
putStrLn ("P3\n"++s++" "++s++"\n"++"255");
args <- getArgs;
let {side = exp(-(read (head args)))};
putStr $ unlines $ map show
$ concatMap ( (\i -> [i,i,(i+55)])
. (mandelbrot_eval iterations)
. (+ center) )
$ [x:+y | x<-(range side), y<-(range side)]
}
center::C
center = 0.4245127190 :+ 0.2075302281
dkms nvidia driver rpm installing
So Dell shipped me this new dell machine running RHEL3 with a nvidia (pci express quadro nv 280 mumble something). Having reinstalled (with Athena) the task was to get the nvidia driver working again. Interesting things:
- The rpm they gave me seemed to have been precompiled for 64bit linux.
- It came with version 6624, thought the newest at support.dell.com was 6105
- Whatever that 6105 package was from dell, I regret having tried it
Anyway, the right thing to do was to use /dell/source/dell-nvidia-6624.1dkms.src.rpm. First be root, then rpmbuild --rebuild it, then rpm -Uvh to install the rebuilt rpm. All the proper DKMS stuff gets triggered (because I had installed dkms first).
Twinview works happily as advertised, and I now have 3200x1200 display on two CRTs.