November 2016 Archives

sudo

I don't post as much as I would like to as all my free time is spent working on Tau Station, so I thought I should remind folks that I'm still alive, still hacking on Perl, and still writing obscure technical humor:

ifeq ($(shell whoami), root)
    MESSAGE = "Okay."
else
    MESSAGE = "What? Make it yourself."
endif

NOECHO = @

me ::
    - $(NOECHO) echo $(MESSAGE)

a ::
    - $(NOECHO) echo

sandwich ::
    - $(NOECHO) echo

Easily clean up a team's remote git branches

There's a problem that I've seen on every team I've worked with that uses git. Because at Tau Station we're fairly merciless about technical debt--which makes the code base pretty sweet to work with--we take all technical debt issues seriously on the theory that once we launch, it may be too late to clean up (a silly idea in theory, but a prevalent one in practice).

The following technical debt issue is actually causing us a problem, though it's more of a process problem than a technical one:

05:35:02 (master) ~/veure $ git branch -a | wc -l
     272

Wow! We have 272 branches? Most of those are are long merged or abandoned. We've discovered that there are a couple of them which got overlooked (I'm tempted to blame github's poor PM tooling, but it's a lousy craftsman who blames his tools). We tried asking devs to find all of their remote branches and review them and delete them, but that turned out to be a rather daunting task and they're still missing branches.

Now, with a simple Perl script, we have a solution.

Seeing the SQL in DBIx::Class

There's no question that DBIx::Class is the dominant ORM in Perl. That's because it's fast, it's flexible, and sane. Well, mostly sane, until you need some introspection (if anyone knows a better way to do this, I'm all ears!):

sub _get_json_columns ( $self, $schema_class ) {
    state $json_columns_for = {};
    unless ( exists $json_columns_for->{$schema_class} ) {
        my $columns = $self->schema->resultset($schema_class)
          ->result_source->columns_info;
        $json_columns_for->{$schema_class}
          = [ grep { 'json' eq $columns->{$_}{data_type} } keys %$columns ];
    }
    return $json_columns_for->{$schema_class};
}

But what's terribly frustrating to many devs is getting DBIx::Class to show the queries it's executing, along with the bind parameters (one without the other is often useless).

About Ovid

user-pic Freelance Perl/Testing/Agile consultant and trainer. See http://www.allaroundtheworld.fr/ for our services. If you have a problem with Perl, we will solve it for you. And don't forget to buy my book! http://www.amazon.com/Beginning-Perl-Curtis-Poe/dp/1118013840/