Posts

Console fonts with good looking Japanese and Cyrillic

Image
Finally! A set of fonts that look good and properly display Japanese and Cyrillic. That is, the Cyrillic is half-width as it is supposed to be. For Gentoo users the package is media-fonts/efont-unicode or there is the official page for everyone else. Some characters like the lowercase б and д are oddly designed but that's a very small price to pay for the pleasure of not having to mix and match different fonts in my terminal configuration. I wish I'd known that a little earlier.

Incredibly slow built-in SD card reader on Thinkpad x60

The built-in SD card reader on my Thinkpad x60 has been always giving me headaches. It works reliably well, but when copying files my system becomes very unresponsive. The mouse is jerky and the CPU usage jumps through the roof. Obviously, DMA is not being used. I couldn't find much about it for a while but just today, when I included the chip id R5C822 of the reader in the search I found this thread . However, instead of patching the source itself, it is quite easy to force the quirk when loading the sdhci module. Put the following in modprobe.conf or /etc/modprobe.d/local.conf and everything will be fine after you reboot. options sdhci debug_quirks=2 You can also reload the module to check if it is fine even now. umount any SD cards that you have mounted modprobe -r sdhci-pci modprobe -r sdhci modprobe sdhci-pci That's all folks. Enjoy a true multitasking Linux.

grub2 cannot read core.img

When trying to install grub2 (whatever snapshot was current as of today) I kept getting the following error: $ sudo /sbin/grub-setup -v --directory=/media/sysrescd/boot/grub \ --device-map=/media/sysrescd/boot/grub/device.map -r '(hd1,1)' '(hd1)' .... snip ... grub-setup: error: Cannot read `/media/sysrescd/boot/grub/core.img' correctly The error was not very descriptive because grub was apparently able to read other important files like boot.img and such. The filesystem on my USB stick was identical (feature wise) to the /boot on my HDD -- ext2. And the same command worked just fine for installing to my hard disk. Digging through the code revealed where the problem is. The error was caused by grub-setup being unable to embed core.img in the MBR. The core.img prepared by grub-mkimage was 25k big. That is about 50 sectors. The first partition on my hard disk starts on sector 63. The first partition on my USB stick was starting on sector 32 (or was it 31?). 32 <...

Bloody OpenBSD syslogd

I spent quite some time today trying to figure out why, oh why, syslogd doesn't want to log to a remote log host. The config file on the machine was identical to that on other machines that worked just fine. Long story made short, that particular version on that particular system didn't like having an IP address after that @ sign. A hostname worked fine. The syslog on our other redhat machines didn't care. I don't know what the reason is yet. Could it be that syslog works the same way on both machines and just does a gethostbyname on whatever is after the @ sign, and glibc gives an answer for the IP address while libc on BSD does not? Whatever the reason, bloody syslogd should at least log an error somewhere. Or a warning. Or whatever.

Switching to Gnome

Me, a long-term Windowmaker user, recently switched to Gnome. There main reason is that I had wanted to drop Windowmaker for a while now. There has been no development for a while now and I don't really like the fonts or the lack of themability of window borders and such. I decided to give Gnome a try because I've always liked the appearance of Gtk applications and a full Gnome desktop can run without having to run a zillion processes in the background. I have looked at KDE but it just doesn't feel right. One feature I really liked in Gnome was the automounting of removable media. It didn't work smoothly because there are a few prerequisites: Your user must be in the plugdev group You must not have an entry for the device in /etc/fstab The last one is mostly speculation, but when I removed the lines in /etc/fstab (leftovers from the windowmaker era) it all started working. I still prefer the Windowmaker style Alt+<Right Click and Drag> to resize a window. With...

Setting the onSubmit handler with JavaScript

A common issue -- setting the onSubmit event handler of a form with JavaScript. I mean, it's easy enough to set it with <form id='theForm' onsubmit="return confirm('Really submit?');"> but here is how to do it with JavaScript <script type='text/javascript'> document.getElementyById('theForm').onSubmit = function() { return confirm('Really submit?'); }; </script>

Parsing HTML with Perl and XPath

I have had to write an HTML parser a few times already and I've always used HTML::Parser . Because it's simple and because I never bothered to do it anohter way. I always wanted to ideally do some parsing with XPath because that way I can easily find what I need with one or two queries. Unfortunately, XPath only works on properly formatted XML documents, so unless the page I am parsing is XHTML, I couldn't do much. I also wanted to somehow convert the HTML to properly formatted XHTML and use XPath with that. Unfortunately, I didn't know an easy way to do that either. Well, now I do. I can use the HTML::TreeBuilder module from HTML-Tree CPAN distribution. It is easy enough to use the module itself for parsing: my $tree = HTML::TreeBuilder->new_from_file("test.html"); my @img = $tree->look_down('tag', 'img', sub { $_[0]->attribute("src") =~ m!thumbnail!; } However, as I would rather use XPath, here is how to easily convert t...