blog.thiesen.org

a geek’s life

Archive for the 'Perl' category

FrOSCon 2007: Call For Papers

The second Free and Open Source Conference “FrOSCon” takes place on August, 25th and 26th 2007 in Sankt Augustin, near Bonn, Germany. The conference is once again hosted by the faculty of computer science of the University of Applied Sciences Bonn-Rhein-Sieg in collaboration with the student body and the Linux/Unix User Group Sankt Augustin.

In a Call for Papers, the organizers ask for submission of contributions. A broad variety of topics concerning free and open source software is desired.

Contributions can be submitted in English or German and should summarize the intended talk concisely and succinctly; talks should be no longer than 45 minutes in length. Deadline for submission is June, 4th 2007.


PerlPlanet

I hate to always criticise other people’s work, but Planet is a piece of crap. I tried it on my favourite blogs to fire up friends.thiesen.org and besides not working on Atom feeds as it should it completely died on another feed and had encoding issues. I tried to fix it, but it appears as if the feed reader library they are using is far too old (they are using 2.2 something, 4.0-pre is the curernt version) and it is Python and I can’t do Python.

PerlPlanet to the rescue. Because there was no other implementation of a Planet like thing and I thought it couldn’t be that hard, I wrote a replacement myself. PerlPlanet can do everything except the Hackergotchi feature while staying compatible with Planets own templates and configuration files. Turns out it is even 500 lines less, though you have to install quite a bunch of Modules, but you should be used to that by now.

Get it here.

P.S.: WordPress 2.0 Beta rocks…


JSON & JavaScript Speed

Was macht man wenn man clientseitig viele Daten verarbeiten möchte? Kein XML parsen, das ist total out, weil XML ja nicht native ist. Dafür gibt es jetzt JSON, die JavaScript Object Notation, die ist wie XML ohne den ganzen DTD schnickschnack und sowieso, man kann es einfach eval’en. Das geht dann auch für 3943 Einträge ala Autor, Titel, Ausgabe, Seiten. Damit man jetzt nicht seine ganzen XML Daten (oder sonstwie mehr oder minder strukturierte Daten) von hand umwandeln muss gibt es JSON für Perl aber auch eigentlich für alles andere. Hat mich auf jeden Fall begeistert, für Sachen die im Browser laufen sollen auf jeden Fall das richtige Datenmodell und richtig schön KISSig.

Wenn man dann allerdings knapp 4000 Einträge in einem Browser laufen lässt und vor allem daraus auch noch ein volles Listing in Tabellenform macht (also 4000 <tr><td> in den DOM Baum einbaut) hat man eher einen Browser Benchmark als sonstwas (das initiale Parsen ist kaum merklich, ich nehme mal stark an das die Browser rendern und so Sachen wie JavaScript Namespace aufbauen asynchron machen). And the winner is… Opera. Ja, ich muss zugeben ich war auch etwas überrascht. Zumindest auf Linux ist es ganz klar Opera der das Ding am schnellsten Angezeigt bekommt. Danach kommt Firefox (1.5 RC1) und dann Konqueror, wenn er nicht gerade nach 5 Sekunden Meckert das ein JavaScript das Anzeigen der Seite verhindert. Mein Windows Test gestern war nicht wirklich fair, da ich das Ding auf dem alten 600 Herzer meine Ma hab laufen lassen, da kam dann der IE erst nach 5 Minuten wieder. Naja, das Suchen geht überraschend performant, es geht hier wohl sehr viel Zeit in das Rendern.

Ferner hat mir das rumgespiele mit JavaScript und DOM mal wieder gezeigt was für tolle Sachen sich doch alles clienseitig basteln lassen und das sogar ohne AJAX. Ich könnte mich jetzt hier hinstellen und das ende von Perl, Ruby und PHP als Websprache vorhersagen, aber das wäre glaube ich etwas verfrüht. Auf jeden Fall ist es für den Benutzer viel freundlicher, wenn man nicht über tausend Seiten geleitet wird nur damit die ganzen Post Queries durchkommen und es ist auf jeden Fall schneller, den Client die Sachen rechnen zu lassen.

