Skip to content

Instantly share code, notes, and snippets.

View grantm's full-sized avatar

Grant McLean grantm

View GitHub Profile
@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 / 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 / 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 / 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 :-)
#
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},
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};