Saturday, November 29, 2008

Devel::NYTProf

Devel::NYTProf is the best dprof tool in Perl land. it's really easy to install, configure, run and read the results.

just be careful with Catalyst Application (which use NEXT), it can't be ran under 5.8.6
you need 5.8.8 or 5.10.

run under modperl 1/2 is simple with Devel::NYTProf::Apache.
it writes files under /tmp and you can mv it to your place and run nytprofhtml on it.

what in result page is:
Calls is how many times it's called.
P is Number of Places sub is called from
F is Number of Files sub is called from
Exclusive Time is time in sub excluding subs it called
Inclusive Time is time in sub including subs it called

it really helps me a lot. Thanks, Tim.

Labels:

Wednesday, November 19, 2008

Learn Mojo 1: start a project and a bit more

Mojo is created by sri, the one who created Catalyst.
since sri is very SMART, we should follow him a bit.

Mojo is not a web framework. it is "a collection of libraries and example web frameworks for web framework developers.". u can treat it as something like Catalyst::Engine or HTTP::Engine.

but Mojolicious is a web framework built on Mojo.

install Mojo should be very simple and it doesn't have the half of CPAN. :)

start a project based on Mojolicous, you just type:
mojolicious generate app DayDayUp
cd day_day_up
perl bin/day_day_up deamon
then you can view a sample through http://127.0.0.1:3000/

it's like Catalyst but it's really much more faster than catalyst server.pl

Mojolicous is still in its early stage. but luckily, we have MojoX::Renderer::TT by ask.

something inside:
1, in Controller $c, it is an instance of DayDayUp::Context which based on Mojolicious::Context.
check http://fayland.googlecode.com/svn/trunk/CPAN/day_day_up/lib/DayDayUp/Context.pm
we added config and dbh there. after this, you can call $c->config and $c->dbh in controller like
http://fayland.googlecode.com/svn/trunk/CPAN/day_day_up/lib/DayDayUp/Notes.pm
it's very flexible. you can add DBIx::Class there, it's not a problem.
2, routines. you don't have any :Global :Regex :Chained in Mojolicous. instead, we defined all those url mapping things in DayDayUp.pm sub start.
http://fayland.googlecode.com/svn/trunk/CPAN/day_day_up/lib/DayDayUp.pm
indeed, I like it. :)
remember it has an order. so you should put the default at the last of routines like
    # route
$r->route('/notes/:id/:action', id => qr/\d+/)
->to(controller => 'notes', action => 'index');
# Default route
$r->route('/:controller/:action')
->to(controller => 'index', action => 'index');

set ENV MOJOX_ROUTES_DEBUG on that you can debug the dispatch.
(1) / is matching ":/controller/:action" with default controller => 'index', action => 'index'
(2) /notes is matching ":/contorller/:action" with controller to be notes and action still be index.
(3) /notes/add is matching ":/controller/:action" with controller "notes" and action "add"
(4) /notes/1/edit is matching '/notes/:id/:action' with action as edit.
much much more you can find it here: Mojo::Manual::Mojolicious
it's simple but powerful.

I'll write more next time. but it's for now.

Thanks.

Labels: ,

Monday, November 17, 2008

Window git and mojo

download the win git from http://code.google.com/p/msysgit/

and try
git clone git://github.com/kraih/mojo.git mojo

I'm playing the Mojo from today. and I'll post more later.

Thanks.

Labels: ,

Sunday, November 09, 2008

photos of diudiu

my wife and I took my son to a photograph shop 1 month ago. diudiu was 6 months.

http://picasaweb.google.com/fayland/DiudiuZhaoyuan

Labels:

Thursday, November 06, 2008

Padre committer

if you are following padre, you may find that I'm a committer now.

[fayland@alpha padre]$ svn log | perl -MData::Dumper -n -e'if (/^r\d+\s*\|\s*(\w+)\s*\|/) {$c{$1}++} END {print Dumper \%c}'
$VAR1 = {
'tsee' => 19,
'adamk' => 90,
'fayland' => 12,
'patspam' => 6,
'bricas' => 2,
'szabgab' => 538
};

mainly I'm contributing something like follows:
* Wx::Choice ->SetSelection(0);
* add test 82-plugin-manager.t and cleanup _load_plugin in PluginManager.pm
* highlight with PPI for Perl5
* remove "no output" in ack
* Limit the search_terms/replace_terms
* add main_files_pos to goto last pos for those left files.

some are trivial and some are important. I feel proud with those commit.

and I update the plugins list a lot. now I have 7 plugins for padre.
Padre-Plugin-AcmePlayCode-0.02 Acme::PlayCode Plugin for Padre
Padre-Plugin-CPAN-0.01 CPAN in Padre
Padre-Plugin-PluginHelper-0.02 make building Padre plugin easy
Padre-Plugin-TabAndSpace-0.05 convert between space and tab within Padre
Padre-Plugin-Validator-0.02 validate HTML/CSS in Padre
Padre-Plugin-ViewInBrowser-0.01 view selected doc in browser for Padre
Padre-Plugin-WordStats-0.02 Word stats for Padre

Padre-Plugin-PluginHelper is useful to develop a new plugin, it loads plugin from a local dir, and it can be reloaded after change.

so start to play with padre, and tell us what you think. :)

Thanks.

Labels: ,

Monday, November 03, 2008

Padre::Plugin::WordStats and Padre::Plugin::Validator

writing Padre plugin is really easy and a lot fun.

I wrote another two today.
one is http://search.cpan.org/perldoc?Padre::Plugin::WordStats - count how many words, lines, chars (with or without) spaces.
the other is http://search.cpan.org/perldoc?Padre::Plugin::Validator - validate editing HTML/CSS in Padre

well, it may be not a big deal, but I'm using them in my daily life. so I like it.

start use padre and my plugins. :)

Thanks, Enjoy!

Labels:

Padre::Plugin::TabAndSpace

Padre::Plugin::TabAndSpace is to convert tabs to spaces OR convert spaces to tabs.

start use padre and my plugin, enjoy.

Labels:

Sunday, November 02, 2008

Padre::Plugin::AcmePlayCode

Padre::Plugin::AcmePlayCode is nothing big deal. it's just a mixin of Padre and Acme::PlayCode.

now you can
* convert double to single
* exchange condition
etc. in Padre.

and I had submitted two patches to Padre developers.

Padre is nice, just start using it!

Thanks.

Labels: ,

Saturday, November 01, 2008

credit card and dreamhost

after I waked up and got online this morning, I found my dreamhost is moved to another server with "unlimited bandwidth and unlimited disk". and it's new, it's 64 bit. BUT all the XS module are not usable now. I removed the perl5 dir in my /home then download local::lib and setup it, then start to re-install all my modules. OMG, it's VERY fast. I'm not sure if that's because not so many people use the new machine or the 64 bit fasten it, I'm glad with that.

dreamhost is cheap. and I'm really happy with it. I have those sites on:
http://www.foorumbbs.com/ - the instance of Catalyst Foorum module.
http://blog.foorumbbs.com/ - blog Foorum
http://docs.foorumbbs.com/
http://irclog.foorumbbs.com/?C=M;O=D - irc log
http://planet.foorumbbs.com/ - Planet Perlchina, used by http://feeds.feedburner.com/CNPerlPlanet, subscribe it!

another thing, my first credit card from http://www.cmbchina.com/ got expired today. I use it to buy my dreamhost and buy things online. I love it indeed.

Thanks.

Labels: ,

Perl Testing程序高手秘笈

the Perl Testing book translated by chunzi and joe is available to buy online now.

http://www.douban.com/subject/3249023/

go and buy one now!

Labels: