Skip to content

Instantly share code, notes, and snippets.

Avatar

Matt Oates MattOates

View GitHub Profile
@MattOates
MattOates / dnadecode.p6
Last active Jun 25, 2018
Tools to encode and decode files as DNA sequence text assuming 2bit style byte encodings.
View dnadecode.p6
#!/usr/bin/env perl6
use v6;
sub MAIN ($file) {
my %bases = (T => '00', C => '01', A => '10', G => '11');
my %bytes = (0..255).map({ sprintf('%08d', $_.base(2)) }) Z=> (0..255);
my $io = $file.IO.open;
while (my $hunk = $io.readchars(4)) {
last unless $hunk.chars == 4;
@MattOates
MattOates / find-primes.p6
Last active Jul 13, 2021
Combined primes benchmark with a parallel implementation that does well to keep up despite doing a lot more calculations!
View find-primes.p6
#!/usr/bin/env perl6
use v6;
use Stats;
sub bench(Str $name, Int $upto, &code) {
my ($start,$end);
my @times;
for 1..20 {
@awwaiid
awwaiid / Matplotlib.pm6
Last active Apr 22, 2017
pyplot wrapper
View Matplotlib.pm6
class Matplotlib {
use Inline::Python;
has $!py;
submethod BUILD() {
$!py = Inline::Python.new();
$!py.run('import matplotlib.pyplot')
}