Skip to content

Instantly share code, notes, and snippets.

View draegtun's full-sized avatar

Barry Walsh draegtun

View GitHub Profile
@draegtun
draegtun / mockdbi.pl
Created August 20, 2010 17:35
Test::MockDBI issue from Stackoverflow question
#!/usr/bin/env perl
BEGIN { push @ARGV, "--dbitest=1"; }
use 5.012;
use warnings;
use Test::More;
use Test::MockDBI ':all';
@draegtun
draegtun / get_perl_versions.pl
Created September 17, 2010 10:21
Get perl version releases using its git tags
#!/usr/bin/env perl
use 5.012;
use warnings;
use Net::GitHub::V2::Repositories;
my $github = Net::GitHub::V2::Repositories->new(
owner => 'mirrors', repo => 'perl',
);
@draegtun
draegtun / webapp.io
Created November 17, 2010 14:24
Expose any Io object over the web. An interesting little snippet
#!/usr/bin/env io
Object webapp := method (
block (reqMsg,
p := reqMsg split("/")
self doMessage(p first asMessage setArguments( p rest map(asMessage) ))
)
)
doRelativeFile("webserver.io")
@draegtun
draegtun / webapp.psgi
Created November 17, 2010 16:41
Expose any Perl object over the web. An interesting little snippet (using Plack)
#!/usr/bin/env perl
use 5.012;
use warnings;
use autobox::Core;
my $expose = []; # expose an Array object (singleton)
my $app = sub {
my ($func, @attrs) = $_[0]->{PATH_INFO}->split('/')->tail;
@draegtun
draegtun / webapp_continuity.pl
Created November 17, 2010 17:02
Expose any Perl object over the web. An interesting little snippet (using Continuity)
#!/usr/bin/env perl
use 5.012;
use warnings;
use autobox::Core;
use Continuity;
Continuity->new( port => 9292 )->loop;
sub main {
@draegtun
draegtun / charge_object.io
Created December 20, 2010 17:11
Charging Objects in Io
# Charging Objects in Io
#
# See "Charging Objects in Ruby"
# - http://timeless.judofyr.net/charging-objects-in-ruby
# - http://news.ycombinator.com/item?id=2022107
Rules := Object clone do (
rules := list()
+ := method (obj,
@draegtun
draegtun / one_liners.io
Created June 7, 2011 08:07
10 (8!) Io one liners to impress your friends
#!/usr/bin/env io
# see: http://news.ycombinator.com/item?id=2610243
# http://news.ycombinator.com/item?id=2612686
doFile("x_load_me.io")
# 1
1 to(10) map(*2)
@draegtun
draegtun / execute_in_reverse.io
Created June 7, 2011 08:12
Execute statements (ie. messages) in reverse
#!/usr/bin/env io
# see : http://news.ycombinator.com/item?id=2144880
executeInReverse := method (
m := call argAt(0)
stmts := list() // list of statements (ie. messages)
loop (
rest := m next // rest of messages after current
#!/usr/bin/env io
# see - http://news.ycombinator.com/item?id=1626018
Hash := Object clone do (
with := method (
hash := Map clone
call message arguments foreach (arg,
# arg = k(v) for eg. t(0)
k := arg name
@draegtun
draegtun / MooseBase.pm
Created September 8, 2011 18:49
One Base Class to Rule Them All (in Perl)
package MooseBase;
use Moose;
use Class::MOP;
# One Base Class to Rule Them All!
#
# see: https://www.destroyallsoftware.com/blog/2011/one-base-class-to-rule-them-all
# https://github.com/garybernhardt/base/blob/master/lib/base.rb
# http://news.ycombinator.com/item?id=2963525