Skip to content

Instantly share code, notes, and snippets.

dmaestro

  • Traverse City, MI USA
Block or report user

Report or block dmaestro

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dmaestro
dmaestro / Latin-1-bytes-and-perl-6.txt
Created Apr 6, 2019
Question by Eric Lindblad about perl 6 and terminal encoding
View Latin-1-bytes-and-perl-6.txt
doug@ender:~/study$ perl6 -e 'say "Hôtel"'
Hô¿½xF4tel
doug@ender:~/study$ perl6 -e 'say "Hôtel".chars'
5
doug@ender:~/study$ perl6 -e 'say "Hôtel"' | od -Ax -t x1
000000 48 f4 8f bf bd 78 46 34 74 65 6c 0a
00000c
doug@ender:~/study$ perl6 -e 'utf8.new(0xF4, 0x8f, 0xbf, 0xbd).Str.ord.&{ "%x".sprintf($_) }.say'
10fffd
doug@ender:~/study$ perl6 -e 'utf8.new(0xF4, 0x8f, 0xbf, 0xbd).Str.uniname.say'
@dmaestro
dmaestro / z-length_negative_assertion.t
Created Mar 24, 2019
Test for rakudo/rakudo issue #2791
View z-length_negative_assertion.t
use v6;
grammar Chord {
rule TOP { <key> \S* }
regex bare-key { <key> <!before \S > }
regex bare-key-one { <key> [ <!before \S > | $ ] }
regex bare-key-two { <key> <!before <:!Space> > }
token natural-note { <[ A..G ]> }
token accidental { <[ \# b ]> }
regex key { <natural-note> <accidental>? }
@dmaestro
dmaestro / CodePointComparison.txt
Created Mar 19, 2019
Example of processing codepoint sequences in Perl 6
View CodePointComparison.txt
doug$ cat z2.pl6
use v6;
my $s = "Zoé";
.chr.print for |$s.NFC, 10;
.chr.print for |$s.NFD, 10;
doug$ perl6 z2.pl6
Zoé
Zoé
perl6 z2.pl6 | perl6 -e '$*IN.encoding(<utf8>); my $z1 = $*IN.get; my $z2 = $*IN.get; say $z1 eq $z2'
True
@dmaestro
dmaestro / TestD.pm6
Created Sep 9, 2018
Delegation fails with "Cannot invoke this object" when this package is used
View TestD.pm6
unit package TestD;
role R {
method foo( --> Int ) { ... }
}
class C {
has R $.delegate
handles *
is required;
@dmaestro
dmaestro / unquote_via_eval.pm
Created Jan 3, 2018
Rakudo* 2017.10 failure
View unquote_via_eval.pm
#!/usr/bin/env perl6
use v6;
use MONKEY-SEE-NO-EVAL;
# "project_gbclient_t_controller_signup_process_purchase_validation_07-wordpress_blog_title_t"
my @raw-names = $*IN.lines.grep({ / ^ '"' <[ \w - ]>+ '"' $ / })».EVAL;
.say for @raw-names;
# cat 185_valid_test_names.txt | MVM_SPESH_DISABLE= bin/unquote_via_eval.p6 | wc -l
# 108 [ non-repeatable count ]
# cat 185_valid_test_names.txt | MVM_SPESH_DISABLE=1 bin/unquote_via_eval.p6 | wc -l
@dmaestro
dmaestro / 8queens.pl
Created Oct 12, 2017
Fundamental Solutions to Eight Queens Problem
View 8queens.pl
use v6;
constant size := 8;
my @corners = map { $_[0] * size + $_[1] }, ((0, size-1) X (0, size-1));
our class Square is Int {
has Int $!piece;
method new (|) {
Metamodel::Primitives.rebless(
You can’t perform that action at this time.