Skip to content

Instantly share code, notes, and snippets.

View jeffa's full-sized avatar

Jeff Anderson jeffa

View GitHub Profile
@jeffa
jeffa / oauth2-perl-sign-on.pl
Last active December 23, 2015 09:39
Google APIs Client Library for Perl
#!/usr/bin/env perl
package LWP::Authen::OAuth2::Dancer;
our $VERSION = '0.1';
use Dancer ':syntax';
use LWP::Authen::OAuth2;
our $oauth2 = LWP::Authen::OAuth2->new(
client_id => '',
client_secret => '',
service_provider => 'Google',
@jeffa
jeffa / oauth1-perl-sign-on.pl
Last active December 24, 2015 12:18
Twitter APIs Client Library for Perl
#!/usr/bin/env perl
package LWP::Authen::OAuth2::Dancer;
our $VERSION = '0.1';
use Dancer ':syntax';
use Net::Twitter;
use Scalar::Util 'blessed';
our $nt = Net::Twitter->new(
traits => [qw/API::RESTv1_1/],
consumer_key => '',
@jeffa
jeffa / ssh-auth-add.pl
Last active August 29, 2015 14:02
Bootstrap your ssh public key to a remote server
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
use Getopt::Long;
use Pod::Usage;
GetOptions (
'r|remote=s' => \my $remote,
@jeffa
jeffa / a2b.sh
Last active August 29, 2015 14:05
ASCII to 8bit Binary
perl -e'print /\s+/ ? $/ : unpack B8 => $_ for split //, shift' 'hello world '
@jeffa
jeffa / djson.sh
Last active August 29, 2015 14:05
Decode JSON file into Perl Data::Dump
perl -MData::Dumper -MJSON -MFile::Slurp -e"print Dumper decode_json read_file shift" foo.json
@jeffa
jeffa / tap2junit.sh
Last active August 29, 2015 14:05
Transform Perl TAP output into JUnit XML
prove -rl --formatter=TAP::Formatter::JUnit --timer > junit.xml
@jeffa
jeffa / MVC.pl
Last active February 24, 2017 03:15
Minimal example of an MVC implementation
#!/usr/bin/perl -l
package Model;
use Moose;
has state => ( is => 'ro', reader => 'get_state', default => 0 );
sub set_state { $_[0]->{state} += $_[1] }
package View;
use Moose;
sub update_display { print $_[1]->get_state }
@jeffa
jeffa / query-plack.cgi
Created April 22, 2015 23:25
Minimal Plack app that interacts with query params
#!/usr/bin/env plackup
use strict;
use warnings;
use Data::Dumper;
use Plack::Request;
use Plack::Response;
my $app = sub {
@jeffa
jeffa / auto-html.pl
Created May 4, 2015 18:46
Just another way to spit out HTML
package HTML::Auto;
use strict;
use warnings;
use Exporter 'import';
our @EXPORT = qw( html head title body h1 p br table Tr td );
our $AUTOLOAD;
sub new { bless {}, shift }
sub AUTOLOAD {
my $self = ref($_[0]) eq __PACKAGE__ ? shift : undef;
my $attr = ref($_[0]) eq 'HASH' ? shift : {};
@jeffa
jeffa / package-name2markdown-list.sh
Last active August 29, 2015 14:20
Generates list of MD linked package names
grep package t/lib/Test/Strategy/*.pm | perl -F'\s' -lape's/(:package|;)//for@F;$_=sprintf" * [%s](/%s)",reverse@F'