You're Awesome YAPC!

I just got back from this year’s YAPC::NA and boy did I have a good time! I’m trying to just get it down before I get back into the groove of regular life, so don’t expect poetry (like those of us who where in rjbs’ talk were treated to during technical difficulties.) First off, this year I took Rik’s advice from his !!con blog and decided to just walk up to random people and talk to them.

Posted Thu, Jun 26, 2014

Static Site Comments?

A week ago I blogged about how I ditched WordPress for Hugo. One of the (at least temorary) casualties to that conversion was the loss of comments. I did export the comments for later inclusion into the site somehow, but I have yet to see an option I can live with for hosting them. Here I’ll discuss the two obvious options. Disqus My original plan was to start using Disqus immediately.

Posted Tue, Mar 25, 2014

F# has Handy GC

As mentioned previously I was recently learning about F#, a neat mostly functional language for the .NET vm. One of the things I was really impressed with was that it allows the user to take advantage of timely destructors. I was under the impression that except for reference counted GC (perl, cpython, and I think C++) timely destructors were impossible and that the user is instead required to close their filehandles, database handles, or whatever other cleanup they need to do, within a finally block.

Posted Thu, Mar 20, 2014

F# has Weird OO

A little while back I was learning about F#. For the most part F# is a cool language. It’s based on ML and is an impure functional language. Here is how you can do some things with F#: Define a function: foo a b = a + b Call that function: let x = foo 1 2 There is a lot more, like currying, powerful type inference, etc.

Posted Mon, Mar 17, 2014

New Blog Engine: Hugo

Nearly a year ago I started to sour on WordPress, the blog engine I’ve been using since 2007. I have thought for a long time that a plaintext based system would be better, easier to manage, and that I could do more remotely (ie offline) with such a system. At the time I looked around and the best option I saw was ikiwiki. For what it’s worth, as with pretty much any blog engine it can be themed to be pretty, and it has a ton of plugins, and hey, it’s written in perl, so I could hack on it if need be.

Posted Sat, Mar 15, 2014

Announcing ::Helper::ResultSet::DateMethods1

I have had this ready to go for a few days now, but I figured I might as well wait for Mardi Gras; so feel free to celebrate, put on a masque, and enjoy a nice Hurricane Cocktail while you read this. A little over three years ago I got inspired while on vacation to Crested Butte, CO and started a branch in DBIC called merely, “date-ops.” The idea was to allow users to call various date functions, portably, directly in DBIC.

Posted Tue, Mar 4, 2014

Game Review: The Swapper

A friend recently mentioned an idea of a club where you play the games you get in the humble bundle and then talk about it afterwards. Kinda a solution to the whole problem where you get a bunch of games from steam sales, humble indie bundles, or just plain excess but then never play them. I decided to do it with some friends at work who already play games anyway.

Posted Sun, Mar 2, 2014

Use Docker to test your code! (and a subtle announcement)

Lately I’ve been working on code to unify disparate SQL into a small set of abstractions. There is a lot to do, and while testing generated SQL is nice, actually running that SQL and examining the results is the best way to test the code. In the past I would have installed a bunch of database engines locally. More recently I’dve used Travis to test against a bunch of databases. I still think that’s a good idea, but pushing to CI to test your code sucks.

Posted Sat, Feb 22, 2014 hacked

Things never change. Well actually they do, just not much. About five years ago I blogged about PerlMonks getting hacked. They had stored their passwords in plaintext, which basically meant everyone who used the site should have changed their passwords and fixed any situations where they had reused passwords. Also probably abandoned PerlMonks (I know I haven’t been back since.), a relatively recent blogging platform that was slated to replace use.

Posted Thu, Jan 23, 2014

Hash Your Passwords! Finale

