Monday, June 17, 2013

Snake classic arcade game on Arduino

Tuesday, April 30, 2013

Weird lacuna in Perl

While you can

$ perl -Mstrict -wle 'foreach our $var (0, 1) { print $var }'

and of course

$ perl -Mstrict -wle 'foreach my $var (0, 1) { print $var }'

foreach local raises an error:

$ perl -Mstrict -wle 'our $var; foreach local $var (0, 1) { print $var }'
syntax error at -e line 1, near "foreach local"
Execution of -e aborted due to compilation errors.

P. S. And in case you wonder what lacuna is.

Saturday, October 16, 2010

Time::Piece's Missing Part

Time::Piece is a great module. The only thing I really miss in it is a truncate method, similar to the one that DateTime has. Fortunately it is quite easy to add it to the original distribution.

I've written a monkey patch, but I look forward for this method in the future versions of Time::Piece.

use strict;
use warnings;

use Time::Piece;

local *Time::Piece::truncate;
*Time::Piece::truncate = sub {
    package Time::Piece;
    my ($time, $to) = @_;
    my @t = (0, 0, 0, 1, 0);
    return $time->_mktime([@t[0..$to-1], @$time[$to..c_isdst]], $time->[c_islocal]);

my $now = Time::Piece->gmtime;
my $midnight = $now->truncate(Time::Piece::c_mday);
print $midnight, "\n";

Wednesday, May 05, 2010

Online image resizing service

Check out my application powered by Google App Engine. It is a truly online image resizing service. I'm planning to open its source code if there's interest for it.

Friday, February 12, 2010

PHP Creole 1.0 Wiki Markup Parser

I translated my JavaScript Creole 1.0 wiki markup parser in PHP.

I did it specially for making a wiki suitable for free web hosting. Just because alike most Russians, I experience irrational affinity to costless products and services.

You can see the wiki in action at or download its source code at Gitorious, the best source hosting service. The source code is distributed under the MIT/X11 License.

UPDATE: There is also a mirror at GitHub now.

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 :)