Skip to content

Instantly share code, notes, and snippets.

Avatar

Grant McLean grantm

View GitHub Profile
View gist:74981ddb68a4149ef39ad360be155bbe
### Keybase proof
I hereby claim:
* I am grantm on github.
* I am grantmnz (https://keybase.io/grantmnz) on keybase.
* I have a public key ASCDS3p9-PMlPFwXwLZqwrGgF5c2zAE8XKb0aEODSMQNBQo
To claim this, I am signing this object:
@grantm
grantm / metacpan-v1-fields.md
Created Nov 13, 2016
Metacpan API /v1 fields
View metacpan-v1-fields.md
View clippy.cow
$the_cow = <<EOC;
$thoughts
$thoughts __
/ \\
| |
@ @
|| ||
|| ||
|\\_/|
\\___/
@grantm
grantm / console.log
Created Dec 22, 2015
DNS queries against Slingshot nameservers
View console.log
~$ host www.lighthousepetone.co.nz 202.180.64.10
Using domain server:
Name: 202.180.64.10
Address: 202.180.64.10#53
Aliases:
Host www.lighthousepetone.co.nz not found: 2(SERVFAIL)
~$ host www.lighthousepetone.co.nz 202.180.64.11
Using domain server:
Name: 202.180.64.11
@grantm
grantm / gist:5242453
Created Mar 26, 2013
cpan-api test failures
View gist:5242453
$ 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
@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:
@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 / 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: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 / 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