A little over a year ago I posted what I hoped would be my last article about hashing passwords in Perl. One of the commentors mentioned a library, though, which in my mind makes things so much easier that it makes the topic worth revisiting. So, as before, here is a DBICDH/DBICM conversion script: #!/usr/bin/env perl use strict; use warnings; use DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::ScriptHelpers 'schema_from_schema_loader'; use Authen::Passphrase::BlowfishCrypt; # PROTIP: generally code reuse in migrations is *not* a good idea as changing # the reused code could break future runs of the migrations, or worse, # make the output subtley different, thus meaning regenerated servers # could have frustratingly different results schema_from_schema_loader({ naming => 'v7', constraint => qr/^users$/i, }, sub { my ($schema) = @_; $_->update({ password => Authen::Passphrase::BlowfishCrypt->new( cost => 14, salt_random => 1, passphrase => $account->password, )->as_crypt, }) for $schema->resultset('User')->all }); Here’s a one time script you can use if you don’t have a migration tool:

Posted Sat, Nov 9, 2013


DBIx::Introspector is a refactorization of some DBIx::Class code that detects what database a $dbh is connected to, as well as getting various facts from the $dbh. It is currently very much unborn, but given some feedback and battle testing on my own modules I hope to get it released before Christmas of 2013. (Famous last words?) The gist is that you can do something like the following: my $di = DBIx::Introspector->new; $di->get($dbh, 'rdbms_engine'); That’s certainly nice, as currently there isn’t anything like that on the CPAN that works for more than just mysql, SQLite, and Pg.

Posted Sat, Oct 19, 2013

Leveling Up

This is a blog post about some of the stuff that I’ve learned over the past few months. It’s hard to find causes for things in real life, but I can say at the very least that in this situation the catalyst for my learning was Aphyr’s Jepsen series. If you have not yet read it, you really should. The gist is that distributed databases often promise (or sound like they promise) more than is possible, and many times don’t even execute what they could do.

Posted Sat, Oct 5, 2013

Perl Switches 101

The backstory to this post is a little weird in that it involves rjbs much more than usual. A couple weeks ago I was playing D&D with rjbs and Abigail, and before the game got started somehow we ended up talking about Masterminds of Programming. The book is pretty good so far, you should totally read it! Anyway, the book has a chapter on AWK and for some reason I mentioned to rjbs that I need to buckle down and learn AWK.

Posted Fri, Aug 16, 2013

Event Loops: Useful After All

I’ve had a series of blog posts referring to event loops; the final message ended up being something like YAGNI. Well, I am eating my hat in this blog post; I have seen the light, I am drinking the kool-aide, I am stockpiling weapons… er, how about I just give some details! Tech Aside: IO::Async I have done some research for a blog post comparing AnyEvent, POE, and IO::Async. This is not that blog post, but in researching that post I came to a conclusion.

Posted Sat, Jul 27, 2013

Install and Configure the MS ODBC Driver on Debian

This page is only here for historical interest; the updated guide is here. This was originally written by my coworker Wes Malone and adapted to Ubuntu by my other coworker Geoff Darling. Basically it should get you up and running with Microsoft’s official ODBC driver in Debian based Linuxes. Enjoy! The Microsoft ODBC Driver (AKA the SQL Server Native Client) is Microsoft’s official ODBC driver for SQL Server. Since 2011 Microsoft has provided binary builds officially supported on Redhat Enterprise Linux.

Posted Fri, Jul 5, 2013

I made my own keyboard!

Check out the pictures at flickr

Posted Tue, Jun 11, 2013

l2type nub

Today I found out I have tennis elbow from the stupid way I type. I’m writing this blog so you’ll all not develop my stupid bad habit. Basically I configured awesomewm to use the alt key as the modifier instead of the windows key, because I learned to use the alt key in xmonad… Now, I don’t know about you guys, but all of they keys that share a row with the spacebar are hard to press in general and for some reason my dumb hands decided the only way to press alt was to curl my thumbs inward and press that way.

Posted Tue, May 28, 2013

Some Kickstarters I Have My Eye On

