Skip to content

Instantly share code, notes, and snippets.

View dwarring's full-sized avatar

David Warring dwarring

  • The C Peoples
  • New Zealand
View GitHub Profile
use Test;
my $p1000 = start {
(1..Inf).grep(*.is-prime)[999]
}
is $p1000.result, 7919, 'simple promise';
# not exiting on jvm
@dwarring
dwarring / gist:10070559
Created April 7, 2014 22:48
BT for S04-phasers/first.t SEGV
davidw@app01:~/git/roast$ gdb /home/davidw/git/rakudo/install/bin/moar
GNU gdb (GDB) 7.0.1-debian
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
# courtesy of https://gist.github.com/masak/244255
use v6;
enum Suit < ♥ ♦ ♣ ♠ >;
enum Rank (2, 3, 4, 5, 6, 7, 8, 9, 10,
'j', 'q', 'k', 'a');
class Card {
has Suit $.suit;
has Rank $.rank;
sub foo {say 'outer foo'}
sub infix:<bar>($a,$b) {say "outer bar {$a + $b}" }
sub infix:<baz>($a,$b) {say "outer baz {$a * $b}" }
foo();
2 bar 3;
2 baz 3;
say;
{
@dwarring
dwarring / gist:12c1e32440a8aea43337
Last active August 29, 2015 14:06
Bisection for parrot failures of advent-2010-day14.t etc
# rakudo bisections on parrot
# david warring 15-09-2014
# --------------------------
sub capture-said($code) {
my $output = '';
temp $*OUT = class {
method print(*@args) {
$output ~= @args.join;
}
}
% icu-config --unicode-version
5.2
% PERL6LIB=t/spec/packages prove -e 't/fudgeandrun --backend=parrot' -v t/spec/S05-mass/charsets.t
t/spec/S05-mass/charsets.t ..
1..17
ok 1 - ident chars
ok 2 - alpha chars
ok 3 - space chars
ok 4 - digit chars
ok 5 - alnum chars
sub repeat(Str $input --> Rat) {
my $phrase := :36($input);
my $l := (36 ** $input.chars) - 1;
$phrase/$l;
}
say (repeat('sixrocks') * 36 ** 40).base(36);
@dwarring
dwarring / gist:8e11f55207990944c0c9
Last active October 31, 2015 18:34
Perl6 Proxys getting hammered
class C {
has $!foo;
method foo is rw {
say "foo";
$!foo;
}
has $!bar;
method bar is rw {
Proxy.new(
@dwarring
dwarring / prof6.sql
Last active April 27, 2018 08:14
Pastable Rakudo profile routines query (https://docs.perl6.org/language/performance)
.mode columns
.headers on
.width 80
select
case when r.name = "" then "<anon>" else r.name end || " / " || r.file as "name/file",
r.line as "line",
sum(entries) as entries,
sum(case when rec_depth = 0 then inclusive_time else 0 end)/1000.0 as "inclusive(s)",
sum(exclusive_time)/1000.0 as "exclusive(s)"
from
npm http 304 https://registry.npmjs.org/sha1
npm http GET https://registry.npmjs.org/nqp-js-io
npm http 404 https://registry.npmjs.org/nqp-js-io
npm ERR! TypeError: Object.keys called on non-object
npm ERR! at Function.keys (native)
npm ERR! at installTargetsError (/usr/lib/node_modules/npm/lib/cache.js:708:24)
npm ERR! at /usr/lib/node_modules/npm/lib/cache.js:638:10
npm ERR! at saved (/usr/lib/node_modules/npm-registry-client/lib/get.js:148:7)
npm ERR! at /usr/lib/node_modules/graceful-fs/polyfills.js:133:7
npm ERR! at Object.oncomplete (fs.js:108:15)