profile picture

10 pages tagged with "programming"

Sorting Chinese characters

December 28, 2013
<p>Recently we decided to localize country selection list at work and there was some confusion about how to sort Chinese characters. I asked my wife and she told me that sorting by pinyin is seems most reasonable to her. So here's how to do it in Perl read more

ZeroMQ Rant

April 03, 2013
Today deployed at work a new service that based on zeromq. I never liked zeromq because it does not provide any feedback about what is going on, and this is exactly what caused problems. After deployment service worked as expected on all servers except one. Daemon was starting, creating zeromq sock… read more

Packing timeval

December 05, 2012
Recently I got a lot of failures from CPAN Testers for RedisDB on NetBSD i386. After investigating a bit I've found that NetBSD 6.0 comes now with 64-bit time_t on all architectures. It means that the way I used to pack struct timeval value to set timeout on socket, didn't work anymore. Previously i… read more

Memory leaks

October 08, 2012
<p>Spent the whole day looking for sources of memory leaks. One of them was because I decided to use named captures. It so happened that perl leaks some memory if named capture doesn't match. read more

RedisDB 1.03

March 19, 2012
Just uploaded RedisDB-1.03 to CPAN. In this version I extracted parser code into a separate module and cleaned it up a bit, I have in plans writing XS version of the parser. Another significant change is that I dropped Module::Install and switched to plain ExtUtils::MakeMaker. The size of the distri… read more

RedisDB 0.16

July 13, 2011
Just uploaded RedisDB 0.16 to CPAN. Hopefully now it will work on Windows. The problem is that Windows don't support MSG_DONTWAIT flag for recv, so I have to switch socket into non-blocking mode before checking for data. And I got just a single test report for MSWin32 for three months, apparently it… read more

Creating preforking server with POE::Component::Daemon

November 28, 2009
After upgrading Perl to 5.10.1 at Friday I found that POE::Component::Server::PreforkTCP, which we use in one of our products, doesn't pass its tests anymore. Perhaps it's possible to fix, I don't know yet (it was Friday evening...), but as the module hasn't been updated since 2002 I decided to chec… read more

Catching a Leap Second

January 01, 2009
As you may know there is such a thing as a leap second, and Dec 31 2008 is a day with a leap second. A couple of hours before New Year I got an idea to catch this leap second. The problem is that Linux uses Unix time and thus ignores leap seconds. Hence if you use time(2) or gettimeofday(2), the lea… read more

More about UTF-8

August 02, 2008
Now suppose you want to rid string of malformed utf-8 characters. Here is an example that checks an utf-8 string and replaces all malformed characters with '?'. The same idea as in the previous post. Note, that it checks only encoding, it is possible that encoding is correct, but the symbol doesn't … read more

How to truncate UTF-8 string

July 16, 2008
<p>Suppose you need to put UTF-8 string into a fixed length buffer. Actually I was in need to do this. Problem is that the last symbol may be incomplete, so here is the example how to do this read more