Some fun kickstarters I’ve got my eye on: Blasphemous Cocktails Cocktails inspired by HP Lovecraft stories and others. It is already funded and I am definitely getting it. The Wine Curmudgeons Guide to Cheap Wine The title says it all. Assuming this gets funded I plan on getting it. I love when people don’t have a minimum $20 a bottle to like a bottle of wine. The Whole Story: Winter 2013 I already “got” this one.

Posted Sun, Jan 27, 2013

The Pomodoro Technique

A couple of weeks ago I was frustrated at my own lack of productivity. I decided to purchase Pomodoro Technique Illustrated: The Easy Way to Do More in Less Time. I had actually already attempted the Pomodoro Technique based on what I read on the internet, but it never seemed to work for me. This short, easy read has made a noticeable difference in my productivity. But the book is not the point of this post, The Method is.

Posted Fri, Jan 25, 2013

Announcing Apache::BalancerManager

At work I use Apache as it’s the best thing out there for perl on windows. One of the features of Apache when you are using it as a load balancer is it’s UI for controlling the Balancer Manager. One of my coworkers remarked that it would be nice to have an API for that so that when we restart workers we could tell the balancer manager first so that the worker would not get dispatched to until it finished restarting.

Posted Fri, Jan 11, 2013

Abstraction Levels

One of the decisions we developers must make when writing our modules is at what level to abstract our code. I, for instance, write a lot of DBIx::Class components, which is, for the purposes of this discussion, about the same as a role (and I will just use the term role for the rest of the article.) For a long time that was my standard modus operandi, but I’ve started to think that that is a bad default and that I need to consider more carefully what to use.

Posted Sat, Jan 5, 2013

Go See My DBIx::Class Advent Article!

woohoo! Again, I’ll probably reblog this in January.

Posted Fri, Dec 21, 2012

Go See My Advent Article!

Merry Christmas! (I’ll reblog it next month probably.)

Posted Thu, Dec 13, 2012

ssh tips

As a developer, I use ssh all the time. When connecting to the various servers and even other computers in my house, ssh is my go to. Most writable git servers use ssh. A newish Perl module by mst (Object::Remote) uses ssh for communication. There are a number of tricks you can use to make using ssh as hassle free as possible. I’ll share these tips here. ~/.ssh/config First and foremost is getting intimate with ~/.

Posted Wed, Nov 14, 2012

Announcing DBIx::Class::MaterializedPath

Have you ever wanted to store trees in your database? How about store them and avoid melting your database server at retrieval time? Did you want to use materialized path and were sad when there were no quality modules to do it with DBIx:Class? DBIx::Class::MaterializedPath I recently had a need for storing tree-ish data in a table and I got it working with extended relationships and a helper or two.

Posted Mon, Sep 10, 2012

Hash your passwords!

More than two years ago I blogged about how to correctly store passwords. Recently a number of high profile websites have had their password storage compromised. The storage method I blogged about two years ago is still hugely better than what LinkedIn (SHA1, no salt) and I think Gawker had. If you aren’t already securely storing passwords, this post should get you going on a conversion. First off, here’s a DBICDH/DBICM compatible conversion script

Posted Mon, Sep 3, 2012

Zero DM RPG's

My weekly table top rpg is Changeling, which is one of the World of Darkness templates. This past week some stuff went on sale on DriveThruRPG so I picked up a few things that I’d wanted to look at for a while. For our game I’m the DM or GM or Storyteller or whatever you want to call that. It’s not because I’m overly creative or even wanted to, it’s because I wanted to play and no one else seemed willing to do it.

Posted Sat, Jul 28, 2012


I’ve had a long, sordid relationship with window managers. When I really started with my first computer it was Windows 98 and I somehow decided to put Litestep on it. I remember switching workspaces was often crashy and I pined for something less hacky. Eventually I installed some form of linux. Because Litestep was inspired by AfterStep I knew that’s what I really wanted. But I was wrong. I may have wanted that if I were already a console user, but I was weening myself out of windows.

Posted Wed, Jul 4, 2012

Web::Machine + Web::Simple is awesome

