Wednesday, July 16, 2008

upgrade pain

Recently I upgrade subversion to 1.5.0 on my WinXP box. but GOD, that's not working with svn+ssh at all. It's too painful to point out the plink is not working in svn 1.5.0 as before.

Sphinx 0.9.8 is out. but I think I would upgrade it after 1 week or more.

upgrade is painful.

Thanks.
Monday, July 07, 2008

tip: one line force install CPAN module

$> perl -MCPAN -e 'force("install","Foorum");'

that's it. Thanks.
Tuesday, June 17, 2008

3 day 3 release

CPAN generally means responsibility. I released 3 Foorum distribution in the last 3 days.

CPAN means better document. so I tried to use DBICx::AutoDoc to create docs for Foorum::Schema. it's a bit different from the original method in DBICx::AutoDoc. I changed a bit to write pod into Schema files directly.

code are:(briefly)
my $ad = DBICx::AutoDoc->new(
schema => 'Foorum::Schema',
output => File::Spec->catdir($Bin, '..', '..', 'docs'),
);

# rewrite the Schema pm POD
use Template;

my $tt2 = Template->new( { INCLUDE_PATH => $ad->include_path, POST_CHOMP => 0, PRE_CHOMP => 0 } );
my $vars = $ad->get_vars;

# first get the lists of all Foorum::Schema pm files
my @sources = @{ $vars->{sources} };
foreach my $source (@sources) {
my $class = $source->{class}; # Foorum::Schema::User

# make file dir
my @parts_of_modules = split('::', $class);
$parts_of_modules[-1] .= '.pm';
my $file_dir = File::Spec->catfile( $Bin, '..', '..', 'lib', @parts_of_modules );

my $output;
$tt2->process('pod.html', { source => $source }, \$output)
|| die $tt2->error(), "\n";

# replace POD in real module
open(my $fh, '<', $file_dir);
local $/ = undef;
my $in = <$fh>;
close($fh);

my ($code, $pod) = split(/\n1;\n/, $in);
open(my $fh2, '>', $file_dir);
print $fh2 "$code\n1;\n__END__\n\n$output\n";
close($fh2);

print "working on $class\n";
}
Full code can be found in http://foorum.googlecode.com/svn/trunk/bin/misc/dbicx_autodoc.pl

Thanks.

Labels:

Sunday, June 15, 2008

Father's Day

Foorum 0.1.5 release

Finally I release the Foorum 0.1.5 after 2 months later.

CHANGES:
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 http://foorum.googlecode.com/files/Foorum-0.1.5.tar.gz

and I uploaded to CPAN too.

Thanks.

Labels:

Friday, May 23, 2008

use INT(11) instead of DATETIME for time

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 date.now, u need wrap date.now 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: http://foorum.googlecode.com/svn/trunk/bin/upgrade/0.1.5/up.pl

Enjoy.

Labels:

Friday, April 11, 2008

Catalyst trap: param and params

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'),
};
$c->res->body(Dumper(\$test));
}
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'},
};
$c->res->body(Dumper(\$test));
}
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.

Labels:

my shell history

-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
Thursday, April 10, 2008

please support Perl in Google App Engine

http://code.google.com/p/googleappengine/issues/detail?id=34

star it please. so that we will have a free Perl host by Google!