Skip to content

Instantly share code, notes, and snippets.

View AlexDaniel's full-sized avatar

Aleks-Daniel Jakimenko-Aleksejev AlexDaniel

  • Tallinn, Estonia
View GitHub Profile
@AlexDaniel
AlexDaniel / primes.p6
Created May 4, 2016 13:07
Pointless benchmark
#!/usr/bin/env perl6
sub get_primes(int $n) {
return () if $n < 2;
return (2) if $n == 2;
my int @s = ();
loop (my int $i = 3; $i <= $n; $i+=2) {
@s.push($i);
}
multi sub infix:<+>(Unit $x, Unit $y) {
if (not $x.isSameUnit($y)) {die "Units do not match.";}
return Unit.new(magnitude => $x.magnitude + $y.magnitude, units => $x.units);
}
my $a = Units::Unit.new(magnitude => 1.2, units => ("m" => 1));
my $b = Units::Unit.new(magnitude => 5.0, units => ("m" => 1));
say $a + $b;
@AlexDaniel
AlexDaniel / doc.perl6_checklink
Last active July 26, 2020 12:04
doc.perl6.org broken links
@AlexDaniel
AlexDaniel / #! perl6
Last active September 3, 2016 02:38
Shebangs in different perl 6 modules (read “|” as “/”)
path-iterator
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@AlexDaniel
AlexDaniel / test.pl6
Last active July 8, 2017 15:51 — forked from dogbert17/test.pl6
Fails when run normally but works with MVM_SPESH_DISABLE=1
use nqp;
{
constant $read-file = "README.md".IO;
$read-file.IO.r;
for ^1000 {
my $p = Proc::Async.new( | «/bin/cat $read-file» );
my $output = '';
$p.stdout.tap: -> $s { $output ~= $s; };
await $p.start;
use nqp;
my $html;
my $proc = run "wget", "-o", "/dev/null", "-O", "-", "https://www.fimfiction.net/bookshelf/149291/", :out;
$html = $proc.out.slurp-rest;
say "html is " ~ $html.chars ~ " chars";
nqp::force_gc;
say "/proc/$*PID/statm".IO.lines[0].split(/\s/)[5] * 4096 / 1024
@AlexDaniel
AlexDaniel / mustache-hyper.pl6
Last active August 20, 2017 16:43 — forked from scmorrison/mustache-hyper.pl6
Perl 6 - Template::Mustache.render dies with hyper
#!/usr/bin/env perl6
use lib ‘data/all-modules/softmoth/p6-Template-Mustache’;
use v6;
#use v6.d.PREVIEW;
use Template::Mustache;
my $html = q:to/EOF/;
<html>
{{> head }}