Skip to content

Instantly share code, notes, and snippets.

Avatar

ab5tract ab5tract

  • Amsterdam, Netherlands
View GitHub Profile
@ab5tract
ab5tract / raku rationale-matrix.p6 --timings-only 8
Last active Aug 7, 2020
Hilbert matrix cross product its inversion is a good demonstration of floating point versus rational arbitrary precision
View raku rationale-matrix.p6 --timings-only 8
Created 'Num' Hilbert of 8x8: 0s
Created 'Rat' Hilbert of 8x8: 0.0469023s
Starting 'Num' Hilbert test at 2020-08-07T17:32:09.217803+02:00
'Num' Hilbert inverse calculation: 8.0857941s
'Num' Hilbert (is identity? False): 8.0857941s
Starting 'Rat' Hilbert test at 2020-08-07T17:32:17.303597+02:00
'Rat' Hilbert inverse calculation: 5.3155128s
'Rat' Hilbert (is identity? True): 5.331197s
View file-check.p6
subset NonExistentFile of Str where { ! $_.IO.e }
multi sub check-file (NonExistentFile $file, $force where *.&so) { True }
multi sub check-file (Str $file, $force where { !$_ }) { True }
multi sub check-file (Str $file, $force where *.&so) { False }
my $force = False;
subset PassedCheck of Str where { check-file($_, $force) }
View secret.diff
commit 480b4571c09d832fc5dbe63d77b4df33a7c2d1c0
Author: ab5tract <john.haltiwanger@gmail.com>
Date: Thu Oct 17 17:46:33 2019 +0200
Add single-arg target to infix:<+>
diff --git a/pimbook/secret/lib/Secret.pm6 b/pimbook/secret/lib/Secret.pm6
index 379cfc6..eaceba7 100644
--- a/pimbook/secret/lib/Secret.pm6
+++ b/pimbook/secret/lib/Secret.pm6
View rex-extract.p6
#!/usr/bin/env perl6
use v6.d;
use REX::File;
use Audio::Sndfile;
sub MAIN(:i(:$in-dir), :o(:$out-dir)) {
mkdir $out-dir unless $out-dir.IO.d;
my (@fails, $total, %words);
View have-to-tap.p6
my $proc = Proc::Async.new(:r, 'echo',
'Man is amazing, but he is not a masterpiece');
react {
whenever $proc.stdout { say "OUT: $_" }
whenever $proc.start { done }
}
@ab5tract
ab5tract / ua-tester.p6
Last active Sep 16, 2016
Test all the P6 user agents
View ua-tester.p6
#!/usr/bin/env perl6
use v6;
use HTTP::UserAgent;
use LWP::Simple;
use Net::Curl;
use Net::Curl::Easy;
use Net::HTTP::GET;
@ab5tract
ab5tract / oo-monitors-test.p6
Created Aug 12, 2016
OO::Monitors breaks with custom initialization
View oo-monitors-test.p6
use v6;
use OO::Monitors;
monitor Grid {
has @!grid;
submethod BUILD() {
@!grid = [23, 42];
}
@ab5tract
ab5tract / test-case.p6
Created Aug 2, 2016
minimal-case-for-Array-of-Nums-smartmatch-bug
View test-case.p6
use v6;
my @tests = [
42.424242 => Buf.new( reverse 0b01000000, 0b01000101, 0b00110110, 0b01001101,
0b10001111, 0b11010101, 0b11001011, 0b01111001),
33.3 => Buf.new( reverse 0b01000000, 0b01000000, 0b10100110, 0b01100110,
0b01100110, 0b01100110, 0b01100110, 0b01100110),
];
my $double-c = q:to/ENDC/;
@ab5tract
ab5tract / naive-decorators.p6
Last active Jul 21, 2016
Naive Decorators in Perl 6
View naive-decorators.p6
#!/usr/bin/env perl6
class Decorator is Callable {
has &.funk;
has @.history;
has $.cached-result;
multi method new(&funk, @history = []) {
self.bless(:&funk, :@history);
}
View gist:1835272892d9ee58cdfb0a1bcd34e5c7
my class Reader {
my $.pos is rw = 0;
my $.buf;
method read(Buf $buf) {
...
}
method read-type(Any:U: $type) {
my $width = nativesizeof($type);