Skip to content

Instantly share code, notes, and snippets.

View grantm's full-sized avatar

Grant McLean grantm

View GitHub Profile
diff --git a/lib/Starman/Server.pm b/lib/Starman/Server.pm
index bf11ed4..6f51cb8 100644
--- a/lib/Starman/Server.pm
+++ b/lib/Starman/Server.pm
@@ -31,6 +31,9 @@ sub run {
if ( $options->{pid} ) {
$extra{pid_file} = $options->{pid};
}
+ if ( $options->{log_file} ) {
+ $extra{log_file} = $options->{log_file};
diff --git a/lib/Plack/Runner.pm b/lib/Plack/Runner.pm
index de83a23..70b58b6 100644
--- a/lib/Plack/Runner.pm
+++ b/lib/Plack/Runner.pm
@@ -50,6 +50,7 @@ sub parse_options {
'r|reload' => sub { $self->{loader} = "Restarter" },
'R|Reload=s' => sub { $self->{loader} = "Restarter"; $self->loader->watch(split ",", $_[1]) },
'L|loader=s' => \$self->{loader},
+ "access-log=s" => \$self->{access_log},
"h|help" => \$self->{help},
@grantm
grantm / ChartImage.pm
Created March 13, 2012 20:50
ChartImage.pm
# A quick hack for demoing using App::p to produce graphs from the command-line
# using Perl 1-liners.
#
# E.g.: to look through an Apache access log file and produce a bar graph of
# requests by hour of the day (00-23):
#
# p -nE 'm{/2012:(\d\d)} && $tally{$1}++ }{ S ChartImage->bar_url(data => \%tally, size => "700x300")' access.log
#
# Use it, copy it, sell it, claim it as your own - I don't care :-)
#
@grantm
grantm / tap.log
Created March 25, 2012 21:31
cpan-api failed test output
cpan-api$ prove -lv t/release/multiple-modules.t
t/release/multiple-modules.t ..
ok 1 - name ok
ok 2 - author ok
not ok 3 - Release is not first
# Failed test 'Release is not first'
# at t/release/multiple-modules.t line 19.
ok 4 - includes three files with modules
ok 5 - file name
@grantm
grantm / gist:3104491
Created July 13, 2012 11:49
Test failure installing Pithub from CPAN
$ make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/live/*.t
t/basic.t ............... 1/?
# Failed test 'use Pithub;'
# at t/basic.t line 8.
# Tried to use 'Pithub'.
# Error: Invalid default 0 at /usr/local/share/perl/5.10.1/Method/Generate/Accessor.pm line 49.
# Compilation failed in require at /home/grant/.cpan/build/Pithub-0.01012-akcvbg/blib/lib/Pithub/Base.pm line 14.
# BEGIN failed--compilation aborted at /home/grant/.cpan/build/Pithub-0.01012-akcvbg/blib/lib/Pithub/Base.pm line 14.
# Compilation failed in require at /usr/local/share/perl/5.10.1/Module/Runtime.pm line 317.
@grantm
grantm / gist:3520281
Created August 29, 2012 23:23
Fix single colon in search queries
--- a/lib/MetaCPAN/Web/Controller/Search.pm
+++ b/lib/MetaCPAN/Web/Controller/Search.pm
@@ -22,6 +22,9 @@ sub index : Path {
$query =~ s{\.pm\b}{};
}
+ # normalise ":", "'" and "-" separators to "::"
+ $query =~ s{\b[:'-]\b}{::}g;
+
my $model = $c->model('API::Module');
@grantm
grantm / diff-encoding.patch
Created September 27, 2012 02:33
Best efforts decoding of output from diff command
diff --git a/lib/MetaCPAN/Server/Diff.pm b/lib/MetaCPAN/Server/Diff.pm
index 2f90e6e..98c6306 100644
--- a/lib/MetaCPAN/Server/Diff.pm
+++ b/lib/MetaCPAN/Server/Diff.pm
@@ -2,6 +2,7 @@ package MetaCPAN::Server::Diff;
use Moose;
use IPC::Run3;
+use Encoding::FixLatin qw(fix_latin);
@grantm
grantm / gist:4367372
Last active December 10, 2015 02:28
Ever forgotten the ':' after the hostname of an scp command?
# a useful addition to anyone's .bashrc
#
# Note, you don't want this function in effect on the remote host side of the scp transfer,
# so make sure to only define it for interactive shells, e.g.: wrap with: if [ ! -z "$PS1" ]
function scp() {
if echo "$@" | grep -q ':'
then
/usr/bin/scp "$@"
else
@grantm
grantm / gist:4773217
Last active December 12, 2015 12:39
Syntactic sugar for DBIx::Class stuff in Dancer
# In my Dancer app I load a 'user' record like this:
my $user = User->find( param('id') ); # usually wrapped in a check that the record was found
# There are a number of 'moving parts' to allow this to work.
# Near the top of my Dancer code I have this:
@grantm
grantm / gist:5242453
Created March 26, 2013 01:47
cpan-api test failures
$ prove -l -v
t/fakecpan.t ..
ok 1 - got ElasticSearch object
ok 2 - Connected to the ElasticSearch test instance on 127.0.0.1:9900
ok 3 - put mapping
ok 4 - remove old fakepan
ok 5 - make fake cpan
ok 6 - index fakecpan
ok 7 - latest
ok 8 - index authors