Refactoring Dispatch Tables into Objects

One of the cool ways of doing things in Perl is to use a dispatch table. The most obvious dispatch table is a hash of subroutines: my $x; my $table = { GET => sub { return $x }, PUT => sub { $x = $_[0] }, }; sub dispatch { my ($method, $data) = @_; if (my $fn = $table->{$method}) { $fn->($data) } else { die 'METHOD NOT ALLOWED!' } } This is a pretty cool thing to be able to do easily.

Posted Thu, Aug 25, 2011

New Stuff in Catalyst::ActionRole::PseudoCache 1.000001

I’m excited to announce a new version of Catalyst::ActionRole::PseudoCache. New in the current release of Catalyst::ActionRole::PseudoCache is that it can now use Catalyst::Plugin::Cache as the underlying cache mechanism. The main reason was that the existing architecture didn’t work for multiple servers, which is how our system works. Plus this is just better overall. In the long term I will be removing the old “Pseudo” cache. It might be a good idea to make a separate package with a better name at some point, but that will be for the next release.

Posted Tue, Aug 23, 2011

Weekly Status Report 3

I don’t feel great about this past week, but I was really busy with wedding planning stuff. I barely made either of my two main goals (2 blog posts and 2 patches/releases a week.) Last week I: Released a new version of Log::Contextual Released a new version of DBIx::Class::Helpers I have high hopes for the coming week, that I can get more important releases and more interesting blog posts written.

Posted Mon, Aug 22, 2011

Using Cygwin instead of msysGit

Our main product at work is a Windows product. The reasons are complicated, but the main reason is that that is what our customers seem to want. What this means is that I do some of my development on a virtual machine. For a long time I was just using msysGit. msysGit goes a long way; you have a real bash console, a bunch of standard unix commands, and very good windows integration.

Posted Mon, Aug 22, 2011

Git aliases for your life

I only use a handful of git aliases, but the ones I do I really like. First off, the basic ones: [alias] ci = commit co = checkout st = status br = branch Also, another handy tip, as pointed out by a commenter is aliasing g to git (alias g=git) so that after you do the above instead of git ci you can merely do g ci. Neat.

Posted Wed, Aug 17, 2011

Weekly Status Report 2

This week I: Released a new version of Class::C3::Componentised Released a new version of DBIx::Class::Candy

Posted Tue, Aug 16, 2011

You should be using git grep

Usually when searching through files I use ack which is an awesome tool indeed. Unfortunately, though ack does indeed work on windows, using it on windows is a painful experience. The main two problems are that it’s slow and the color coding doesn’t work. I figured I’d try out git grep, with the hope that it might be marginally better. I try my best to at least be familiar with all the git commands, so this is one of those things I had been meaning to do anyway.

Posted Sun, Aug 14, 2011

Powerful benchmarking with Perl and ab

One of my projects at work was to make an SMS (and voice actually) gateway. The gist is that instead of our customers each having an account with whatever text message company, they go through us. The benefit is that with a larger pool of users for the text messages users can have a lot more flexibility with how they use their messages. Most gateways sell you messages per month, and we sell yearly messages.

Posted Fri, Aug 12, 2011

New Stuff in Class::C3::Componentised 1.001000

I’m very excited to finally announce a feature that I’ve toyed with in Class::C3::Componentised for over a year now. New in the current release of Class::C3::Compontised is Class::C3::Componentised::ApplyHooks. The gist is that you can run code, or more importantly methods, against the class being injected into. I wouldn’t be surprised if few people reading this actually know what Class::C3::Componentised is actually used in; the answer is DBIx::Class. The upshot of this new feature is that you could write a component to add columns or relationships much more nicely than before.

Posted Wed, Aug 10, 2011

Weekly Status Report 1

This week I sent a small patch (along with a lot of discussion) to Exodist for Exporter::Declare released an awesome new version of Log::Contextual

Posted Mon, Aug 8, 2011

New Stuff in Log::Contextual 0.004000

