Skip to content

Instantly share code, notes, and snippets.

View MattOates's full-sized avatar

Matt Oates MattOates

View GitHub Profile
@MattOates
MattOates / Newick.pm
Last active January 1, 2016 08:29
Newick grammar in Perl6... the quoted and unquoted tokens fail if you replace unquoted with <[A..Z]>* it works for the example newick string :/
#!/usr/bin/env perl6
use v6;
grammar BioInfo::Parser::Tree::Newick {
rule TOP {
<tree>+
}
rule tree {
#!/usr/bin/env bash
blue='\033[34m'
cls='\033[0m'
echo -e "$blue"`date +[%H:%M:%S]`' Cloning fresh Rakudo repo'"$cls"
git clone https://github.com/rakudo/rakudo.git
echo -e "$blue"`date +[%H:%M:%S]`' Checking out Plano 2014.01 tagged release'"$cls"
cd rakudo
git checkout Plano
my @list = ('P','P','G','A','P','T','A','T','T','A');
for 1..4 -> $k { for 1,[email protected] -> $i { say "$i" } }
@MattOates
MattOates / fib_app.pl
Created February 14, 2014 18:30
Quick test of interlaced recursive function and template stuff in Mojolicious
#!/usr/bin/env perl
use Mojolicious::Lite;
get '/:n' => sub {
my $self = shift;
$self->render('index');
};
app->start;
__DATA__
@MattOates
MattOates / gist:11257194
Last active July 18, 2016 18:45
Trying out running a compiled Perl6 program with moarvm
Perl6 compiled with rakudobrew about ten minutes ago perl6 version 2014.04-96-g375404d built on MoarVM version 2014.04-29-ga109e8d
test.p6 is just: say "Hello";
$ perl6 --target=mbc --output=test.moarvm test.p6
Then
$ moar --libpath="/home/oates/.rakudobrew/moar-HEAD/install/languages/nqp/lib" --libpath="/home/oates/.rakudobrew/moar-HEAD/install/languages/perl6/lib" --libpath="/home/oates/.rakudobrew/moar-HEAD/install/languages/perl6/runtime" test.moarvm
Segmentation fault (core dumped)
@MattOates
MattOates / fasta.p6
Last active August 29, 2015 14:00
Playing with FASTA parsing
#!/usr/bin/env perl6
use v6;
class Bio::Sequence {
has Str $.id = "";
has Str $.comment = "";
has Str $.sequence = "";
}
class Bio::Sequence::Amino is Bio::Sequence {
@MattOates
MattOates / gist:972ae2cc8428155c0592
Created May 30, 2014 17:12
Whiteboard cleanup onleliner
convert input.jpg -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 output.jpg
@MattOates
MattOates / SQL.pl
Created August 28, 2014 15:39
SQL Named Parameter Replacement
#!/usr/bin/env perl
use warnings;
use strict;
use Data::Dumper;
sub sql {
my ($sql,%data) = @_;
my @parameters;
foreach my $placeholder ($sql =~ /:([a-zA-Z_]+)/g) {
if (ref $data{$placeholder} eq 'ARRAY') {
@MattOates
MattOates / runencode.pl
Created September 5, 2014 14:43
Function to run length encode stuff in Perl
#Take an arrayref of numbers or a delimited string and returns a list of start-end pairs for runs of values above a threshold
sub runencode {
my ($probs,%opts) = @_;
#Some default optional parameters
$opts{delimiter} //= ',';
$opts{threshold} //= 0.5;
$opts{cmp} //= sub {$_[0] >= $_[1]};
#If a string was passed split it into values
@MattOates
MattOates / Grammar_trace.txt
Created December 14, 2014 17:39
Day 15 of the Perl6 2014 Advent Calendar
TOP
>
| record
>
| | id
>
| | * MATCH "hello"
>
| | comment
>