Skip to content

Instantly share code, notes, and snippets.

Avatar

Grant McLean grantm

View GitHub Profile
View gist:465025
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};
View gist:474760
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},
View 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 Mar 25, 2012
cpan-api failed test output
View tap.log
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 Jul 13, 2012
Test failure installing Pithub from CPAN
View gist:3104491
$ 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 / start-es.sh
Created Aug 1, 2012
Launch ES with ulimit raise for more filehandles
View start-es.sh
#!/bin/bash
ES_BINARY=/home/grant/elasticsearch-0.18.7/bin/elasticsearch
if [ -z "$1" ]
then
sudo $0 as-root $USER
stty sane
elif [ "$1" = "as-root" ]
then
@grantm
grantm / gist:3520281
Created Aug 29, 2012
Fix single colon in search queries
View gist:3520281
--- 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 Sep 27, 2012
Best efforts decoding of output from diff command
View diff-encoding.patch
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 Dec 10, 2015
Ever forgotten the ':' after the hostname of an scp command?
View gist:4367372
# 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 Dec 12, 2015
Syntactic sugar for DBIx::Class stuff in Dancer
View gist:4773217
# 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: