PreshBlog

Perl

Dancer::Plugin::SimpleCRUD 0.10 released

by on Jun.05, 2011, under Dancer web framework, Perl, Programming

I’ve just released version 0.10 of Dancer::Plugin::SimpleCRUD, incorporating a new display_columns option to control which columns should be visible when listing records, kindly provided by saberworks in PR-9. Also included is a documentation fix for the editable_columns option, and implementing the not_editable_columns option, courtesy of Alberto Simões (ambs) – thanks!

1 Comment more...

HTML::Table::FromDatabase 1.00 released with row_callbacks feature

by on May.24, 2011, under Perl, Programming

I just released version 1.00 of HTML::Table::FromDatabase, with a new row_callbacks feature.

You could already declare callbacks on a cell-level basis, so you could say, format monetary values appropriately, round numeric columns, turn URLs into clickable links etc. Now, you can also declare a callback which receives an entire row as a hashref, which it can modify as needed.

An (admittedly somewhat contrived) example from the documentation:

my $table = HTML::Table::FromDatabase->new(
    -sth => $sth,
    -row_callbacks => [
        sub {
            my $row = shift;                                                                                 
            if ($row->{name} eq 'Bob') {
                # Hide this row
                $row = undef;
            } elsif ($row->{name} eq 'John') {
                # John likes to be called Jean these days:
                $row->{name} = 'Jean';
            }
        },   
    ],       
);

I decided to bump the version to 1.00 for the sake of anyone who considers 0.x versions to be unready for production use; this module has been about since 2008 and is working well in production use for me.

Leave a Comment more...

The Dancer release that will get you hooked!

by on May.24, 2011, under Dancer web framework, Perl, Programming

Sawyer X wrote up a good post on version 1.3050 of the Dancer Perl web framework being released – "The Dancer release that will get you hooked!".

The addition of extra hooks, along with support for plugins to create hooks, heralds additional flexibility and power for your Dancer apps.

Dancer itself now provides various new hooks you can use to customise its behaviour, including before_deserializer, before_file_render, before_error_render, before_template_render, before_layout_render, before_serialization
– see the Dancer::hook() documentation for the full list. Plugins can register their own hooks, which your code can then make use of.

Props go to Franck Cuny for the implementation, and JT Smith of Plain Black for pushing for this feature and working with the Dancer team in designing the implementation.

Dancer 1.3050 also includes various bug fixes and improvements – see the CHANGES file for a full list.

Leave a Comment more...

Dancer::Plugin::TimeRequests

by on May.23, 2011, under Dancer web framework

Today I knocked up a quick plugin for the Dancer Perl web framework to log the time taken by requests to help look for bottlenecks – enter Dancer::Plugin::TimeRequests.

At the moment it’s very simple, and simply logs the time taken to execute every request; in the future, I may extend it to support capturing statistics and adding a route handler to display stats (e.g. average request time, which routes take the longest to execute, etc.)

Suggestions / patches welcome – the code is on GitHub as usual.

1 Comment more...

Bot::BasicBot::Pluggable::Module::GitHub

by on May.10, 2011, under Perl, Programming

We have an IRC bot in the #dancer IRC channel powered by Bot::BasicBot::Pluggable, and I recently wrote some new features as a distribution of modules which I plan to release to CPAN soon.

Until then, you can see the code in the Bot::BasicBot::Pluggable::Module::GitHub repository on GitHub.

There are two modules so far:

EasyLinks

Bot::BasicBot::Pluggable::Module::GitHub::EasyLinks recognises certain elements within discussions on IRC and provides responses containing titles/URLs to see the corresponding entity, for instance:


<someuser> I'm just working on Issue 42 now
<bot> Issue 42 (Issue Title - Issues - sukria/Dancer - GitHub) - https://github.com/user/project/issues/42

<someuser> I've just submitted PR 517, anyone want to merge it?
<bot> Pull request 517 (Pull request title - Pull Request - GitHub) - https://github.com/user/project/pull/517

<someuser> What do you think of commit 0d2752 then?
<bot> Commit 0d2752 (Commit message summary here) - https://github.com/user/project/commit/0d2752...

PullRequests

Responds to a !pr command, reporting the number of open pull requests, either for whatever project is specified as the default for that channel, or a specific project can be named. For instance:


<someuser> !pr user/project
<bot> Open pull requests for user/project : 5 pull requests open (usera:3, userb:2)

