Programming
Backing up Google contacts/calendar etc
by bigpresh on Jul.23, 2011, under Perl, Programming
I recently followed a discussion on Twitter after @thomasmonopoly‘s Google account was blocked for unknown reasons, denying him access to the data he’d entrusted Google with.
I casually mentioned that entrusting Google to store all your data without having backups yourself is a bad idea, and @jmrowland enquired as to how you can back up stuff you create “in the cloud” (using Google).
I figured I should share the Perl script I’m currently using to back up my Google contacts, calendar and Google Reader subscriptions, so I’ve uploadedbackup-google-stuff on GitHub.
As I only wrote the script for my own use it’s quite basic and perhaps not particularly user-friendly, but I thought it only fair to share it; if people are interested in it, I may extend it somewhat. I’m fairly sure there are other “backup your Google account” solutions already out there already, though.
Of course, backing up mail from Gmail is trivial as they offer IMAP access; I don’t rely on Gmail so I’ve not bothered with that myself.
EDIT: I’ve seen Backupify recommended as a good solution for backing up your stuff from Google.
Easy profiling for Dancer apps
by bigpresh on Jul.23, 2011, under Dancer web framework, Perl, Programming
Today I released Dancer::Plugin::NYTProf, which provides easy profiling for Dancer apps, powered by the venerable Devel::NYTProf.
Using it is simple – load the plugin in your app:
use Dancer::Plugin::NYTProf;
Then, use your app as normal, then, to view the profile data, point your browser to /nytprof (e.g. http://localhost:3000/nytprof, and you’ll get a list of profile runs (each request is profiled individually):
Select the profile run you wish to view, and nytprofhtml will be invoked behind the scenes to generate the HTML reports, which will then be served up, and you’ll be looking at the helpful Devel::NYTProf reports, to see where time was spent processing your request:
Early days yet, and a lot of room for improvement, but in my testing, it works.
Things I’d like to add when time permits:
- The ability to exclude Dancer internals from the profiling (if I can find a clean way to do so)
- The ability to enable profiling only for certain requests – for instance, providing a pattern to match the request URLs you want to profile
- The ability to customise the URL at which profiling reports are served up
- Check for sane behaviour if prefixes are in use
Feedback welcome!
WordPress plugin for easy CPAN module links
by bigpresh on Jun.05, 2011, under Geeky, Perl, Programming
Just installed the CPAN Auto Link Generator WordPress plugin, which automatically matches module names and provides links to the module’s documentation on CPAN. Very helpful for anyone blogging about Perl, so thought I’d give it a link here.
Dancer::Plugin::SimpleCRUD 0.10 released
by bigpresh 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!
HTML::Table::FromDatabase 1.00 released with row_callbacks feature
by bigpresh 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.
The Dancer release that will get you hooked!
by bigpresh 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.
Bot::BasicBot::Pluggable::Module::GitHub
by bigpresh 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.
Creating and pushing new remote git branch
by bigpresh on Apr.15, 2011, under Programming
A note for my own reference, as I always forget how to create a remote branch then work with it later:
Create a new remote branch topic/add_awesomeness with, e.g.:
git push origin :origin:refs/heads/topic/add_awesomeness
Create a new local branch to track it:
git checkout --track -b add_awesomeness origin/topic/add_awesomeness
The unintuitive way to delete a remote branch is:
git push origin :heads/topic/doc_cleanup
(There must be a better way than that…)
Dancer::Plugin::Database 1.00 released
by bigpresh on Jan.14, 2011, under Dancer web framework, Perl, Programming
I’ve just released Dancer::Plugin::Database 1.00 to CPAN. This includes Alan Haggai’s patch to supply runtime configuration info to the database keyword as a hashref (thanks, Alan!) which was already released as a developer release, 0.91_01.
I’ve bumped the version to 1.00 to indicate that I consider it stable and ready for use in production, for those users who mistrust any module with a 0.xx version number.
Dancer::Plugin::MPD released
by bigpresh on Nov.10, 2010, under Dancer web framework, Perl, Programming
I recently wrote Dancer::Plugin::MPD, a simple plugin to make it easy to talk to MPD (Music Player Daemon) from Dancer-powered webapps in Perl.
It uses Jerome Quelin’s excellent Audio::MPD – it simply provides an mpd keyword which returns a connected Audio::MPD object (connecting first, if we didn’t have a connection or it went away, otherwise keeping the connected object cached).
It makes for code as simple as this example from DancerJukebox:
get '/control/skip' => sub { mpd->next; redirect '/'; };


