Mon, 28 Jan 2008
Pete Zaitcev mentions an interesting programming challenge (read on only if you have several minutes of free time, so that you can try it yourself):
Write on paper, as fast as you can, a program, which prints out the numbers from 1 to 100, but instead of numbers divisible by three it prints "Fizz", instead of numbers divisible by five, it prints "Buzz", and instead of numbers divisible by both 3 and 5 it prints "FizzBuzz".
Pete mentions that even some comp.sci graduates cannot solve this problem. The difficulty of course varies with the programming language used. My own solution in C took me about 3.5 minutes, and the short part of this time I have not been busy writing I spent thinking about a clever way of doing it using conditional expressions in one command, instead of writing the obvious solution.
Anyway, here is the original FizzBuzz article, and there is also a Golf challenge: I am at 60 characters now (in Perl, of course), but they do not accept the command-line switches, so the actual solution has 63 chars instead.
Wed, 23 Jan 2008
In our cluster, we run various instances of Apache on different ports. When we need another instance, we just add it to all cluster nodes to the next free port. We have started at ports 80 and 443, respectively, and now we use ports up to 88 and 451. And this is where the problem starts:
The Apache instances are usually accessed at port 80 or 443 of the cluster
IP address, which is then forwarded by IPVS to the appropriate cluster
node and port. However, from time to time we need to access the Apache
instance directly. To my big surprise, the URL
does not work in Galeon (altough
wget can access it without problem). Galeon says that
the server has dropped the connection. It is not true:
tcpdump does not
show any outgoing packet from my machine to the port 87.
The fix is simple, at least for Galeon: add the following line
to your preferences (for my Galeon, it was the
Apparently, all other browsers (not only Gecko-based ones) have this behaviour. They just refuse to talk to services running on port 87 (and some other ports like 21, 22, 25, etc.). I wonder how these ports have been chosen, because some other well-known ports like 136-138, and 445, are not on this list.
Tue, 22 Jan 2008
I have got a cheap fingerprint reader (thanks Juraj!) and I have played a bit with it:
(image from this digitaltechnews.com article). It is an USB device, and it works surprisingly well with Linux. There is a comprehensive HOWTO available, but I will try to summarize steps needed for Fedora Linux:
- Run "
yum install thinkfinger". This is a set of user-space tools and a PAM module for this reader.
- If you do not have a distribution kernel, compile the
uinputmodule in (under
- Make sure your root filesystem is mounted with the
acloption (if not, run "
mount -o remount,acl /").
- Now you can play with
tf-tool --verifyand see whether the scanned fingerprint matches. From time to time I see the
usb_bulk_readerror mentioned here, usually running
- Using "
tf-add --add-user logname" add your fingerprint to the system database.
- Configure PAM. I have added the boldface text into
auth sufficient /lib/security/$ISA/pam_thinkfinger.so
auth sufficient /lib/security/$ISA/pam_unix.so likeauth nullok try_first_pass
- Run "
modprobe uinput" as root.
- Restart your display manager using
init 3, wait few seconds, and then
- And that's it: user which has been added using
tf-tool --add-usershould be able to login with his finger now! In Fedora, HAL manages access control lists of devices, so a separate group
fingerprintas described in the HOWTO above is not necessary.
So far I think this technology is interesting, even though it is not always
100 % reliable. It is however usable for
local logins only. It would be nice if more local apps such as
ssh-askpass or Revelation
can use it.
Mon, 21 Jan 2008
What Is Luminance?
I have recently enhanced my scanned form recognition software in IS MU to handle not only greyscale scans, but also color ones. It is quite simple - the software converts the image to greyscale in the input phase. During tests, we have found a problematic input file - it has been recognized differently when scanned greyscale than when scanned in full colors. Before reading on, look at the image below and try to decide what number should the software see there:
I think the correct output should be the digit "3", with the previous
digit being recognized as rubbed out. Now look at the
color version. There are
three variants there: the first one is the output of the scanner in the color mode,
the second one is the color scan converted to greyscale (using
ppmtopgm(1) give similar results), and the last variant
is the scanner output in the greyscale mode (as seen in the image in this
Apparently the conversion to greyscale is not as simple as, for example,
averaging the three color channels:
ppmtopgm(1) source code they refer
to the ITU-R BT.601.5 standard, which states that the luminance value
(essentially the grey level of the greyscale version of the image) should
be computed using the following formula:
0.2989*R + 0.5866*G + 0.1145*B
I guess the scanner does something simpler than using this formula, which leads to suboptimal results. When the requirements to the recognition software are "it should recognize what human would see in the scanned image", I think it correctly recognizes the greyscale scan as "3", and the color scan as "23".
Thu, 17 Jan 2008
Yesterday's Hyena writes about the robotic vacuum cleaner. I have looked into this (having the flat cleaned when you are away looks tempting :-), but I think I need more references.
- I did not find whether it is available in the Czech republic (well, there is www.irobot.cz, but it seems outdated and there are even no newer models).
- Or, can it be bought somewhere with the Czech wall plug inlet and the European warranty?
- I have read the robot is quite noisy. Is it true?
So, my dear lazyweb - do you have Roomba or some other vacuum cleaning robot? Where did you buy it? And would you recommend it?
Thu, 10 Jan 2008
From PalmOS to Maemo
After Vlasta has left, I have got his Nokia 770 to play with. I am even thinking about replacing my Palm T5 with it eventually, as the synchronization with my desktop has ceased to work in the last few months (the Palm is not visible as an USB device anymore except when in the Drive mode). So far my experience is mixed:
The good thing is that it is has a real OS (Linux). Things like
screen etc. work,
as well as reading plain text files, etc. It also has WiFi and
a real WWW browser.
Unlike PalmOS, it has two power-saving modes: in one it has the display and keyboard switched off, but the OS is working. This mode can be entered or left almost instantly. However, in this mode, the battery lasts only for two days or so, even when not doing anything with the device. The other mode is full Linux shutdown, but this takes about 20 seconds to boot the device again.
It is slow. The apps start much longer than in PalmOS. However, it is a true multitasking OS, so the audio playback works even when another CPU-intensive task is running.
It has a RS-MMC slot, which supports 1 GB cards only (2 GB with firmware upgrade), but the device itself has only a 64 MB card, while my Palm has 2 GB SD-card). I use my Palm as an audio player as well, so the available filesystem space is important.
It has a huge repository of software at maemo.org. However, the system userland is not nice - they have several versions of the system image (OS 2005, OS 2006, OS 2007, etc.), and only 2005 and 2006 versions are production-stable on 770. Some apps work only on later systems.
I miss some PalmOS apps, especially PAdict (an excellent Japanese dictionary), and AutoBase (a vehicle usage tracking database). Fortunately, there seems to be a closed-source PalmOS virtual environment for Maemo, which I want to try.
I have yet to find a good PIM application suite with working and easy to use desktop counterpart (as jpilot was for PalmOS PIM). I ahso have to find out how to export the existing PIM data from PalmOS and import it to Maemo.
Overall I think n770 is not a bad device, but has a slightly different purpose than Palm. I will probably try to buy a 2 GB flash card and replace the T5 with it.