Friday, 21 March 2008

sudo tachet i tac a ti

G: Ehi tu, tachet i tac a ti!
L: Io tachet i tac a ti, che te tachet it tac? Tachet i ti i to tac.
G: sudo tachet i tac
L: okay

Fionnuala got me that http://xkcd.org t-shirt for Christmas :)

sudo solve impossible problem

Thursday, 6 March 2008

best leaving present EVER: The Gemmalarm™!

Gemma is leaving us and one of the things she gets is this:
http://www.gemmalarm.com/ The Gemmalarm™

The Gemmalarm™ itself is the best ever office utility/joke.
Gemmalarm™ = orrible app -> parallel port -[wires]-> picture of us with leds for eyes.

Monday, 25 February 2008

scales balancing puzzle check weights40.pl

see perl script weight40.pl


#!/usr/bin/perl

=head1 NAME

weights40.pl - check you can make each weight from 1 to 40 balance

=head1 DESCRIPTION

This doesn't solve the puzzle but does prove that the solution works.

The puzzle is you have a balance (bilancia in Italian).
And you can choose some unit weights to help weigh things.
If you get any unit weight from 1 to 40 you need to be able to determine the weight.
(You have to make the scales balance, you're not allowed to measure
it as lighter than w+1 and heavier than w-1 hence is w.)
What is the minimum number of weights you can do this in ?

If the puzzle is told properly then you probably have to bring the
balance and weights up a big mountain with dragons on top so you wish to use the absolute minimum
number of weights (or possibly minimum weight of weights - is it the same answer I wonder?)

=cut

my @weights = ( 1, 3, 9, 27 );

for(my $w=-1; $w<=41; $w++) {

# brute force, try balance all permutations, weights on both sizes

# try position of not there, left, right for each weight
my @weight_pos = ( 0, 0, 0, 0 );
my $wi = 0;

# print terrible message if not found otherwise might miss one
my $terribleness = "BAH! :( not good, no match for $w\n";
my $found = 0;

for($weight_pos[0]=0; $weight_pos[0]<3 && $found==0; $weight_pos[0]++) {
for($weight_pos[1]=0; $weight_pos[1]<3 && $found==0; $weight_pos[1]++) {
for($weight_pos[2]=0; $weight_pos[2]<3 && $found==0; $weight_pos[2]++) {
for($weight_pos[3]=0; $weight_pos[3]<3 && $found==0; $weight_pos[3]++) {

# start with $w always on left
my $left_tot = $w;
my $right_tot = 0;
my @leftside = ( $w );
my @rightside = ();

# print '$#weights is ' . $#weights . " (number of elements in weights array)\n";

# put weights on balance
for($wi=0;$wi<=$#weights;$wi++) {

#print "dbg w=$w wi=$wi pos=$weight_pos[$wi]\n";

if ($weight_pos[$wi] == 1) {
#printf "L";
push @leftside, $weights[$wi];
$left_tot += $weights[$wi];
} elsif ($weight_pos[$wi] == 2) {
#printf "R";
push @rightside, $weights[$wi];
$right_tot += $weights[$wi];
}
#$ls += "(".$weights[$wi].) ";
#$rs += "(".$weights[$wi].) ";
}


#print "dbg w: $w, balance $left_tot = $right_tot, left: @leftside - right: @rightside\n";

if ($left_tot == $right_tot) {
print "w: $w, balance $left_tot = $right_tot, left: @leftside - right: @rightside\n";
$terribleness = "";
$found = 1;
break;
}

}
}
}
}

print $terribleness;
}



perldoc is a good reference, (command-line interface to perl docs)
not on all machines but is on slaine
same stuff as is on web in lots of places of course:
http://perldoc.perl.org/perl.html

e.g. perldoc perl, perldoc perldoc (for table of contents)
perldoc perlsyn
perldoc perlre

-f or -q to get function documentation or search faq:

perldoc -f printf
perldoc -q while

After you know all that perldoc then you can start thinking about using perl modules! :D


To read perl documentation _inside_ perl scripts or modules just do e.g.:

perldoc weight40.pl

Saturday, 23 February 2008

"Oh ye broke me cups and saucers"

I've set me playing the recorder of the tune of "cups and saucers" as ringtone for Mum :)
I started with "Moll Dubh" for Fionnuala.
Quite a striking mobile ringtone! :-o

Mum remembers her dad singing this chorus, and only the chorus:

