Blog
Error handling in defer
October 07, 2023
I see periodically people handling errors in deferred calls like this:
func Do() (r Result, err error) {
// ...
defer func() {
err = multierr.Append(err, f.Close())
}()
// ...
}
or another variant:
func Do() (err error) {
// ...
defer func() {
err1 = f.Close(…
read more
Serving a Special Page for a Country
March 04, 2022
As Russia invaded Ukraine I had a thought about blocking access to my pages
from Russia altogether, not as I think that anybody will notice, but just as a
symbolic gesture. Today though, as Russia blocked access to BBC and DW sites
among some others to its hopelessly brainwashed population I decided…
read more
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
View on Putrajaya
August 12, 2013ZeroMQ 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
Cameron Highlands. Sunset.
January 14, 2013
We spent four days in Cameron Highlands in December. Here are some photos of a sunset I took from the balcony of our hotel room.
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 2.00
June 27, 2012
Uploaded RedisDB 2.00 to
CPAN yesterday. It features XS parser which improves performance about 25%. It
still loses to Redis::hiredis in
pipelining mode, but in synchronous mode it is faster.
read more
A point on a map
May 16, 2012
Three and a half years ago while playing with maps on my then new Nokia 5800 I
marked McDonald's somewhere on another side of the planet. Last month I ate
double quarter pounder there, it wasn't that far after all.
I don't use Nokia anymore, it was replaced by HTC Desire with Android. Google
maps …
read more
CyanogenMod
May 13, 2012
Installed CyanogenMod onto my HTC
Desire. It feels like a new phone now, and it takes less memory, so I was able
to install some additional applications. The only problem so far is that I have
lost handwritten Chinese input, which was a very useful feature.
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
Singapore Post
March 17, 2012
As practice shows, it takes about a week to deliver letter from Singapore to Singapore. Today I got long awaited one from ICA -- about half an hour on bus from my home, don't know why it took it so long. Yellow envelope with "PLEASE DO NOT BEND" written in big bold letters on the front sid…
read more
IELTS
March 02, 2012
Today got results of my IELTS test. Overall 7.5 which is not bad, though I
got just 5.5 for speaking. I think I could do speaking better, but it was
next day after my wife gave birth to our son, so I didn't concentrate much on
the test. Maybe I will take it again a couple of months later.
read more
Solyanka
February 03, 2012
Made an attempt to cook Solyanka for dinner today, but got something completely
different due to peculiarities of locally available components. Pickled
cucumbers and Chinese sausages were sweet. The broth wasn't thick enough. On
a
positive side, I had two types of chillies. As a result I created ver…
read more
Christmas hot pot
December 26, 2011
We bought a steamboat couple of weeks ago and it immediately became an irreplaceable attribute of weekend lunches.
read more
Passport
December 26, 2011
Today I finally got a new passport. I applied first in the end of April while
still living in Malaysia. By the end of August, when I was moving to Singapore,
it wasn't yet ready, so I had to apply again here. It seems Russian state
institutes when hiring giving preferences to retards, it took them a…
read more
Nutritious lunch
November 06, 2011
Today for lunch we had delicious and spicy Sichuan food:
read more
Ubuntu 11.10
October 30, 2011
Just upgraded Ubuntu to 11.10. First impression very disappointing. Unity looks
like completely unusable, and installation of gnome-panel doesn't really saves
situation -- it's ugly. Currently looking for solution with gnome, or maybe
will upgrade to Xubuntu. This version IMO is a big step back in u…
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
Modern Perl book available
November 12, 2010
Modern Perl book by chromatic is out.
You can download free PDF version of the book right now, read it, and transfer
some sum to the author later if you like the book and have money. Isn't this
how all books should be distributed?
If you learning Perl, or switching to Perl from the other language, t…
read more
ThinkPad
August 31, 2010
Just a couple of weeks before I moved to Malaysia my Dell XPS M1330 broke down
because of faulty Nvidia chip in it. It was very unpleasant surprise, but
fortunately I had Lenovo IdeaPad S9 as temporary solution. So I disassembled
Dell and saved some space in my luggage.
IdeaPad S9 did its work well,…
read more
What are the most important features of employer
May 09, 2010
Gabor Szabo started the poll for Perl developers What are the 8 most important features of an employer or a job opportunity for you?. Here are my answers with comments sorted by priority:
The company allows and encourages the contribution to open source projects
That's the question of personal fr…
read more
STA driver in Ubuntu
December 01, 2009
I've got new 500G HDD for my Dell M1330 and reinstalled Ubuntu. After
installation I experienced several freezes -- notebook blinked with caps and
scroll lock leds and didn't respond to any keys but power off. Every time
this happened while wireless was actively used. As I discovered, the source
of …
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
The Limits of Control
November 01, 2009
Watched today Jim Jarmusch's The Limits of Control in Avrora. Quite nice. Maybe it's not the best his film, but still it's better than usual boring stuff. I found that sometimes in Avrora you can see original versions of the films without dubbing.
read more
Sunset near Lenexpo
March 19, 2009Catching 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
M*A*S*H
December 14, 2008
Today finished watching M*A*S*H. All episodes from all eleven seasons, and it's took me less than a year.
M*A*S*H on IMDB
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