Monday, December 21, 2009

Saint Perl 2009: Zhuravlev about Regular Expressions

I go on telling about Saint Perl 2009 conference. This time it is a story about Nikolay Zhuravlev and power of Perl regular expressions. I looked forward to this presentation the worst, and it may be the reason, why it appeared to be the worst disappointment.

I expected an interesting story about recursive regular expressions and how they give Perl the power of context-free grammars. (BTW, ask me how. In fact, we should call them Perl context-free grammar expressions, not Perl regular expressions.) But instead the presentation was about boring benchmark graphs for various randomly — well, almost randomly — assembled regular expressions and without any sane resume. (Though he is totally exonerated by the fact, that he is yet a student.)

Thank Darwin, my perverted imagination saved me from deadly bore, since I had been hypnotized by regular expressions the speaker was showing, that resembled.

/(.*)(.*)\2\1/; # a girl
/(.*)(.*)(.*)\3\2\1/; # a mutant girl from Total Recall movie
/(.*)(.*)(.*)(.*)\4\3\2\1/; # a girl with a friend
/(.*)(.*)(.*)(.*)(.*)\5\4\3\2\1/; # a mutant girl from Total Recall movie with a friend

And so on. Ok, you've got the idea. This is what I meant when I wrote about power of Perl regular expressions.

Now I like regular expressions even more.

P. S. I asked Nikolay Zhuravlev if he had read Mastering Regular Expressions by Jeffrey Friedl — the best book about regular expressions I know of — and he answered that he had tried, but it hadn't appeared mathematically precise enough for him. All issues could be avoided if Nikolay had taken this book more seriously.

Saint Perl 2009: Sharifulin about Mojo

On 18. of December I attended the first Perl conference in Saint Petersburg, Russia, Saint Perl 2009. I will tell about my there experience in the next few posts. By the way, on 18. of December 2009 Perl had its 22th anniversary.

In the first post dedicated to Saint Perl 2009 I would like to appreciate the most interesting (in my humble opinion) presentation by Anatoly Sharifulin about Mojo, Mojolicious and Mojolicious::Lite. Mojo and its descendants are convenient Web frameworks for Perl and in Perl. I won't retell the whole Anatoly's story, but Russian-speaking girls (as well as guys) may have a look at his slideshow.

In his presentation Anatoly mentioned the codex of coding guidelines for Mojo, established by Sebastian Riedel, the Mojo developer. Among some stupid and useless statements, such as "It's not a feature without a test" or "No spaghetti code" there is a profound truth there, that burned my brain out: "Every file should contain at least one quote from The Simpsons or Futurama."

Being highly motivated by Anatoly's presentation though not particularly by this guideline, I went to read the Mojo's source code, not to mention that there's no decent documentation for Mojo. And when I found no original quote in one of the source files, I immediately opened a bug. Yes, I'm a bore, that's me all over. Kudos to Sebastian, he fixed the bug in just half an hour! It's the fastest fix for a bug I have ever submitted for a CPAN module :)

Monday, December 07, 2009

PunBB/FluxBB Extension for Private Message Announcements

I have a hobby. I'm an administrator of the forum for Plantarium, a site dedicated to plants of Russia and its neighbors. It's powered by PunBB 1.3.

Someone told me it is hard to notice if there are unread private messages. So I've written an extension to display an announcement, when a new private message arrives. That's how it looks:

Private Message Announcements screenshot

Source Code

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

blah blah blah

Download the source code at Gitorious.

Tuesday, December 01, 2009

IdeaPad S9/S10 WiFi Ubuntu Voodoo

On Sunday I finally got my demicrosofted Lenovo IdeaPad S9 back. I installed Ubuntu Netbook Remix 9.10 (Karmic Koala) on it. Alas! WiFi didn't work. But I compiled a powerful voodoo spell to manage this issue and I am happy to share this magic with you.

First recite this verse.

sudo apt-get update
sudo apt-get install ndiswrapper-utils-1.9
mkdir ~/bcm43xx; cd ~/bcm43xx

wget http://myspamb8.googlepages.com/R174291-pruned.zip
unzip R174291-pruned.zip

sudo ndiswrapper -i bcmwl5.inf
ndiswrapper -l
sudo depmod -a
sudo modprobe ndiswrapper
sudo cp /etc/network/interfaces /etc/network/interfaces.orig
echo -e 'auto lo\niface lo inet loopback\n' | sudo tee /etc/network/interfaces
sudo ndiswrapper -m
echo 'ndiswrapper' | sudo tee -a /etc/modules
echo 'ENABLED=0' | sudo tee -a /etc/default/wpasupplicant

Then use this verse, but slightly modified to avoid warnings about deprecated filenames.

mkdir fixinitrd
cd fixinitrd
cp /boot/initrd.img-`uname -r` ./initrd.gz
mkdir initrd
cd initrd
gunzip < ../initrd.gz | cpio -i --make-directories
echo blacklist b43 >> ./etc/modprobe.d/blacklist.conf
echo blacklist ssb >> ./etc/modprobe.d/blacklist.conf
cd ..
find ./ | cpio -H newc -o > ../initrdfixed
cd ..
gzip initrdfixed
sudo cp ./initrdfixed.gz /boot/initrd.img-`uname -r`

Please backup your /boot/initrd.img-`uname -r` before casting the spell, for it is dangerous kernel magic that can backfire.