I really like “REST,” which the pedantic of you will realize is really just using more than just basic HTTP. I’ve gotten used to a handy REST-y pattern with Catalyst, which, though verbose, is pretty neat: use Catalyst::Controller::Accessors; cat_has account => ( is => 'ro', namespace => 'MyApp::Controller::Accounts', slot => 'thing', ); cat_has $_ => ( is => 'rw' ) for qw(rs thing id); sub base : Chained('/accounts/item') PathPart('contacts') CaptureArgs(0) { my ($self, $c) = @_; $self->rs($c, $self->account($c)->contacts) } sub item : Chained('base') PathPart('') CaptureArgs(1) { my ($self, $c, $id) = @_; $self->id($c, $id); $self->thing($c, $self->rs($c)->find($id)); } sub contacts :Chained('base') PathPart('') Args(0) ActionClass('REST') {} sub contacts_POST { my ($self, $c) = @_; my $params = $c->request->data; my $foo = $self->rs($c)->create($params); $c->stash->{rest} = { success => 1, data => $foo }; } sub contacts_GET { my ($self, $c) = @_; $c->stash->{rest} = $self->ext_paginate( $self->search($c, $self->paginate($c, $self->sort($c, $self->rs($c)) ) ) ); } sub contact :Chained('item') PathPart('') Args(0) ActionClass('REST') {} sub contact_GET { my ($self, $c) = @_; $c->stash->{rest} = { success => 1, data => $self->thing($c), }; } sub contact_PUT { my ($self, $c) = @_; my $foo = $self->thing($c); my $params = $c->request->data; $foo->update($params); $c->stash->{rest} = { success => 1, data => $foo }; } sub contact_DELETE { my ($self, $c) = @_; $self->rs($c)->search({ id => $self->id($c) })->delete; $c->stash->{rest} = { success => 1 }; } That’s cool.

Posted Wed, Jun 27, 2012

Announcing Catalyst::Action::FromPSGI

At YAPC this year I spoke with Stevan Little about his new module, Web::Machine. He mentioned that ultimately he wanted to figure out how to shim it into Catalyst. mst actually implemented something like that exactly a month ago, and I actually want to use it to make little redistributable apps that are the backend implementations of the gadgets for our dashboards at work. So I took Matt’s code and made a module!

Posted Mon, Jun 25, 2012

DBIx::Class::DeploymentHandler Backup based workflow

In my last post I wrote about how to make a backup for each migration you run. That’s a great trick that opens the door for this next tip. I’ve never really trusted or been comfortable with downgrade scripts. If your downgrade script truly is the reverse of your upgrade script it’s almost inevitable that your upgrade script will be archiving changed data so that the downgrade script can undo said change.

Posted Fri, Jun 8, 2012

DBIx::Class::DeploymentHandler + Backups

Given that DBIx::Class::DeploymentHandler is a widely misunderstood and confusing module to the point that a friend of mine wrote DBIx::Class::Migration a module to wrap it up more nicely, I’ve decided that some blog posts showcasing how I use DBICDH are in order. If you don’t already know, DBICDH was written by me, and designed my mst, myself, ribasushi, and Rob Kinyon. The latter two claim to barely remember our discussions early on, but I’ll credit them as having helped me design what I made.

Posted Wed, Jun 6, 2012

Introducing DBIx::Class::Helper::Schema::LintContents

Surprisingly recently we decided to actually clean up our database in my current project at work and add primary, unique, and foreign key constraints. For most projects that’s really not that hard, but because our project is a turn key server and it’s deployed on hundreds of customers’ sites we can’t just fire up a database shell and fix any broken constraints before we deploy them. So I made a tool that would quickly and correctly delete all but one of the duplicates of primary and unique constraints, and would delete the dangling children of broken foreign keys.

Posted Mon, Jun 4, 2012

Introducing DBIx::Class::Helper::ResultSet::SearchOr

