Skip to content

Instantly share code, notes, and snippets.

View ab5tract's full-sized avatar

ab5tract ab5tract

  • Amsterdam, Netherlands
View GitHub Profile
class Codeword {
has Supply $.printer;
# has Sub $!codeword;
has Sub $.scrambler is rw;
has $!string;
has $!encoded-string;
method new( :$string = "bloop" ) {
my $printer = Supply.new;
$printer.act: { $_.say };
@ab5tract
ab5tract / gist:4dc7deb90ae8a75ecbcc
Last active August 29, 2015 14:18
Phrasings for the pow wow
A CompUnit is said to be '{@possible.roll(1)}' if and only if
it has guarunteed idempotence under the stipulations of
the CompUnit Recognition Act, local bylaws withstanding.
@possible = <
authoritative
registered
participating
idemnified
representing
@ab5tract
ab5tract / frame-printer.p6
Last active August 29, 2015 14:21
framerate printing
class Draw {
has $!supply;
has $!chan;
has $!interval = 1;
method new( $interval ) {
self.bless(:$interval);
}
submethod BUILD(:$!interval) {
@ab5tract
ab5tract / gist:9457079caa93244511b1
Last active August 29, 2015 14:23
flattened-index
my %h = 1 => [ [<what what>], [<how how>] ], 2 => [ [<this this>] ];
my $i = 0;
my $size = [+] %h.values.map({ +@^a });
(1..$size Z~ %h.values>>.map({ @($^a)})).say;
@ab5tract
ab5tract / overlaps-with.p6
Last active August 29, 2015 14:24
Overlaps With
use Test;
sub overlaps-with( $r1, $r2 ) {
$r1.min ~~ $r2 and $r1.max ~~ $r2 or $r2.min ~~ $r1 and $r2.max ~~ $r1
or ( $r1.min == $r2.min and ($r1.max <= $r2.max or $r2.max <= $r1.max) )
or ( $r2.min < $r1.min < $r2.max <= $r1.max )
or ( $r1.min < $r2.min < $r1.max <= $r2.max );
}
my @range-tests = (
#!/usr/bin/env perl6
use Test;
sub overlaps-with( $r1, $r2 ) {
$r1.min ~~ $r2 and $r1.max ~~ $r2 or $r2.min ~~ $r1 and $r2.max ~~ $r1
or ( $r1.min == $r2.min and ($r1.max <= $r2.max or $r2.max <= $r1.max) )
or ( $r2.min < $r1.min < $r2.max <= $r1.max )
or ( $r1.min < $r2.min < $r1.max <= $r2.max );
}
@ab5tract
ab5tract / sereal-test.p6
Last active August 29, 2015 14:25
Sereal::Pool::Perl5
use v6;
use Inline::Perl5;
class Sereal::Encoder::Perl5 {
has Inline::Perl5 $!p5;
has $!encoder;
submethod BUILD() {
$!p5 := Inline::Perl5.new;
@ab5tract
ab5tract / benchmark-for.p6
Last active August 29, 2015 14:26
for-vs-while-int-vs-Int
my $begin = DateTime.now;
say "Beginning at $begin";
my int @range = 0..^400;
my $count = 0;
for @range -> int $i {
for @range -> int $j {
for @range -> int $k {
module <%= @name %>
module Configurations
class Default < Waves::Configurations::Default
attribute 'dependencies'
dependencies ['first', 'second']
end
end
end
require 'foundations/simple'
module Blog
include Waves::Foundations::Simple
end