Andrew Channels Dexter Pinion

Wherein I write some stuff that you may like to read. Or not, its up to you really.

November 27, 2005

It Never Rains

On top of a non functioning Mac I've now managed to bugger my work laptop.

I had it dual booted with Windows XP and Ubuntu but hadn't set my disk partitions properly. I wanted to move some space from the Ubuntu partition back to Windows but for one reason or another ended up deleting my whole ext3 partition. Which is fine because everything on it was backed up.

What it has done is confused my Grub configuration file. Whenever I start the machine I get grub error 22. So my question is this, oh great lazy web, how do I boot into Windows with a broken Grub installation sitting in my master boot record?

Oh, and it's a work machine so I don't have the windows Administrator password to run the XP recovery disk.

Update Following Ludo's advice in the comments - and from other parts of the intarweb - I got a Windows boot disk from Free Pc Tech Support, booted from it and fixed the master boot record (with fdisk /mbr). I can now boot into Windows XP and I'll reinstall Ubuntu after a suitable amount of sober reflection.

Posted by Andy Todd at 07:42 PM | Comments (6)

November 22, 2005


My iBook has died. I am desolate.

I'm not sure what is wrong. I packed it into my bag at the end of the day and when I got home it wouldn't wake from it's nap. Even pressing the on/off button for the specified ten seconds didn't seem to make a difference. Until it seemed to start up and all I got was the cpu fan spinning rather manically. At that point I found that the only way to stop it was to reset the PMU and figured that it was not a well laptop.

Even worse, when I took it to the local Apple dealer to see if they could fix it they told me that they wouldn't be able to look at it for at least a week.

So I'm stuck in a Windows only world and it's rather a rude shock. Luckily all of my data is in flat files, my scripts are all in Python and everything is backed up so I can carry on. But it's not the same.

Here's hoping that it can be fixed because money's tight and I'm not sure I can afford a replacement at the moment.

Posted by Andy Todd at 07:26 PM | Comments (7)

November 10, 2005

String manipulation in PL/SQL

I've had to put my managerial hat to one side for a while. There's some very broken code in our system and I find myself the only person with the skills and time to fix it. It's the most serious PL/SQL programming I've done in a while and I'm beginning to remember why. These days if I want to get something done I'll reach for Python, and a day or so into this PL/SQL coding I'm pining for it already.

My first problem is with string handling. I want to do something as innocuous as count the number of commas in a string. In Python it's;

>>> myString.find(',')

In PL/SQL, well let's just say that PL/SQL doesn't have the robust string handling support that Python enjoys. The original author, who shall remain nameless to protect the incompetent, simply loops through each of the characters in the string incrementing a local variable if they are a comma. Not entirely efficient methinks. Mind you, Google isn't a fount of knowledge on the subject either, it's best offer is this snippet from Chapter 11 of Oracle PL/SQL Programming from O'Reilly. Which, summarised and less general than the example allows me to do something like;

FUNCTION count_occurrences(p_my_string IN VARCHAR2, p_character IN VARCHAR2) RETURN NUMBER IS
  l_search_loc NUMBER := 1;
  l_search_again BOOLEAN := TRUE;
  l_return_value NUMBER := 0;
  WHILE l_search_again LOOP
    l_search_loc := instr(p_my_string, p_character, l_search_loc, 1);
     l_search_again := l_search_loc > 0;
     IF l_search_again THEN
       l_return_value := l_return_value + 1;
       l_search_loc := l_search_loc + length(p_character);
     END IF;
   return l_return_value END;

It's more efficient than looping through the provided word or phrase but still a lot of code to do some simple string manipulation. I'd write it in Python, but Oracle doesn't let you write trigger code in proper programming languages ;-)

Posted by Andy Todd at 04:06 PM | Comments (7)

November 03, 2005

November Sydney Python Meetup

It's that time again. Alan's booked the venue and press ganged a couple of presenters so all that's left is to announce the date. The next Sydney Python meetup will take place on the 17th of November, 2005.

Full details are at and discussion takes place on the mailing list.

Posted by Andy Todd at 08:10 PM | Comments (0)