I just released Log::Contextual 0.004000 and it has a handful of great features. It now supports arbitrary levels, so where before you simply had: trace debug info warn error fatal Now you can have any levels by just saying use Log::Contextual -levels => [qw(lol wut zomg)], ':log'; which would import functions for log levels lol, wut, and zomg. But the really exciting thing is that now you can make a base class of Log::Contextual and set defaults for all of the different import options:

Posted Sun, Aug 7, 2011

DBIx::Class Extended Relationships

Since the dawn of time DBIx::Class relationships were simply a set of columns related to each other via equality. For the most part this is good enough, but DBIx::Class aims at 100% power for all databases (unlike some other ORMs… :-) .) In May what we internally called “extended relationships” was added to DBIx::Class. (docs here) Basically this allows you to use the full power of SQL::Abstract to define your join conditions.

Posted Fri, Aug 5, 2011

Event Loops are better than while (1)

One of the projects that I worked on last year had a number, five I think, of background daemons. Basically the way we implemented this was by making a DoesRun role that looked something like the following: package Lynx::SMS::DoesRun; use Moose::Role; requires 'single_run'; has period => ( is => 'ro', required => 1, ); sub run { my $self = shift; while (1) { $self->single_run; sleep $self->period; } } no Moose::Role; 1; And then a typical Runner class looked something like this:

Posted Wed, Aug 3, 2011

Getting More Done

Today I purchased 59 Seconds, recommended by Jeff Atwood. I struggle with procrastination as much as anyone else so I’m willing to spend 10 bucks to try to get more done. The author recommends four things to attain a given goal: plan well reward yourself focus on benefits tell people I’ve kinda slacked off with Open Source stuff the past year (see the graph at metacpan) and I’d like to remedy that.

Posted Tue, Aug 2, 2011

My Ideal workflow tool

super fetch: git fetch git fetch –tags git pull –ff-only (all local branches) git reset –hard (specified branches) pull issues: “rebase” issues from github “rebase” issues from RT “rebase” issues from JIRA sync issues from remote repo super status: Dirty? Non-Tracking branches? How many? Ahead tracking branches? How many commits total? Unmerged branches? Unreleased master? (no tag) How many issues? My last post was about Distributed Issue Tracking.

Posted Tue, Jul 12, 2011

Distributed Issue Tracking

Ever since I heard about SD (Simple Defects) I’ve been enamored with the idea of distributed issue tracking. Unfortunately SD is mostly unmaintained, undocumented, slow, and has lots of deps. I could probably get over the latter two, but the first two are deal breakers. Fast forward eighteen months and I saw genehack’s App::GitGot. It’s a little sluggish (1.35s to merely list repos on my SSD) but it’s exciting because it can easily list my repos that are dirty or ahead by X commits.

Posted Thu, Jul 7, 2011

FUD and Loathing in JavaScript

A coworker sent this to our internal mailing list, partially to goad me into responding to the stupid comments. I don’t have an ars account, so I’ll just hope that trackbacks work. Here are the arguments that someone actually put effort into making: a) Magic ‘this’. This is this, except when this is that. JavaScript pushes you to use anonymous functions all over the place, except they always end up losing the proper context for the ‘this’ variable, so you end up having goofy code like “var _this = this” all over the place and then using that inside your callbacks or other functions.

Posted Fri, Jun 24, 2011

Nicer git remote URLs

Most open source git repositories that I interact with are hosted at A few typical repo urls (read/write) hosted here looks like: [email protected]:DBIx-Class.git [email protected]:Catalyst-Runtime.git [email protected]:Devel-Declare.git [email protected]:Moose.git A handy trick is to make a file at ~/.ssh/config with the following in it: host catagits user catagits hostname port 22 identityfile ~/.ssh/id_dsa host dbsrgits user dbsrgits hostname port 22 identityfile ~/.ssh/id_dsa host p5sagit user p5sagit hostname port 22 identityfile ~/.

Posted Wed, May 25, 2011

Converting repos from Subversion to Git

