THE WORLD DISCUSSES #PYTHIAN ON TWITTER. HAVE A QUESTION? USE OUR HASHTAG AND ASK AWAY.

Chained Actions with Dancer

Sometimes, I can be slow on the uptake.

A few days ago, had you asked me one big plus of Catalyst over Dancer, I would have said “chained actions”. Chained actions allow to split the logic underlaying an uri into smaller components associated with its segments. A very neat, DRY-friendly ways of doing things.

Read the rest of this entry . . .

Getting Around Expiration Dates via Reincarnation (and Catalyst)

Web applications typically have a bunch of static files — images, css and javascript, that kind of stuff — that almost never change. For all but the simplest apps, it’s usually a good idea to let the browser know that it can cache and reuse those files, so that we can all save a little bit of bandwidth and get things moving a wee bit faster. Read the rest of this entry . . .

Profiling Catalyst’s Requests Memory Consumption

Thanks to Catalyst::Stats, it’s already a breeze to profile the time taken by requests, and last week I found myself looking for the same kind of profiling ability for memory usage. A quick look around made me discover the dynamic duo Catalyst::Plugin::LeakTracker and Catalyst::Controller::LeakTracker, but they were not exactly what I’m looking for. So… say hi to Catalyst::Plugin::MemoryUsage.

Read the rest of this entry . . .

Blog-Agnostic Widgets

Please, someone stop me if this has already been done elsewhere…

While I was raking the leaves yesterday, I was entertaining thoughts about new widgets for Galuga. From there, I began to think that while there’s a thousand and one different blog engines out there, it’s kinda silly that, for each of them, we re-write almost-identical HTML and Javascript for the different widgets and badges we adorn them with. Wouldn’t be be nice if there was a standard way to write those widgets so that we they could be used and shared across all Perl blog engines?

Cue in WWW::Widget, probably the most trivial API ever designed. Written as a Moose Role, it requires from wannabe-widget classes only two things: that they pass all configuration elements at object-creation time, and implement a as_html() method.

And that’s pretty much it. The role auto-wraps the HTML generated by as_html() in a <div> with two classes, WWW-Widget and WWW-Widget-ThisWidgetClass so that the display can be controlled via CSS. And, for the laziness-inclined, the role also overloads the object’s stringification to be an alias to as_html().

Bottom-line, in Galuga (which uses Catalyst and Mason), I can now take care of my widgets by having the following in my configuration:

<widgets>
    <PerlIronMan>
        id yanick
    </PerlIronMan>
    <Twitter>
        username yenzie
    </Twitter>

</widgets>

and put this stanza in my template:

% while ( my ( $widget, $conf ) = each %{ $c->config->{widgets} } ) {
%   my $package = 'WWW::Widget::'.$widget;
%   eval "use $package; 1" or next;
%   $conf ||= {};  # in case there's no configuration item
    <% $package->new( %$conf ) %>
% }

The module is not yet available on CPAN, but should be soon (as soon as I distributionify the code, slap a little bit of documentation on it, and make sure I’m not reinventing an already existing wheel).

Catalyst::Plugin::Sitemap

I hadn’t planned on writing this. In fact, I positively don’t have the time to write this. But, sometimes, the only mistake a man has to make is to pause one second and wonder hey, wouldn’t be cool to have something that auto-generates the sitemap of a Catalyst app? And then BAM! The yak jumps out of nowhere, hangs to the poor sod’s t-shirt with all hooves and forcefully moos “shave me, shaaaave me” until the silly git succumbs to the pressure.

Oh well. On the sunny side, I’ve now written my very first Catalyst plugin, and it’s going to be something useful for Galuga.

Read the rest of this entry . . .

Shuck & Awe #12: Hunting for Perl

[yanick@enkidu shuck]$ perl -MO=Deparse news.pl

Holy mackerel, use.perl.org is shutting down! Pudge is changing jobs and, as his now-previous $workplace was hosting the site, he is temporarily shutting down the site. Breath easy, though, the blog entries are not all going to disappear in a puff of smoke — the site will be put in ‘static’ mode for the time being, and there is the possibility it will reappear somewhere else. Love it or hate it, use.perl.org was one of the first and major Perl blog hubs, and it served the community well during the last 10 years. I, for one, can honestly say it’ll be missed (and yikes!, I better make sure all my old blog entries have been extracted and locally saved).

Have a function that returns sometimes a scalar, sometimes an array? The Schwern asks: “why not use Parcels?” He’s taken the Perl 6 Parcel data structure and ported it to Perl 5.

dagolden is fiddling with Perl’s guts to have the core array functions (push, pop, shift and friends) to DWIM on array references. His end-goal is to be able to do without the noisome array de-referencing in situations like this

my %foo;
push @{ $foo{bar} }, 'a'...'z';

print $foo{bar}[0];   # prints 'a'

and instead directly do

my %foo;
push $foo{bar}, 'a'...'z';

print $foo{bar}[0];   # also prints 'a'

Nifty new rad feature, or yet another yard of rope to hang ourselves with? The jury is still out (personally, I’m on the oooh, shiny side).

