Foorum 0.1.5 release

15 June 2008

Finally I release the Foorum 0.1.5 after 2 months later.

1, Foorum::Search with backend Foorum::Search::Database and Foorum::Search::Sphinx
2, change DATETIME to INT(11) for tables.

it's a release for my little boy diudiu. :)

u can get it from

and I uploaded to CPAN too.


Father's Day

15 June 2008

use INT(11) instead of DATETIME for time

23 May 2008

well, don't use DATETIME or DATE in database for time, use INT(11) UNSIGNED instead.

the benefits are:
1, u don't need care about MySQL or SQLite or others. NOW() is used by MySQL while CURRENT_TIMESTAMP is used by SQLite. that's important while u developer in MySQL and write test cases by SQLite.
2, compare. while in TT, if u want to compare topic.time with, u need wrap by String.Compare or convert topic.time to int. that's not so easy. and date.format can convert INT to any format u want.

I spent some hours to do the upgrade for Foorum.
and the upgrade pl is simple: create a temp column then update as UNIX_TIMESTAMP, then drop old column and rename temp column.

code is here:


my shell history

11 April 2008

-bash-3.00$ history|awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}' |sort -rn|head
290 perl
235 svn
67 ls
60 screen
46 vim
27 mysql
25 cp
23 rm
22 ps
22 exit

Catalyst trap: param and params

11 April 2008

well, if we write code as follows:
sub test : Local {
my ($self, $c) = @_;
my $test = {
a => $c->req->param('a'),
b => $c->req->param('b'),
c => $c->req->param('c'),
then try to visit test?b=1, guess what we get? that's not what we expected.
$VAR1 = \{
'1' => 'c',
'a' => 'b'
a weird result!

please use follows, that's much better.
sub test : Local {
my ($self, $c) = @_;

my $test = {
a => $c->req->params->{'a'},
b => $c->req->params->{'b'},
c => $c->req->params->{'c'},
and get what we want:
$VAR1 = \{
'a' => undef,
'b' => '1',
'c' => undef

so do remember that. and don't write dbix insert/update code like that.

I have a son

07 April 2008

My son (nickname: diudiu 丢丢, formal name: 林锦喆) was born a week ago on April Fool's Day (4.1) and weight was 3kg. I'm pretty happy with that. I'll upload some photos later. :)

memcached for Windows

19 March 2008

Catalyst Tip: bind STDOUT with res->body

14 March 2008

sub test_body : Local {
my ($self, $c) = @_;

print "a\n";
print "b\n";

I think that's pretty useful when u are trying to use "Benchmark" module (or others use STDOUT).

Have fun!


05 March 2008

Thanks for my college CY.

UNIX_TIMESTAMP(birthday) is not working when birthday is before 1970.
I should use TIMESTAMPDIFF(DAY, '1900-01-01', birthday) to get the DAY or SECOND
mysql> select TIMESTAMPDIFF(DAY, '1900-01-01', '1998-05-01');
| TIMESTAMPDIFF(DAY, '1900-01-01', '1998-05-01') |
| 35914 |

in Perl, we can do:
use Date::Calc qw/Delta_Days/;
print Delta_Days(1900,1,1, 1998,5,1);

something about Sphinx indexer

02 March 2008

Sphinx is just another search engine. something like Xapian.

I'm rebuilding the search function for Zorpia these days. the user table is somehow 9,000,000+, it's pretty slow to query SQL directly. so we guess we need use a search engine to rebuild our search function.

Xapian and Sphinx is coming into our eyes. frankly we don't know much about them. I just spend some hours on Sphinx (haven't do Xapian index yet. but both are installed) and find the indexer part in Sphinx is pretty easy to understand and configured. u just need write a conf and Sphinx indexer will take care of the left. I'm pretty happy with this. anyway, someone will say that's not controllable. but it's OK when it meets our demand.

I think I'll do Xapian indexer later and do search part of both. But basically the idea behind search engine is somehow the same.

That's it, I'll write more when I'm free.