I have now converted something like 25 repositories from svn to git. I can fix undetected merges, correctly import tags, and clean up ugly (svk) commit messages. With this knowledge I hope to write a small, non-free eBook (7.50 USD I think.) But first I’d like a chance to convert your repository! The more repositories that I convert the more ground the ebook can cover. I’ve converted a number of repos for CPAN modules and I’d love to do more.

Posted Wed, May 18, 2011

New Stuff in DBIx::Class::DeploymentHandler

I’m just releasing my first new release of DBIx::Class::DeploymentHandler in six months! For the most part the release is just a few doc tweaks, but it does have one important new feature, the “_any” version. If you didn’t already know, DBICDH has a handy little directory structure for how your deploys work. If you haven’t seen it, take a look. This new release allows you to use _any in place of a version or version set, which will run the given files no matter what version you are deploying to.

Posted Wed, Apr 13, 2011

Chai Tea Mix

I’ve been using this for a couple years now, and I figure I’ll repost it so that it’s easy to find (for me.) Ingredient Amount Sugar, White Granulated 1 Cup Instant Non Fat Dry Milk 1 Cup Non Dairy Creamer 1⁄2 Cup Instant Tea 1⁄2 Cup Cinnamon, Ground 1 Teaspoon Ginger, Ground 1 Teaspoon Salt, Table 1⁄2 Teaspoon Nutmeg, Ground 1⁄2 Teaspoon Allspice, Ground 1⁄4 Teaspoon Cloves, Ground 1⁄4 Teaspoon Cayenne Pepper 1⁄8 Teaspoon And for convenience, here is the recipe x 4, which is how much I like to make:

Posted Thu, Apr 7, 2011

DBIx::Class::Helper::Row::RelationshipDWIM: Awesome!

Thanks to some idle chatting in the #dbix-class channel on I came up with DBIx::Class::Helper::Row::RelationshipDWIM. The gist of it is that you get to type __PACKAGE__->has_many(addresses => '::Address', 'person_id' ) instead of __PACKAGE__->has_many(addresses => 'MyApp::Schema::Result::Address', 'person_id' ) That yields a total sugar (with candy) of the following: package Lynx::SMS::Schema::Result::MessageParent; use Lynx::SMS::Schema::Candy; primary_column id => { data_type => 'int', is_auto_increment => 1, }; column account_id => { data_type => 'int' }; column type_id => { data_type => 'int' }; column caller_id => { data_type => 'int', size => 11, is_nullable => 1, }; column message => { data_type => 'nvarchar', size => 1000, }; column when_created => { data_type => 'datetime', set_on_create => 1, }; column voice_id => { data_type => 'int', is_nullable => 1, }; belongs_to account => '::Account', 'account_id'; belongs_to voice => '::Voice', 'voice_id'; belongs_to type => '::Type', 'type_id'; has_many children => '::MessageChild', 'message_parent_id'; 1; Pretty nice.

Posted Tue, Mar 15, 2011

New Stuff in DBIx::Class::Candy