Arguably the most important design decision that mst made when first writing DBIx::Class was the choice to make chainable resultsets. A fundamental part of that design is that when you chain off of a resultset you should always get a subset of what you started with. This is important because it’s what makes searching from a user object or similarly using DBIx::Class::Schema::RestrictWithObject work in a safe manner. Most everyone should know at this point that the best way to use DBIx::Class it to make various ResultSet methods that return named subsets of data.

Posted Fri, Jun 1, 2012

Introducing DBIx::Class::Helper::ResultSet::CorrelateRelationship

Recently at work we ran into an issue where a report was timing out. At first I thought it was because the server was overloaded, or the clients that were connecting to it were doing so improperly. Both of those things were true, but they weren’t the cause of the problem. The problem was this: sub TO_JSON { my $self = shift; return { %{$self->next::method}, failed_location_tests => $self->test_computer_links->failed->count, location_tests => $self->test_computer_links->count, device_tests => $self->test_device_links->count, total_pcs => $self->all_computers->count, total_pcs_failed => $self->failed_computers->count, total_pcs_succeeded => $self->succeeded_computers->count, total_pcs_untested => $self->untested_computers->count, } } So to be clear, with our standard pagination of 25 rows per grid, this was doing the initial query to get the data, and then SEVEN additional queries per row.

Posted Wed, May 30, 2012

Introducing JavaScript::Dependency::Manager

Nearly a year ago my grandfather passed away. He had some form of dementia for a long time and I personally wasn’t hit very hard by it, but as is the custom I went home to visit my family when it happened. On the drive down I listened to Childhood’s End and Rendezvous with Rama. At work I’d been tackling the problem of users with custom dashboards and possibly even the ability to have gadgets that we sell separately.

Posted Mon, May 28, 2012

Introducing DBIx::Class::UnicornLogger

