Skip to content

Instantly share code, notes, and snippets.

View draegtun's full-sized avatar

Barry Walsh draegtun

View GitHub Profile
@draegtun
draegtun / fasta.pl
Last active December 11, 2015 23:18
Faster fasta.pl
use 5.016;
use warnings;
# See: http://news.ycombinator.com/item?id=5141179
#
# This fasta.pl is a port of fasta.rb and is 2.6 times quicker than original alioth fasta.pl
use constant IM => 139968;
use constant IA => 3877;
use constant IC => 29573;
@draegtun
draegtun / goldilocks_1_port_from_js.pl
Last active December 11, 2015 04:08
Goldilocks (subset) in perl 5 & 6
use 5.016;
use warnings;
# Inspired by: http://news.ycombinator.com/item?id=5024754 | http://news.ycombinator.com/item?id=5025485
# (port of) - https://gist.github.com/3755270
package Bear {
sub new {
my ($class, $porridge, $chair, $bed) = @_;
bless {
@draegtun
draegtun / gist:2836306
Created May 30, 2012 13:20
Log of Perl 5.16 install + cpanm + Moose & MongoDB
[~]$ date
Wed 30 May 2012 13:01:15 BST
[~]$ perlbrew install perl-5.16.0
Fetching perl-5.16.0 as /Users/barry/perl5/perlbrew/dists/perl-5.16.0.tar.gz
Installing /Users/barry/perl5/perlbrew/build/perl-5.16.0 into ~/perl5/perlbrew/perls/perl-5.16.0
This could take a while. You can run the following command on another shell to track the status:
tail -f ~/perl5/perlbrew/build.log
@draegtun
draegtun / Compute.pl
Created March 22, 2012 10:23
Saw this and just wanted to play!
#
# see http://perl.plover.com/idiocy/Addition.pm by MJD
#
use 5.014;
use warnings;
{
package Compute;
use Carp;
@draegtun
draegtun / accessor.pl
Created February 9, 2012 20:07
Python accessor example converted to Moose
{
package AnotherPerson;
use Moose;
use namespace::autoclean;
has _firstname => (is => 'rw', isa => 'Str', accessor => 'firstname');
has _lastname => (is => 'rw', isa => 'Str', accessor => 'lastname' );
}
my $you = AnotherPerson->new;
@draegtun
draegtun / arity.io
Created November 2, 2011 16:16
block() with unknown arity
arity := block (
"You provided #{call argCount} args" interpolate println
call evalArgs foreach (arg, "... #{arg}" interpolate println)
)
// "call evalArgs" is a shortcut for "call message argsEvaluatedIn(call sender)"
var := "test"
arity call( "1", 2 + 2, var );
arity call
@draegtun
draegtun / find_hn_users_on_metacpan.pl
Created September 16, 2011 19:16
Find Hacker News (HN) users on MetaCPAN
#!/usr/bin/env perl
use 5.014;
use warnings;
use LWP::UserAgent;
use JSON 'decode_json';
# Simple script to get MetaCPAN users that use Hacker News (http://news.ycombinator.com/)
my $ua = LWP::UserAgent->new;
@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
@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