I’m extremely proud to announce a fairly major release of DBIx::Class::Candy, 0.002000. Not only are the tests much more complete as well as the underlying code much more comprehensible, but the usage of the Candy can now be even sweeter. To get the full features of DBIx::Class::Candy you’ll want to first create the following base class: (Of course you can call this sugar if you hate my naming scheme or rainbows if you love it.

Posted Wed, Mar 9, 2011

Git from git on ubuntu

I really like git. It has an excellent suite of tools bundled with it from the start and it gets lots of updates and active development. Today I was looking at the latest git version (1.7.4) because I was installing it on a new machine and, as usual with new versions of things, I perused the release notes. What really caught my eye was this: * "git log -G<pattern>" limits the output to commits whose change has added or deleted lines that match the given pattern.

Posted Wed, Mar 2, 2011

Screen Scrape for Love with Web::Scraper

My fiancée and I have not yet picked out a date for our wedding, but we do know that we want it outdoors. We have scoped out a number of locations that can handle indoor and outdoor weddings just in case there is bad weather, but we’d prefer to have perfect weather. After some searching I found NOAA’s NSSL, which has ridiculous amounts of data. Instead of most websites, which give you the average high temperature and average low temperature for a given day of the year from the past three years, this gives hourly measurements for basically anything back to 1910.

Posted Fri, Feb 18, 2011

Catalyst Git Conversion

Hello All! Some of you already know that I am working on converting the Catalyst repository to git. I am happy to announce that I am closing in on completion! The current state of the git repo: The script to convert it: The only things I know of that we must have before we finalize this conversion is: Is it correct that the svn user rjk is Ronald J Kimball: rjk AT linguist DOT dartmouth DAWT edu ?

Posted Sat, Feb 12, 2011

My Fork of ExtJS

Sencha has been pretty slow at fixing bugs for the company where I work. We not only pay for usage but also for forum support. I’ve decided to personally (that is, me, not my company) fork ExtJS and maintain a set of patches on top of it. Those patches will be licensed as GPLv3 (because they must, because ExtJS is licensed as GPLv3) and Sencha can take them and merge them into core whenever they want.

Posted Wed, Feb 9, 2011

New stuff in DBIx::Class::Helpers

I just released a new version of DBIx::Class::Helpers and it has two new components: DBIx::Class::Helper::ResultSet::ResultClassDWIM and DBIx::Class::Helper::Schema::GenerateSource. Helper::ResultSet::ResultClassDWIM This component solves an issue I’ve seen both by myself and with my coworkers; it’s too hard to remember/type the following: my $rs = $schema->resultset('Foo')->search($q, { result_class => 'DBIx::Class::ResultClass::HashRefInflator', }); So I wrote this component which will let you generically write: my $rs = $schema->resultset('Foo')->search($q, { result_class => '::HashRefInflator', }); or use the specially hardcoded:

Posted Tue, Feb 1, 2011

New Stuff in Data::Dumper::Concise (Devel::Dwarn)

I just released a new Data::Dumper::Concise. There are new features! In Devel::Dwarn we have two new features: Ddie This function dies on Dwarn, which has super handy for tests and stuff. Ddie { frew => 1, }; DwarnF This is like Log::Contextual’s Dlog methods. So you now can do the following: DwarnF { "user: $_[0]\n session: $_[1]" } $user, $session; DumperObject Apparently people needed this. It’s part of Data::Dumper::Concise.

Posted Fri, Jan 21, 2011

Announcing Config::ZOMG

For a while now I’ve wanted to tear Config::JFDI up. Since I first used it it’s always been too heavy and had too many little weird things. Well, I did that last night and it ended up getting three times faster! I’ve released the fork as Config::ZOMG (I considered GTFO and STFU, but thought better of it.) For the most part it’s the same as Config::JFDI of course, but basically what I did was remove the substitution and install_accessor features, removed isa checks, and switched from Any::Moose to Moo with inlined defaults.

Posted Wed, Jan 12, 2011

Predefined Schema Additions for DBIx::Class

At work we have a tiny set of classes and relationships that we’ve reused for a few projects now. The idea is that it’s a package deal of users, roles, permissions, and a way to map permissions to parts of the application. I’m actually pretty fond of it, but its usage is a little awkward and not very flexible. If I could I’d put it on CPAN as that would mean tests, docs, and more importantly, a way to make it more useful for disparate projects.

Posted Tue, Dec 28, 2010

Why I Won't Use Your Programming Langauge

I keep running into people at parties or whatnot who mock me for using Perl and claim that “only .NET is a real programming language” (sic.) Most of the time they are trolling, but I figure I might as well make measurements for what I think of as a reasonably useful programming language. I’ll break this up into two groups of things. The first group is stuff that I want when programming at home for fun.

Posted Tue, Dec 14, 2010

Announcing Log::Sprintf and Log::Structured

I just released Log::Sprintf and Log::Structured to CPAN. They are both very simple modules, but they allow some powerful stuff. Log::Sprintf will convert a hashref into a string given a specification almost conformant to Log::log4perl’s log specs. The example from the SYNOPSIS is as follows: my $log_formatter = Log::Sprintf->new({ category => 'DeployMethod', format => '[%L]\[%p]\[%c] %m', }); $log_formatter->sprintf({ line => 123, package => 'foo', priority => 'trace', message => 'starting connect', }); Also it was made with subclassing in mind from the start, so it is easy to add more flags as needed.

Posted Wed, Dec 8, 2010

Handy Backup Solution for Linux

At work I was recently given an external hard drive for backup purposes. Most of my coworkers are using some windows program to get the job done, but of course I can’t use that since I am using Linux. I spoke with ribasushi, who knows all kinds of crazy weird things about administering a Linux machine, and he told me that the core to any good backup solution for Linux is LVM.

Posted Sat, Nov 27, 2010

Moo: woohoo!

Moo was just released! As mst says, Moo is almost, but not quite, two thirds of Moose. Or maybe Minimalistic Object Orientation. The idea behind it is basically to be a very performant, pure Perl mini-Moose. It supports lots of Moose features already and even more are on the way. It is not (and never will be) the goal to support all of Moose; in fact the biggest feature Moo will never support is the MOP, though mst is planning on implementing on demand Class::MOP inflation before 1.

Posted Tue, Nov 16, 2010

Sensible database testing using Catalyst

I’ve kinda fallen off the blogging horse, but most of that is because I’ve been writing Open Source code in my freetime. I think generally that’s a worthwhile tradeoff, but I like blogging in general, when I have stuff to blog about, so I’m gonna try to mix in more blog posts; at least about what I’m doing. At work I am writing an SMS gateway. This is after writing my first Catalyst app and also after trying to test another Catalyst app, so now that I have that experience under my belt I think I’ve finally figured out how to do relatively complex tests (including tests that use the database) without going crazy.

Posted Thu, Nov 11, 2010

Announcing DBIx::Class 0.08124

Hello all, I’m proud to announce DBIx::Class 0.08124! It’s been a VERY long time since 0.08123 and a this release brings lots of goodies. My favorite is color-coded, correctly indented SQL, with placeholders filled in. Try it! Just do: DBIC_TRACE_PROFILE=console DBIC_TRACE=1 ./ There is also the exciting new “-ident” pseudofunction for SQL: $rs->search({ foo => { -ident => ‘bar’ } }) which is the same as $rs->search({ foo => \‘bar’ })

Posted Thu, Oct 28, 2010

zsh for the win

In the past I’ve only touched on the fact that I am a z shell user. I figured I’d make a post about some of the tweaks I made to my config (mostly my prompt) yesterday, in addition to why I use it at all. First off, what are some features zsh has that make it work using for me? Various bundled “modules.” For example, the zsh-mime-setup module enables me to “run” files with extensions and have the mime setup use the right program to open them.

Posted Mon, Oct 4, 2010

Try Out Color Coded SQL

Thanks to arcanez, my color coding SQL Logging has been merged into DBIC’s master! That means you can easily try out the new color coding! All you need to do to try it out is clone our master from git: git clone git:// Make sure you install any new deps. The main one will be SQL::Abstract 1.68. cpanm --installdeps . And then use that as your lib directory when you run your server or whatever:

Posted Tue, Sep 21, 2010

Announcing DBIx::Class::Storage::PrettyPrint

Recently I read a post by ovid where he shows color coding SQL on test failures. I really wanted to steal his code for DBIx::Class’s trace output. For MSSQL it would be especially helpful since our pagination involves two subqueries. ribasushi had pointed out in the past that all we need to do this (and do it correctly) was to refactor a bit of the test code and we’d have a proper parser and deparser.

Posted Tue, Sep 7, 2010

YAPC NA videos available!

This year at YAPC::NA nearly all the talks were filmed, including mine. I watched them so I could glean a bit more ideas for how to make talks in the future better. Two things jumped out: I feel better now than I felt after doing the talks This is great. I feel like they went really well now. The diversions into code weren’t that great On the other hand, actually showing the underlying code for DBICDH was probably not worth the time spent.

Posted Thu, Aug 12, 2010

Reactions to porting Log::Contextual to Perl 6

Today we had our Dallas.p6m meeting, which was a lot of fun as usual. This meeting was especially interesting because Rakudo * was released since we last met. In the meeting I discussed my little project to port Log::Contextual to Perl 6. First off, here’s the code. There are plenty of positives and negatives to Rakudo *. First the positives! Positives It works! It’s pretty cool that the tests actually pass!

Posted Wed, Aug 11, 2010

Using Plack for Hardware emulation

One of the first projects I did at work was to make a web/javascript based interface for a piece of hardware that we sell. The machine is very underpowered so pushing a lot of the complexity to the client makes sense. It was a great project and is one of the few that I haven’t had to make modifications to since I finished it nearly two years ago. Well, it turns out we are making a new version of the hardware and I have to add a ton of options to the UI.

Posted Tue, Aug 10, 2010

Announcing latest release of DBIx::Class::Helpers (2.004000)

I am proud to announce a new release of DBIx::Class::Helpers. There are five major changes in this release. First off, the latest release adds DBIx::Class::Candy exports. So if you are using DBIx::Class::Candy to define a result, certain methods will be imported into your namespace. For example, DBIx::Class::Helper::Row::SubClass will export a subclass subroutine into your module. Not huge but nice nonetheless. Next up, we have four shiny new components. Two are ResultSet components and two are Result components.

Posted Fri, Jul 30, 2010

git-svn for the win

I have been using git more and more. I use it in all of my CPAN modules. I’m using git to the point where I expect everything else (that is, svn) to be just as powerful and fast. Unfortunately that just is not the case, and I’m still stuck with it for all but one project at work.. For example, the other day I wanted to find the last commit that my coworker made.

Posted Tue, Jul 27, 2010

New stuff in Devel::Dwarn

Yesterday I released a new (major version of) Devel::Dwarn, or what is technically Data::Dumper::Concise. But those in the know call it Devel::Dwarn. If you did not already know, Devel::Dwarn is sugar + good defaults for Data::Dumper. Check it out. Drool. Use it. Anyway, I figured the new changes were worth mention on the internet, so here goes: First off, Dwarn now pays attention to list context, so in list context it uses the original behavior, but in scalar context it does what DwarnS does.

Posted Fri, Jul 23, 2010

Announcing DBIx::Class::Candy

Over a year ago I read this blog post. To be honest at the time I thought it was mostly silly and I still feel that way. The things that are important to me in an ORM are capabilities, not subjective prettiness of code. But, I also get tired of typing repetitive things, especially __PACKAGE__->. That’s just too many shift keys! So after working on a few different modules and accruing various bits of knowledge here and there I learned what I needed to to create a sugar layer for DBIx::Class that doesn’t throw the baby out with the bath-water.

Posted Wed, Jul 21, 2010

Being a Speaker at YAPC 2010

This year Rob Kinyon and mst convinced me to do some speaking at YAPC. I ended up doing three forty minute talks. The DBIx::Class one was certainly the easiest, but also the one I was least invested in. I didn’t write DBIx::Class and it’s a big enough project that the slides nearly wrote themselves. I also did a talk on DBIx::Class::DeploymentHandler. I am a little frustrated with how this talk went down.

Posted Sat, Jun 26, 2010

YAPC Talks I Think Are Worth Note

So I just got back from my second YAPC. Again I had to leave early, but not as early as last time, so that’s good. Instead of summarizing every single talk I went to, I’d like to highlight some of my (most and least) favorites. Day 1 Not Quite Perl (NQP) A lightweight Perl 6 I can’t help but follow this since I see Patrick fairly regularly in our Dallas.

Posted Wed, Jun 23, 2010

Announcing DBIx::Class::DeploymentHandler

Do you remember when you first realized that you were not the only person with a perspective in the world? I do. I was 5ish and I remember looking into the car to the left of me and seeing another person looking at me from their respective car. I remember thinking, “This is not what it is like from their point of view.” I distinctly remember reevaluating things all day that day.

Posted Fri, Jun 11, 2010