More than a 1.5 years ago we added color coded, formatted SQL output to DBIx::Class. Since then I’ve tried adding various configurable logging facilities to the core, but I haven’t had much luck getting the API for that whipped into shape. So I’m giving up on getting it into the core for now and releasing it separately. It’s pretty rough around the edges, but it’s a logger, so it’s not like you could depend on it working a certain way and get into any kind of trouble with it (yet.

Posted Fri, May 25, 2012

Introducing Catalyst::ActionRole::DetachOnDie

In my last post I introduced Catalyst::Controller::Accessors, which is mostly aimed at users who do a lot of chaining. This module is similarly targeted for chaining users. Anyone who has used chaining for more than a few weeks will know that exceptions in chains are stupid; an exception will not stop the chain, but merely end the current part of the chain, add to $c->errors, and run the next part of the chain.

Posted Wed, May 23, 2012

Introducing Catalyst::Controller::Accessors

Ugh, I first released this eight months ago, but I fell off the blogging wagon pretty badly. It’s so hard to write when I could be writing code, docs, and tests! So anyway, I’m trying to get caught up on the eight announcements that need to be made as well as a few DBIx::Class::DeploymentHandler related PSA’s. I’ll schedule them to get auto posted with at least a few days between so I don’t melt your feed reader or bore you too much.

Posted Mon, May 21, 2012

Using AND metacpan

I appreciate the effort and openness of metacpan, but their search is still pretty bad. To be clear, compare the results of the search for DBIx:Class::Source on SCO and metacpan. That’s why I made the following greasemonkey/dotjs script: $('a').each(function(i,x){ var obj = $(this); var href = obj.attr('href'); var re = new RegExp('^/~([^/]+)/(.*)$'); this.href = href.replace(re, '$1/$2'); }) Put this in ~/.js/ to install it with dotjs. Feel free to extend it to work for more than just modules.

Posted Wed, May 16, 2012

The Rise and Fall of Event Loops (in one very small place of my code)

In the spirit of one of my other posts I’ve decided to chronicle my path with at least a couple event loops. More than eighteen months ago I documented my decision to start using an event loop as it would handle things I may not have considered, the example mentioned specifically in that post being exceptions. Things went well! I used the code I documented in that post for a long time with no issues until recently.

Posted Wed, Mar 7, 2012

Perl Event Loop

I have some extremely basic code using AnyEvent but I recently found out that I was doing it wrong. That is, the entire reason I am using an event loop is to catch errors, log them, and keep going. That’s one of the great benefits that Catalyst gives me; I override one thing and I get universal error logging. The problem is that AnyEvent specifically does not handle this use case.

Posted Sun, Mar 4, 2012

Using Catalyst::Plugin::Authentication with an old setup

Recently I took it upon myself to make Catalyst::Plugin::Authentication know users had logged in after users had logged in in a completely non-Catalyst part of our app. After LOTS of frustration, code spelunking, and bugging a couple people in #catalyst (hobbs and t0m) I got it working. Basically what I did was have the session plugin look at a different cookie and load information from our own strange brew of session table.

Posted Wed, Jan 18, 2012

Cloning Objects in Perl

Recently I needed to do some deep cloning of some objects at work. I think I ended up looking at all of the major ways to do it, and I figure I might as well discuss them here. What is deep cloning? Nearly everyone should be able to answer this, but it doesn’t hurt to define it anyway. Deep cloning means you clone other things the current object is related to, recursively.

Posted Tue, Sep 20, 2011

Shortcut Constructor Method & Conversion

I left my book and notes at work yesterday, hence the late post. Shortcut Constructor Method What is the external interface for creating a new object when a Constructor Method is too wordy? Sometimes creating an object is exorbitantly wordy. The example that the author gives (in javascript) is the following: var p = new Point({ x: 1, y: 2 }) Add methods to a lower level object that can construct your objects.

Posted Wed, Sep 7, 2011

Creating a pseudo attribute with DBIx::Class

I’m surprised I haven’t actually blogged this before. I had to do it recently for the first time in a long time and I figured I’d share the secret sauce. At work we just added a complete permission system on top of our existing user system, but we didn’t want to make the UI as flexible as the underlying code. We ended up making a single role (which has all permissions) called “Full Control”.

Posted Sun, Sep 4, 2011

Smalltalk Best Practice Patterns - Constructor Parameter Method

How do you set instance variables from a constructor method? The fundamental issue here is that often validation is bypassed at construction time, for whatever reason. So one’s accessor may look something like this: sub x { my $self = shift; if ($self->constructing) { if (exists $_[0]) { $self->{x} = $_[0]; } else { return $self->{x} } } else { if (exists $_[0]) { die 'too high!' if $_[0] > 100; die 'too low!

Posted Sat, Sep 3, 2011

Smalltalk Best Practice Patterns: Constructor Method

Sadly reading is going slower than expected due to being so busy with various things in life. Oh well, just a single pattern today. Constructor Method How do you represent instantiation? In addition to a vanilla constructor, add methods for common cases to instantiate typical objects. For strange cases allow the use of accessors. Using Perl (with Moose) an example might be: package Point; use Moose; has x => (is => 'ro'); has y => (is => 'ro'); sub r_theta { my ($class, $r, $theta) = @_; $class->new( x => $r * cos($theta), y => $r * sin($theta), ); } 1; So now both of the following work:

Posted Thu, Sep 1, 2011

Smalltalk Best Practice Patterns - Chapter 3 - Behavior - Methods

Today I had to spend time taking care of passport stuff for my upcoming honeymoon, so I only got to read a handful of pages. I’ll post my notes nonetheless. Methods are more important that state because, correctly factored, methods paper over any changes in state over time. Most of us who took OO classes in college had this hammered into our brains :-) Methods should be written to get something done, but should also be written to communicate with the reader.

Posted Thu, Sep 1, 2011

Smalltalk Best Practice Patterns, Chapters 1 and 2

For work I decided I’d start reading some technical books, taking notes, and then trying to reiterate what I’ve learned. Yesterday I read the Preface and Chapter 1 and today I read Chapter 2, but sadly it’s all still introductory. I might as well discuss what I’ve read nonetheless. First though, I should say that I am reading the book because Thomas Doran of Catalyst development recommended it, and it clearly applies to Perl with Moose.

Posted Tue, Aug 30, 2011