Remember cpans from Shuck & Awe? Well, Cornelius reminds us that there’s also a Pure Perl version of the tool, and he goes on writing a third version in Bash, for the sake of completeness.

Dave Cantrell managed to merge CPAN with a TARDIS and gives us CP2000AN, a view of all the distributions (with at least one successful test report) that were on CPAN as of the beginning of 2000. And there’s more. For like a TARDIS moves in space as well in time, his CP???AN space-time distorting machine also provides us platform-centric views of CPAN. Only want to see distributions working on Cygwin? There is CPcygwinAN. Only want CPAN distributions working on Perl 5.8.8 on irix? There is CP5.8.8-irixAN. You want a view of CPAN for Commodore 64? There is– Darn. There’s not a view for that one yet.

No-one can stop the march of progress. Perl 5.12.2 is out. No mind-blowing new feature this time, but a lot of good healthy bug fixing.

Andy Gorman introduces a new Catalyst controller called Catalyst::Controller::DirectoryDispatch. I’ll let your imagine run wild and try to come up with what functionality it performs (but I’ll nonetheless give you a hint: it’s pretty much does what it says on the can).

First there was constant. Then there was Readonly. Now Leon Timmermans brings us a new constant module: Const::Fast. It’s clean, it’s simple, it’s fast, and it doesn’t use XS or any other dark shenanigans. Clearly, a credible contender for the conveted credentials of chief constant creator.

And lastly, to leave this edition on a cheerful note, chromatic takes time to stop, smell the flowers, and discuss what’s going right in Perl.

[yanick@enkidu shuck]$ perl -E'sleep 2 * 7 * 24 * 60 * 60 # see y'all in 2 weeks!'

Shuck & Awe #9: Hunting for Perl

[yanick@enkidu shuck]$ perl -MGit::Wrapper \
    -E'say for Git::Wrapper->new(".")->show( "master:shuck-and-awe-9" )'

First this week we have John Anderson filling us up on the Perl high drama of OSCON of earlier this week. In a nutshell the organizers provided, as it’s the tradition, ribbons to the attendees, and the Perl Mongers in the crowd got one reading Desperate Perl Hacker. The epithet, coined in an XML article written in 1997, was meant in good fun, but was received with a distinct lack of glee by the Perl hackers. Which is no surprise, considering how mongers already have to fight tooth and nail to dispel the heavy baggage of preconceptions that our language accumulated throughout the years. Quite a few blog entries sprouted to discuss the whole hooplah, with Piers Cawley‘s being one of the most eloquent, explaining that, yes Virginia, Perl can, and is, often used at the 11th hour to save someone’s bacon and, consequently, has instances of code that are less than perfectly pretty. But, it’s also much more than an emergency fire extinguisher and and has flip side that consists of a strong, solid and modern ecosystem that can, and is, definitively used for bigger projects.

Buuut enough about that. Let’s return to our regular parade of technological goodies, shall we?

Read the rest of this entry . . .

Shuck & Awe #4: Hunting for Perl

[yanick@enkidu shuck]$ cat my_feeds | \
    perl -MXML::Feed \
         -ne'say( (XML::Feed->parse($_)->entries)[0]->summary ) if rand() > 0.5 '

Curtis Jewell followed up on an old post by Adam Kennedy and checked out if shuffling things around really improve compression. From the results, there seems to be very little blood to be squeezed out of that stone.

jjore came up with a very clever hack to stop the debugger when a test fails. Not only it is extremely useful, but the hack itself provides a lot of insight and food for thought for anyone attracted to the dark arts of under-the-Perl-interpreter-hood meddling.

Read the rest of this entry . . .

cpanvote: a Perl Mini-Project

The Itch

For many, CPAN is a Canadian Prairies-sized field of modules where it’s darn hard to separate the wheat from the chaff.

While the CPAN Ratings service is the principal and official way CPAN tries to rank its distributions, for me at least, it doesn’t quite scratch the itch because . . . 

  1. not all distributions have reviews.
  2. even when there are reviews, they generally don’t answer the next question: what should I use, instead?.

Read the rest of this entry . . .

Ottawa Perl Mongers Presents: FormFu Assassin

formfu_assassin.jpg

Once more, the Ottawa Perl Mongers assemble!

When: Thursday December 3rd, 2009, at 7:00pm.

Where: at Pythian headquarters.

What: I’ll be presenting on how I’m implementing AJAX forms in a Catalyst application, using the deadly magic of Mason, Prototype, and FormFu.

Bonus: Pizza will be graciously provided by Pythian. So if you plan on coming, please let me know so that I can be a good little ninja and make the number of slices match the number of attendees.

See you there!

Start NowWith Pythian - database design, management and emergency handling capabilities...

Live Updates

pythian: RT @FN_Press2: Schooner Information Technology Teams with Pythian to Deliver Advanced Support and High... http://finanznachrichten.de/20
more



Testimonials

  • Serge Racine

    DBA, Brookfield Energy

    We are very satisfied by the service given to us by Andre and Shakir in support of our recent data quality and reorganization initiative.... more