Zusammenfassung: JSON ist cool als Datenformat, Opera ist der schnellste JavaScript Auswerter/Renderer auf Linux und weg vom Server, zurück zum Client.


fuseftp: Implementing userspace filesystems with Perl

Well, as I mentioned earlier, 2.6.14 has this nifty new FUSE feature, allowing the implementation of a file system in userspace. Unfortunately, there was no implementation of a FTP filesystem. Fortunately, there are Perl bindings for FUSE :-).

One can implement a userspace filesystem using the whole power of Perl, and that makes it quite easy. I implemented a basic ftp filesystem this morning, which uses Fuse.pm and Net::FTP to allow read only access to ftp servers. It works quite well and was really easy, so this might be the beginning of a couple of nice userspace filesystems written in Perl. I could actually create MegasusFS….

BTW, you can download fuseftp from my wiki page.

Usage is quite easy, you can simply:

marcus@hal2000:~: mkdir kernel
marcus@hal2000:~: fuseftp kernel/ ftp.kernel.org &
Successfully logged into ftp.kernel.org
[1] 7150
marcus@hal2000:~: cd kernel/
marcus@hal2000:~/kernel: ls
for_mirrors_only  lost+found  pub  usr  welcome.msg
marcus@hal2000:~/kernel: cd ..
marcus@hal2000:~: fusermount -u kernel/
[1]+  Done                    fuseftp kernel/ ftp.kernel.org

Net::SILC::Client

Once upon a time there was a Linux user group which switched it’s chatting system to SILC. Unfortunately there was no Chatbot available for SILC and the user group had to live without. Suddently, in the beginning of ‘05, somebody had the time to write a bot, called Megasus, which runs inside the Irssi client, which is used by SILC as well. From now on the chat was enriched by nice information provided by a Bot. But Megasus had a problem, (actually the Irssi client when you call fork() inside of it) and it was leaking memory like hell, until the bad Adminstrators where forced to put memory and runtime limits on the machine. This lead to Megasus dying a horrible death every week and really annoyed the author. But then…

Well, I have been looking for real Perl bindings for the SILC Client API for quite a while. The problem is that there are none. Apparantly, nobody took it’s time to write something which would allow something like:

use Net::SILC::Client;
use Chatbot::Eliza;

my $bot = new Chatbot::Eliza( );

sub on_channel_message {
    my ($self, $channel, $nick, $message) = @_;

    if ($message =~ $self->nickname) {
        my $answer = $bot->transform($message);

        $self->channel_message($channel,
                               $nick . ': '  . $answer );
    }
}

my $silc = Net::SILC::Client->new (channels => [ 'silc' ],
                                   nickname => 'NSC');

$silc->set_callback('channel_message', \&on_channel_message);

$silc->connect;

A few days ago, I stumbled over SILC.pm a Sourceforge Project which attempted to create a Perl wrapper for the SILC API. They hadn’t released any code and as the project was founded in 2002 I contacted the authors and asked if they had already done some work, because I started believing that I would have to do this myself. They where really friendly and they had code, but only wrapping some of SILCs Math functions and not really what I needed. So I started writing from scratch.

As of today, you can run the above example and it does what it has to, plus there are a couple of other events that you can handle directly from Perl. As this is my first Perl/C/PerlXS Module I believe that it is leaking memory like hell as well as there are a couple of other problems (vanishing scalars between two function calls is one of them). But it supports all important events (you can set callbacks as this whole system is event driven), lets you issue commands and send private and channel messages. What I need to do to make it a possible frontend for Megasus is that I need an other Event System (for things like fetching RSS feeds) and some other minor fixes, but the major part is done. The Event System is a little bit tricky, as I tried to use Event.pm and running the SILC Main Loop with it which crashed horibly and I’m still not really good in debugging this stuff. And of course, it is lacking documentation (there are two examples which show the main methods as well as some information about the events, but this is not really good). It’s still far away from something I’d release to the CPAN, but If you want to have a look, it’s all in the CVS on Sourceforge.