Skip to content

Instantly share code, notes, and snippets.

View MattOates's full-sized avatar

Matt Oates MattOates

View GitHub Profile
@awwaiid
awwaiid / Matplotlib.pm6
Last active April 22, 2017 09:49
pyplot wrapper
class Matplotlib {
use Inline::Python;
has $!py;
submethod BUILD() {
$!py = Inline::Python.new();
$!py.run('import matplotlib.pyplot')
}
@MattOates
MattOates / find-primes.p6
Last active March 23, 2023 21:51
Combined primes benchmark with a parallel implementation that does well to keep up despite doing a lot more calculations!
#!/usr/bin/env perl6
use v6;
use Stats;
sub bench(Str $name, Int $upto, &code) {
my ($start,$end);
my @times;
for 1..20 {
@MattOates
MattOates / dnadecode.p6
Last active June 25, 2018 17:02
Tools to encode and decode files as DNA sequence text assuming 2bit style byte encodings.
#!/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;