Skip to content

Instantly share code, notes, and snippets.

Avatar

Matt Oates MattOates

View GitHub Profile
View super_cool_script.pl
#!/usr/bin/env perl
#Write sane perl
use strict;
use warnings;
use feature 'say';
#Use some modules which are sufficiently round wheels
use Text::CSV;
use Getopt::Long;
View my_series_fail.p6
my @list = ('P','P','G','A','P','T','A','T','T','A');
for 1..4 -> $k { for 1,1+$k...@list.end -> $i { say "$i" } }
@MattOates
MattOates / fib_app.pl
Created Feb 14, 2014
Quick test of interlaced recursive function and template stuff in Mojolicious
View fib_app.pl
#!/usr/bin/env perl
use Mojolicious::Lite;
get '/:n' => sub {
my $self = shift;
$self->render('index');
};
app->start;
__DATA__
@MattOates
MattOates / fasta.p6
Last active Aug 29, 2015
Playing with FASTA parsing
View fasta.p6
#!/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
Whiteboard cleanup onleliner
View gist:972ae2cc8428155c0592
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 Aug 28, 2014
SQL Named Parameter Replacement
View SQL.pl
#!/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 Sep 5, 2014
Function to run length encode stuff in Perl
View runencode.pl
#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 Dec 14, 2014
Day 15 of the Perl6 2014 Advent Calendar
View Grammar_trace.txt
TOP
>
| record
>
| | id
>
| | * MATCH "hello"
>
| | comment
>
@MattOates
MattOates / BioInfo.pm6
Last active Aug 29, 2015
Trying to add a little Slang to https://github.com/MattOates/BioInfo so that ` ` construct a Seq object
View BioInfo.pm6
use QAST:from<NQP>;
sub BioInfo::seq(Str $sequence) is export {
use BioInfo::Parser::FASTA::Grammar;
use BioInfo::Parser::FASTA::Actions;
BioInfo::Parser::FASTA::Grammar.parse($sequence, actions => BioInfo::Parser::FASTA::Actions).ast;
}
sub EXPORT(|) {
role BioInfo::Grammar {
@MattOates
MattOates / six-frame-translation
Created Mar 24, 2015
Mising bits from P5 necessary for a port of the six-frame-translation perl6-bench benchmark
View six-frame-translation
use strict;
use feature 'say';
use Data::Dumper;
use List::MoreUtils 'zip';
#Implement something similar to the Perl6 X meta operator
#probably not the best implementation in the world
sub X {