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.

#!/usr/bin/perl
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 110mb.com 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 110mb.com 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.