I plan to add more features before releasing the first version to CPAN; in particular, I’d like to add commit hook support, so the module could spawn a trivial webserver to listen for hook triggers from GitHub, and announce commits.

As always, contributions would be welcomed.

Leave a Comment more...

Welcoming ambs to the Dancer core dev team

by on May.10, 2011, under Dancer web framework, Perl

Alberto Simões (ambs) has been a helpful contributor to the Perl Dancer web framework for some time now, submitting a lot of helpful pull requests and being a valued member of the community providing ideas and support to new users.

I’m very happy to note that ambs is now a member of the Dancer core developers team – great to see all that hard work recognised (well, Dancer 1.3030 was released with codename “Silence of the ambs” as recognition too :) )

Welcome aboard, ambs!

1 Comment more...

Dancer::Plugin::SimpleCRUD 0.03 and Dancer::Plugin::Database 1.24

by on May.09, 2011, under Dancer web framework, Perl

A busy evening’s hacking on Dancer plugins tonight. I’ve released Dancer::Plugin::SimpleCRUD 0.03, which incorporates a new search feature kindly contributed by Alberto Simões which I’ve been meaning to release for a while, along with removing the dependency on SQL::Abstract in favour of the convenience methods provided by Dancer::Plugin::Database, which will make D::P::SimpleCRUD work correctly with PostgreSQL databases too – thanks to Jonathan Barber for reporting this issue in RT #68040.

(I should point out that the problem was not with SQL::Abstract, but with D::P::SimpleCRUD setting the quote_char param to a backtick, which is good for MySQL and SQLite, but not so much for PostgreSQL. The code in D::P::Database uses the quote() / quote_identifer() methods provided by DBI, so should Do The Right Thing for any DBI-supported database engine.)

Also released is version 1.24 of Dancer::Plugin::Database, fixing a bug with the log_queries setting reported today on IRC by Martin P Evans (mpe) – thanks Martin!

As soon as time permits, I intend to add more features and refinement to Dancer::Plugin::SimpleCRUD to make it even more useful. Any contributions would be very welcome indeed – you can fork the Dancer::Plugin::SimpleCRUD repository on GitHub and submit pull requests, or contact me with patches.

(You can also find Dancer::Plugin::Database on GitHub, and if you’re interested in my other projects or “following” me, see my GitHub profile.)

Leave a Comment more...

Dancing in the cloud – deploying Dancer apps to dotcloud

by on Apr.30, 2011, under Dancer web framework

Marco Fontani wrote up an excellent blog post on deploying Dancer apps to DotCloud’s beta.

DotCloud is a PaaS (platform as a service) hosting platform currently in beta, running on Amazon EC2. It promises dead-easy deployment of Perl web applications. (DotCloud announced Perl support as CaaS (Camel as a Service) recently.)

Marco’s write-up shows that it is indeed simple; push your Dancer app to DotCloud, and it figures out the dependencies, installs them, and starts it up. As the little meerkat would say, “simples!”.

Leave a Comment more...

11 million CPAN testers reports

by on Apr.11, 2011, under Perl

On 11th March 2011, CPAN testers reached the milestone of 11 million CPAN testers reports.

That’s an awful lot of code testing! CPAN Testers are damned useful, automatically testing CPAN modules on various platforms to make sure all is as it should be – a very valuable part of the CPAN ecosystem.

Leave a Comment more...

Nagios plugin to monitor 3ware/LSI RAID

by on Mar.31, 2011, under Perl, System Administration

I wrote a basic Nagios plugin named nagios_3ware_raid_check to monitor the status of RAID arrays on 3ware/LSI hardware RAID controllers, but it was pretty limited.

Today I got a chance to improve it as I needed it for some machines at work; it now automatically figures out which card(s) are present, and checks the status of each RAID array on it. This means you don’t need to configure it to know which card number and unit to monitor, it just Does The Right Thing.

It uses the tw_cli utility available from the LSI website, which supports a wide range of 3ware/LSI RAID cards.

Example:

[dave@rasputin:~]$ /usr/local/bin/nagios_3ware_raid_check -v
Card 6 is a 8006-2LP
Unit u0 on card6 is a RAID-1 array of 931 GB and is OK
RAIDCHECK OK - Card 6 unit u0 RAID-1 OK (931GB)

When actually using it from Nagios, don’t use the -v (verbose) option – just use something like the following in nrpe_local.cfg:

# Monitor RAID status
command[check_raid]=/usr/local/bin/nagios_3ware_raid_check
5 Comments more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!