Oh ye broke me cups and saucers
Oh ye did ye rogue, oh ye did ye rogue
Oh ye broke me cups and saucers
Oh ye did ye rogue, oh ye did ye rogue

Much grepping of internet reveals those lyrics are nowhere!
Maybe on an album by Bobby Gardiner - The Clare Shout - song The Kerry Cow, Cups and Saucers
http://www.thesession.org/recordings/display/2330
Someone says on comments "It's called Cups and Saucers on Bobby Gardiner's album "The Clare Shout". He lilts the tune and runs it into the song "Cups and Saucers" (of the same tune).
Maybe that is song eilzab is talking about."

thesession.org seems to be quite a good source for information on irish tunes.
lyrics, sheet music and ABC music
http://www.thesession.org/tunes/display/1123
Also known as "Bhiosa La I BPort Lairge", Cups And Saucers, False Knight On The Road, The False Knight On The Road, I'll Cloot My Johnny's Breeches, Let's Pet The Pope, Little May Cullinane, O, I Courted A Farmer's Daughter, Port Lairgè, Portlairge, Portláirge, Dashing White Sergent, White Cockade

And in last.fm/youtube can find various renditions of "The False Knight on the
Road" ... and one or two of them have the same tune.
http://www.last.fm/music/Steeleye+Span/_/False+Knight+On+The+Road+%5Blive%5D

Friday, 25 January 2008

kubuntu feisty ahh ohhh .... ARGH!

After bedtime songs over (I peeped in - Maeve, Airport up in Knock - Kate, Does God have a name) Maeve directs me to go on computer. Unusual! Fionn out residents meeting. So well I _have_ been meaning to backup photos and get video upload and editing working so I toddle over, fire in kubuntu live CD and after a little clicking go and install. I see qtparted and lots of nice things so I can probably recover if something goes wrong.

BTW, need to update at this stage as SuSE 9.1 even after kernel and driver upgrades and reconfig cannot access new SATA DVD/RW and usb driver hangs/goes ultra-very-slow when communicating with HD camcorder. And of course have reached limit of adding bleeding edge versions of various libs built from source in order to get later versions of anything (Wesnoth :) Scribus/Inkscape ...)

So 1st reboot later and ARGH! Blinky cursor top left of black blank screen where grub should be starting up. NOOOOOOOOOOOOOOOOOOOOOO!!!!!!

Typical. Plus ca change ... PAS! :)
Redhat install pre-1998 involved lilo loopiness first and then every teeny step of the way needed configuring and persuading (keyboard, mouse, graphics, sound, modem, ...)
SuSE 9.1 install maybe 2002/3 was much easier. Resized an ntfs windows partition and grub did everything right. Had fun with Nvidia 3D gfx drivers (Makefile edits).

After rebooting with live CD lots of times, reading up on grub/kubuntu install problems (quite possibly down to sata handling) poking at grub. retrospectively backing up mbrs of every partition. At about 4:30am I get a grub menu BAUGH!! Of course nothing boots but I can quickly see hd0 seems to be sdb not sda and vice-versa for hd1 and sda so another liveCD boot, edit grub manu.lst and YAY! can boot new ubuntu. And YAY! boot old SuSE 9.1 but urk! can't boot windows?
Install install install stuff on ubuntu.
Kids educational and games.
Graphics, some music and video edit.

I hear ... something beeping beeping beeping ... waurgh! It's my alarm clock.
Glance at clock .... 7am!! Ach jaypers! I leg it to spare bed and crash.
Fionn up with kids, I'm really cold during getting ready/breakfast.
Galke force winds.
There's been crash on M50 and traffic is CrAzY can see it backing up in our estate.
All Leopardstown road is jammed, lots of N11 much busier than usual and around port too.
Windy but grand and dry and not cold really for motorbiking. Lots of motorbikes/scooters around.

TODO: 3D/nvidia setup, java+flash+licenced extras around system, transfer photos and music (or ...), transfer video, backup & setup editing.



https://bugs.launchpad.net/ubuntu/+source/grub-installer/+bug/32357/comments/17
Installer doesn't recognise SATA disks as primary.
https://bugs.launchpad.net/ubuntu/+source/grub-installer/+bug/46520
Grub installs to wrong drive's MBR in default install. No way to change in standard installer.
https://bugs.launchpad.net/ubuntu/+source/grub/+bug/8497
grub guessed BIOS disk order incorrectly
https://bugs.launchpad.net/ubuntu/+source/grub/+bug/21186
grub uses wrong bootparameters with sda after install


