Configuration Station

We’ve all dealt with and implemented configuration systems. I’ve set up a few different kinds over time. I think the very first was something like the following: package MyApp::Util; use strict; use warnings; use JSON; our @DBI_PARAMS = do { open my $fh, '<', "C:/inetpub/myapp.json" or die "couldn't open myapp.json: $!"; @{decode_json(<$fh>)} }; ... 1; It certainly leaves a lot to be desired! At the minimum it at least gave us something better than hardcoded settings, but that’s almost all it gave us.

Posted Thu, Feb 19, 2015

OfflineIMAP Docker

This needs to be a short one as I don’t have a lot of time to write this, but I just wanted to quickly put out some thoughts about one of the more complex Docker setups I’ve made in the past few days. I use offlineimap to sync my mail to all of my local computers. I find that it paired with notmuch is both faster and better at search than vanilla Gmail, plus at some point I’d like to cut the cord with Gmail entirely.

Posted Fri, Feb 6, 2015

Docker: First Impressions

Today I deployed my first Docker based application. I just wanted to get down some basic thoughts about how it went down etc. Nearly all the hosted (ie not turnkey) apps that we have at work have some form of git-based deployment strategy. (Aside: Don’t say something silly to yourself like “git is not a deployment strategy!” It totally is, you just don’t like the tradeoffs.) Each one has it’s own special snowflake of push vs.

Posted Wed, Jan 28, 2015

Asynchronous Musings

Recently at work I’ve been working on our first section of code that is purely asynchronous. It’s pretty exciting! As I’ve discussed before, we’re using IO::Async, which has first class support for Futures. Futures are sorta kinda a way to express callbacks. They aren’t quite as powerful, but they can do nearly everything callbacks can do. (Specifically Futures represent a single action, not a stream of actions like callbacks can.)

Posted Thu, Jan 22, 2015

MORE MORE MORE: 2015 Edition

This is a three part post, but it’s supposed to be short, so lets get to it! Part I: Shorter Blog Posts I like to blog, but my posts tend to get really long and involved, because I sorta like to think from first principles and build up and tend to teach that way also. It’s generally not great; my documentation usually has something to be desired after I’m done.

Posted Sat, Jan 17, 2015

NSIS Sucks

This is the first article of a series on Windows Installers. (Note from the future: I have happily been able to abandon Windows professionally, so there will almost surely be no more of these.) I wrote an installer for work using Nullsoft Installer System (aka NSIS) about 18 months ago. (To be completely honest I wrote most of it but my coworker has to take a good portion of the credit for finishing it all the way.

Posted Thu, Oct 2, 2014

How to replace your CyanogenMod Kernel for Fun and Profit

I’ve recently been on a journey of discovery with respect to “observability” tools. I’m sure many other Linux users have felt the lust after DTrace that first the relatively obscure Solaris (and kids) and now the totally non-obscure OSX users have. After watching various presentations about DTrace features I’ve kept my ear open for features that are similar on Linux. Last month I posted about strace and sysdig. Both strace and sysdig are pretty coarse compared to what can be done with DTrace, though both are pretty great.

Posted Thu, Aug 28, 2014

Concurrency and Asynchrony in Perl

Lately I’ve been in situations where I need to write some event driven, parallel code. Most people call that “async” and I’ll stick to that for now. What I’ve been doing is writing a little TCP service that can accept any number of clients at the same time (though typically only one) and interact with the clients in a single process and with no multithreading. As surely many have remarked before, this is to some extent the future of computing.

Posted Tue, Jul 29, 2014

DBIx::Class: Parameterized Relationships

UPDATE (2017-10-17): The hack in this post no longer works; please check out DBIx::Class::ParameterizedJoinHack for something more likely correct. Probably once a week in the DBIx::Class channel someone asks if there is a way to pass arguments to a relationship. There is an answer but it isn’t pretty or for the faint of heart, so I finally have decided that I should write up a post detailing how to do it and nicely hide it from the user.

Posted Tue, Jul 22, 2014

A Gentle TLS Intro for Perlers

At work we’ve recently been audited for security by one of our customers and one of the takeaways was that we need to encrypt more things. Specifically all things. This lead me on a journey of discovery. In this post I’ll give some basic sample code on how to set up and debug a server using TLS, as well as some basic info on TLS itself. TLS? TLS is what most people think of as SSL.

Posted Thu, Jul 17, 2014

A Few of My Favorite Tools

strace Recently I’ve started branching out some in my debugging style. In the past it was usually adding print statements, reading docs carefully, reading logs, etc. I still mostly add print statements when I’m debugging my own code, but when trying to figure out why some random program isn’t working, instead of reading docs I go straight to strace. If you don’t already know, strace traces system calls, so it effectively gets between the program and the kernel and lists all the system calls being made.

Posted Mon, Jul 7, 2014

Use Travis (and more)

At YAPC last week vanstyn was complaining about the fact that there is so much “assumed knowledge” in Perl. One of the examples he gave was TravisCI. There are a few tools that go with Travis that every Perler should know about. First off, use Travis! Step one is to enable it for your repo at$username. After that add a text file to your repo with the name .travis.yml with the following content:

Posted Sun, Jun 29, 2014

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