Skip to content

Instantly share code, notes, and snippets.

View mrmuskrat's full-sized avatar

Matthew Musgrove mrmuskrat

View GitHub Profile
#!/usr/bin/env perl
use Mojolicious::Lite;
use DBIx::Connector;
helper db => sub {
state $db = DBIx::Connector->connect("dbi:mysql:host=localhost;db=testdb", 'testuser', 'xxxsecret')
};
helper get_data => sub {
@pjlsergeant
pjlsergeant / git.pl
Created November 27, 2012 12:42
GraphViz Git Commit Tree
#!perl
# Draw the commit graph of a git repository, using GraphViz. Supply the directory
# the repo is in as the first argument. Writes a file called 'repo.svg' to the CWD.
use strict; use warnings;
use Cwd;
use Git::PurePerl;
use GraphViz2;
@pjlsergeant
pjlsergeant / bubble.pl
Created November 27, 2012 09:23
BubbleCharts of DB Tables
#!perl
# Display a bubble chart of DB tables, with rows and relationships to other tables
# Either run directly: perl bubble.pl
# Or with Plack: plackup bubble.pl
use strict; use warnings;
# cpanm Dancer Template DBIx::Class::Schema::Loader Data::Google::Visualization::DataTable
use Dancer;
@dpetrov
dpetrov / cpan_favorites.pl
Created November 7, 2012 08:24
Install all favorited distributions
#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
use Mojo::UserAgent;
my $url = shift @ARGV or die "Usage: $0 metacpan_author_url";
my $ua = Mojo::UserAgent->new;
my $dom = $ua->get($url)->res->dom;
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@afair
afair / parse_hstore.pl
Created August 2, 2011 17:58
Perl methods to parse and create PostgreSQL hstore column data
##----------------------------------------------------------------
## HSTORE: PostgreSQL key-value store column type
##----------------------------------------------------------------
# Double-quotes the value, escaping embedded double-quotes. This is NOT the
# same as db quoting (which uses apostrophes), and any value here must also
# be quote()'ed before sending to the database.
sub double_quote {
my ($self, $v) = @_;
$v =~ s/"/\\"/g;