Same problem for me feisty 7.04. Two SATA drives sda and sdb. Dell optiplex desktop.
There seem to be a few problems for users coming up related to grub + sata difficulties
and the issue seems to be ongoing so I'll just add my piece.

bios before was booting from hd0 (suse + grub)
kubuntu new installed on sdb, wrote grub mbr to hd0, sdb was unformatted before install
After kubuntu install sdb bios was looking for hd1 mbr only? Boot hung.

After woe and wailing and gnashing of teeth wrote kubuntu sdb grub mbr to hd1
(in grub root(hd1,1) setup(hd1)) and got a grub menu YAY. But nothing worked.
Weirdly could see sdb was now hd0 and sda was hd1.
So if boot kubuntu live cd grub hd0 = sda, hd1 = sdb.
But in grub from bios boot hd0 = sdb (disk booting from) and hd1 = sda.
Swap hd0<->hd1 in menu.lst

Also the os scan could see suse and windows on sda but entry for suse was not added in kubuntu's menu.lst.

So ... hurmmm. What should the grub install do?
The grub setup(hd0) write by kubuntu gui install flashed up very fast and I didn't see it.
Write to hd0 or hd1 ? If I think you can't trust bios
I think it could have some helpful things added:
1. make a backup of any mbr it is writing over, put it in /boot/grub/backup_mbr_xxxx (and rotate)
(consider also backup of all partition mbr areas - user would appreciate that if they have to start
running grub install themselves)
2. if kubuntu successfully boots from install mark grub as having a successful boot
3. If user has come back in on live CD and there is an mbr backup then options to
restore these would be nice (display options if advanced user OR if user has come back and
a successful boot has not happened).
4. If user has come back in on live CD and there is no grub successful boot mark then ... ... ?
offer option to audit hardware/software and send report somethere?
5. If there is another grub ... play nice, warn user. Can't cover all options but it would be nice.

bloat bloat bloat :) but in the name of user-friendliness and that's what the grub install intends?

I think the bios behaviour is odd.

To handle bios weirdness I'd guess after any partition editing a reboot would have to be done (YEUCH!) and then the assigned handles would probably be correct so that grub install could run and be reasonably sure the handles have not changed.

Otherwise write grub mbr to all disks seen? Especially if have just formatted a disk ...
In my case the sdb mbr was left uninitialised so when it was attempted to boot from by bios it hung.
If a grub mbr was sneakily written to new disks it could save hassle for a few people.

But grub is clever and ?should?/could be made to be a bit more flexible?
i.e. if (hd0,x)/boot/grub/menu.lst not found then look for it on (hd1.x) (hd2.x) ... ?
Maybe that is hard to do.

James.

Sunday, 6 January 2008

dsp cookbook and pumpkins

Yay! :) Paula has published latest dspsrv cookbook
http://www.dspsrv.ch/cookbook

We just harvested our last 3 pumpkins after christmas - they were a bit late
in the planting really and probably just got half the potential Irish sun due to location
- we had 4 for halloween but left the others as they were still very green.
We've eaten one of the latest ones and wow it was so sweet!
I'd say not 100% ripe as there was no apace inside, just pumpkin seeds packed in tight.

We've also discovered pumpkin goes very nicely in omlette.
Fry pumpkin with herb/seasoning quickly before taking out and adding to egg
(you have to add the pumpkin to the egg so it's inside the omlette and not obviously underneath).

I have to clarify one thing, I actually quite like bogs and Brenda Costigan's book too!.
So when I say "some simple bog-standard Irish recipes" I actually mean simple*** and bog-standard as in
down to earth and sensible in a very excellent way. I didn't put enough emoticons and
thought/proofreading in there!

*** simple in one way yet teeming with gazillions of twii###mendously compwex and exciting
micwo-owganisims (hopefully for a healthy bog)

### sowii!

Wednesday, 2 January 2008

varied diet

for my midnight-ish snack I've just had:
half an apple
pulp of one orange
hot whiskey (with zingy grated lemon peel and ginger, honey & lemon clove slice) (with Fionnuala)
piece of cajun salmon
half glass red wine
bowl of breakfast cerial (girls from this morning - medly!)
small piece of christmas cake

Yum. Leftovers. Me dustbin.