Skip to content

Instantly share code, notes, and snippets.

View ab5tract's full-sized avatar

ab5tract ab5tract

  • Amsterdam, Netherlands
View GitHub Profile
@ab5tract
ab5tract / naive-decorators.p6
Last active July 21, 2016 07:44
Naive Decorators in Perl 6
#!/usr/bin/env perl6
class Decorator is Callable {
has &.funk;
has @.history;
has $.cached-result;
multi method new(&funk, @history = []) {
self.bless(:&funk, :@history);
}
my class Reader {
my $.pos is rw = 0;
my $.buf;
method read(Buf $buf) {
...
}
method read-type(Any:U: $type) {
my $width = nativesizeof($type);
@ab5tract
ab5tract / bigint-timetrial.p6
Created March 21, 2016 14:08
Bigint speeds
use v6;
sub bigpackids(int @ids) {
my $ret = 0;
my $c = 0;
while $c++ < +@ids {
$ret = $ret +| (1 +< (@ids[$c] - 1));
}
return $ret;
@ab5tract
ab5tract / gist:d730a845a3915f7abdcf
Created January 29, 2016 11:30
async-transcoder.p6
#!/usr/bin/env perl6
use v6;
sub MAIN($dir) {
my $handler-supplier = Supplier.new;
my $handler-supply = $handler-supplier.Supply;
my %seen;
my $dispatch-promise = start {
say "Watching out on '$dir'";
@ab5tract
ab5tract / sha1.p6
Last active December 11, 2015 19:30 — forked from cognominal/sha1.p6
sha1 hash
subset Sha1 of Str where *.chars == 40 and m:i/<[A..Z 0..9]>/;
class Sha1H does Associative {
has $!sha1;
has %!h{Sha1(Str)};
method AT-KEY($_) { %!h{ .lc } };
method ASSIGN-KEY($_, $v) { %!h{ .lc } = $v }
}
class Sha1Str is Str {
unit class Grid;
#use Terminal::Print::Commands;
#
#constant T = Terminal::Print::Commands;
has @.grid;
has $!character-supply;
has $!control-supply;
module Chance {
my @faces = '⚀', '⚁', '⚂', '⚃', '⚄', '⚅';
sub term:<¿>() is export(:golf) { @faces.roll }
sub chance() is export { ¿ }
}
import Chance;
say chance;
#!/usr/bin/env ruby
require 'rubygems'
require 'i3-ipc'
i3 = I3::IPC.new
def process(data)
data.each do |ws|
if ws["focused"]
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 0 0 300 300
/period 2 def
/thick 1 def
2 2 scale
10 10 translate
thick setlinewidth
@ab5tract
ab5tract / gist:1224064
Created September 17, 2011 15:49
PoG - Tumblr Accounts
http://www.tumblr.com/tumblelog/seyalex
http://maxweidlich.tumblr.com/
http://quic0.tumblr.com
http://dennii3.tumblr.com/
http://www.tumblr.com/tumblelog/willem12
http://mbustraan.tumblr.com/
http://e-langhout.tumblr.com
http://www.tumblr.com/tumblelog/fajknerd
http://matthiasfelix.tumblr.com/
http://loocerasemag.tumblr.com