Log in

I've moved!

I'm here now: www.kamr.no



Posting Flickr images to Web Boards

I post images from Flickr on misc Web Boards regularly, and today I wrote a small Perl script to help me along:

The script is available here: kvisberg.net/scripts/flickr2bbc.pl

#!/usr/bin/perl -w
#  This script was developed by Ole Bendik Kvisberg (olekvi at kvisberg.net),
#  This script is free software; you can redistribute it and/or modify it
#  under the same terms as Perl itself.

use strict;

use Getopt::Long;
use File::Basename;

my $help        = 0;
my $flickrname  = 'olekvi';

# From Flickr.com:
# Flickr Community Guidelines specify that if you post a Flickr photo on
# an external website, the photo must link back to its photo page

my $nolink      = 0;

GetOptions ("flickrname=s"      => \$flickrname,        
            "nolink"            => \$nolink,
            "help"              => \$help);

my $url = shift;
if ($help or !$url) {


sub usage {
        printf ("Usage: %s [OPTION] [PHOTOURL]\n", basename($0));
        print "Creates BBCode to insert Flickr photo on web forums\n\n";
        print "  -f  --flickrname   your flickr username (i.e 'olekvi')\n";
        print "  -n, --nolink       skip link (Flickr says you shouldn't!)\n";
        print "  -h, --help         display this help and exit\n";

sub createbbc {
        my $photourl = shift;
        unless ($photourl =~ m!^http://farm\d+\.static\.flickr\.com/\d+/(\d+)_\w+.jpg$!) {
                printf ("Invalid Flickr photo url:\n%s\n", $photourl);
        my $linkurl     = sprintf("http://www.flickr.com/photos/%s/%s/", $flickrname, $1);
        my $photobbc    = sprintf("[IMG]%s[/IMG]", $photourl);
        if ($nolink) {
                printf ("%s\n", $photobbc);
        else {
                printf ("[URL=%s]%s[/URL]\n", $linkurl, $photobbc);      


Flickr Pro

I bailed out and paid for a pro account on Flickr.

Goodbye Mr Old Gallery, Hello New Flickr --> http://flickr.com/photos/olekvi/

Perl saves the day

After a lot of totally meaningless mouse clicking I have finally automated yet another "web only" task using Perl, Web::Scraper, WWW::Mechanize and cron.

I just love CPAN! And hate the HTML I've been parsing (//table[2]/tbody/tr/td[3]/table/tbody/tr/td/table/tbody/tr *BRRRRR*)

But why didn't I take the time to wrap up these scripts months ago?!


http://yapc.tv/ - great for all of us not going to any YAPC this year (great for all others as well, I guess)

Summer time

And my first summer in like 15 years I don't have to touch a computer, unless I want to.

I like this new situation a lot, not sure for how long, though.

Done more than 5000 km on the motorcycle already this season - great weather, and enough time results in pure fun!


Phun is really cool!

Grab it here and waste the rest of your day :-)


Some days ago I wrote about how I HATED hardware.

I still do, and after failing with the SiL S-ATA controllers I bought a new four channel controller from Promise, the TX4 300 arrived on saturday.
A shutdown, some yelling and messing around with screws, pci cards and those damn crappy S-ata cables later the box was up and running again.

Impressed, but not surprised, I watched ZFS assembling the raid as if nothing have happened since last boot, though three of five disks in the raid had changed device name.  ZFS 1 - Hardware 0

I was told to run zpool scrub raid and after a few hours I could see a lot of zfs checksum errors, those awful DMA errors in syslog was gone though.  A new file system scrub found even more checksum errors, and I got a bit worried.  Perhaps there is memory problem?

A reboot-with-new-ram-and-two-scrubs later I got zero checksum errors and zero DMA errors in my syslog.  *whee!*
... the system has been running with a high IO load for 72 hours now, and still no errors  *double whee!*

The good thing: ZFS has never created errors which it wasn't able to fix; all my files are ok, and I've learned quite a lot about ZFS on my way:  ZFS 2 - Hardware 0
The bad thing: I've spent way to much time debugging hardware (and money on new hardware).


Using the fantastic LXR I found the following in the Linux driver for SiL:

MODULE_PARM_DESC(slow_down, "Sledgehammer used to work around random problems, by limiting commands to 15 sectors (0=off, 1=on)");

Perhaps that is why my buggy SiL hardware have worked for years on my Linux system?


I own a old, but still very usable IBM ThinkPad T30. You know, that kind of a laptop which probably will live forever as long as you give it a new battery every third year ...

The Thinkpad was bought in the US, and has got a US keyboard layout, which is nice for everything but writing characters like æ, ø, å, Æ, Ø, Å,.

My T30 is running Ubuntu 7.10, but this should work for all systems running some kind of X and support xmodmap, and the idea is simply to remove the normal caps lock behaviour, which is never used anyway, and then use the combination of caps lock and another key to produce my beloved "Norwegian characters".

This is very easy using xmodmap, and my .Xmodmap looks like:
! This is an .Xmodmap file for my IBM T30 with an american keyboard layout
! supporting æøå, ÆØÅ using Caps Lock
! Ole Bendik Kvisberg

clear lock
keycode 66 = Mode_switch

! norwegian chars
keycode 34 = bracketleft braceleft aring Aring
keycode 47 = semicolon colon oslash Ooblique
keycode 48 = apostrophe quotedbl ae AE

! broken in default config
keycode 21 = equal plus
keycode 35 = bracketright braceright

I HATE hardware!

... at least the buggy ones.

At home I got a two or three years old P4 computer, mainly used as a file server, hidden in a closet.  Very nice when everything works, not nice at all with buggy hardware in it.

Normally I use Linux on all my computers, preferable Ubuntu, but I really wanted to play around with ZFS on the file server so I installed FreeBSD 7.0 RC1 on it some days ago.  The install went very well, and I was quickly able to create a raidz of 5 Samsung S-ATA drives.

Three of the drives are connected to the onboard S-ATA controller on my main board, and the two last disks are connected to two separate 'Sil 3512 SATALink/SATARaid Controller' PCI controllers.  Wanna guess which disks are on the SiL?

        NAME        STATE     READ WRITE CKSUM
        raid        ONLINE       0     0     0
          raidz1    ONLINE       0     0     0
            ad15    ONLINE       0     0     0
            ad13    ONLINE       0     0     0
            ad4     ONLINE       0    34    11
            ad8     ONLINE       0    42     9
            ad14    ONLINE       0     0     0

No rewards for guessing ad4 and ad8, sorry.

My syslog is filled with messages like:

Jan 31 15:44:05 dj kernel: ad4: TIMEOUT - WRITE_DMA48 retrying (1 retry left) LBA=473275789
Jan 31 15:44:10 dj kernel: ad4: TIMEOUT - WRITE_DMA48 retrying (0 retries left) LBA=473275789
Jan 31 15:44:15 dj kernel: ad4: FAILURE - WRITE_DMA48 timed out LBA=473275789
Jan 31 15:44:15 dj root: ZFS: vdev I/O failure, zpool=raid path=/dev/ad4 offset=242317203968 size=32768 error=5
Jan 31 15:45:31 dj kernel: ad8: TIMEOUT - WRITE_DMA48 retrying (1 retry left) LBA=
Jan 31 15:45:31 dj kernel: ad8: FAILURE - WRITE_DMA48 status=51<READY,DSC,ERROR> error=10<NID_NOT_FOUND> LBA=488396070
Jan 31 15:45:31 dj root: ZFS: vdev I/O failure, zpool=raid path=/dev/ad8 offset=250058787840 size=1024 error=5
Jan 31 16:03:14 dj root: ZFS: checksum mismatch, zpool=raid path=/dev/ad4 offset=208201856000 size=32768
Jan 31 16:05:41 dj root: ZFS: checksum mismatch, zpool=raid path=/dev/ad4 offset=152869227520 size=32768

I've tried to Google error messages, and I'm not the only one having trouble with the SiL shit, but I still haven't found any solution to my problem, except for the obvious 'buy a new S-ATA controller, and a working one this time!' approach.

Comments and help on this one is warm welcome :-)