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 / gist:103ac74c97d56d8c5f12
Created August 18, 2014 19:20
readelf -s "$(dpkg -L libxkbcommon0 | grep -m 1 libxkbcommon.so.0)"
Symbol table '.dynsym' contains 143 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00000000 0 FUNC GLOBAL DEFAULT UND __snprintf_chk@GLIBC_2.3.4 (2)
2: 00000000 0 FUNC GLOBAL DEFAULT UND strcmp@GLIBC_2.0 (3)
3: 00000000 0 FUNC GLOBAL DEFAULT UND __vfprintf_chk@GLIBC_2.3.4 (2)
4: 00000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterTMCloneTab
5: 00000000 0 FUNC GLOBAL DEFAULT UND secure_getenv@GLIBC_2.17 (4)
6: 00000000 0 OBJECT GLOBAL DEFAULT UND stderr@GLIBC_2.0 (3)
@AlexDaniel
AlexDaniel / gist:d8c7333f181b41cc64a6
Created June 28, 2015 06:51
perl6 problem full output
$ time ./asc-to-svg pins.ASC B
.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
#!/usr/bin/env perl6
8
< 1 >
0 < 1 > 1
< 1 < 2 > 3 >
6 < 4 < 1 > 1 > 1
< 1 < 1 < 1 > 6 > 1 >
1 > 1
< 1 >
1 < 1
@AlexDaniel
AlexDaniel / qqx
Created October 3, 2015 11:08
Perl6 qqx usage
Audio-Encode-LameMP3/t/030-encode.t- ok($buf.elems > 0, "and there are some elements");
Audio-Encode-LameMP3/t/030-encode.t- $out-fh.write($buf);
Audio-Encode-LameMP3/t/030-encode.t- $out-fh.close;
Audio-Encode-LameMP3/t/030-encode.t-
Audio-Encode-LameMP3/t/030-encode.t- if ( "/usr/bin/file".IO.x ) {
Audio-Encode-LameMP3/t/030-encode.t: like qqx/file $out-file }/, rx/MPEG/, "and it's a MP3 file";
--
Audio-Encode-LameMP3/t/030-encode.t- ok($buf.elems > 0, "and there are some elements");
Audio-Encode-LameMP3/t/030-encode.t- $out-fh.write($buf);
Audio-Encode-LameMP3/t/030-encode.t- $out-fh.close;
à̴̵̶̷̸̡̢̧̨̛̖̗̘̙̜̝̞̟̠̣̤̥̦̩̪̫̬̭̮̯̰̱̲̳̹̺̻̼͇͈͉͍͎́̂̃̄̅̆̇̈̉̊̋̌̍̎̏̐̑̒̓̔̽̾̿̀͂͆͊͋͌̕̚ͅ͏͓͔͕͖͙͚͐͑͒͗͛ͣͤͥͦͧͨͩͪͫͬͭͮͯ҃҄҅҆҇͘͜͟͢͝͞͠͡҈҉߲߫߬߭߮߯߰߱߳ఀ᩿᪵᪶᪷᪸᪹᪺᪽፝፞፟᪰᪱᪲᪳᪴᪻᪼᪾⃒⃓⃘⃙⃚᷐᷎᭬᷂᷊᷏᷽᷿᭫᭭᭮᭯᭰᭱᭲᭳᷀᷁᷃᷄᷅᷆᷇᷈᷉᷋᷌᷑᷒ᷓᷔᷕᷖᷗᷘᷙᷚᷛᷜᷝᷞᷟᷠᷡᷢᷣᷤᷥᷦᷧᷨᷩᷪᷫᷬᷭᷮᷯᷰᷱᷲᷳᷴ᷵᷾⃐⃑⃔⃕⃖⃗⃛⃜᷼᷍⃝⃞⃟⃠⃡⃢⃣⃤⃥⃦⃪⃫゙゚⃨⃬⃭⃮⃯⃧⃩⃰⳯⳰⳱ⷠⷡⷢⷣⷤⷥⷦⷧⷨⷩⷪⷫⷬⷭⷮⷯⷰⷱⷲⷳⷴⷵⷶⷷⷸⷹⷺⷻⷼⷽⷾⷿ꙯꙰꙱꙲︧︨︩︪︫︬︭𐇽ꙴꙵꙶꙷꙸꙹꙺꙻ꙼꙽ꚞꚟ꛰꛱꣠꣡꣢꣣꣤꣥꣦꣧꣨꣩꣪꣫꣬꣭꣮꣯꣰꣱︠︡︢︣︤︥︦︮︯𐍶𐍷𐍸𐍹𐍺𑌀𖫰𖫱𖫲𖫳𖫴𝅧𝅨𝅩𝅥𝅦𝅮𝅯𝅰𝅱𝅲𝅻𝅼𝅽𝅾𝅿𝆀𝆁𝆂𝆊𝆋𞣐𞣑𞣒𞣓𞣔𞣕𞣖𝅭𑍦𑍧𑍨𑍩𑍪𑍫𑍬𑍰𑍱𑍲𑍳𑍴𝆅𝆆𝆇𝆈𝆉𝆪𝆫𝆬𝆭𝉂𝉃𝉄
@AlexDaniel
AlexDaniel / false-christmas-tree.p6
Last active January 29, 2016 13:13
False Christmas Tree
#!/usr/bin/env perl6
say
𑁣
< 𐌡 >
𐅵 < ⅴ > 𑁪
< 𐅵 < ໑ > ໐ >
𐅵 < ౸ < ⅴ > 𑁧 > 𑁪
< 𐅵 < 𐅵 < ⅴ > ᧚ > 𑁧 >
𐧁 > 𐧁
< 𐧁 >
@AlexDaniel
AlexDaniel / splits.md
Last active February 17, 2016 16:52
Array splits

Is there a cute Perl 6 way to take an array (say ‘a’..‘d’) and get all head/tail partitions of it (e.g. (<a>, <b c d>), (<a b>, <c d>), (<a b c>, <d>))?

Sure! Pick one:

my @a = a..e; say (@a[^$_, $_..*] for 1..^@a);
my @b = a..e; say (1..^@b).map: {@b[^$_, $_..*]};
my @c = a..e; say (@c.rotor($_, ∞, :partial) for 1..^@c);
my @z = a..e; say @z[0..*-2].keys.map: {@z[0..$_, $_^..*]}; # same as b
my @d = a..e; say (1..^@d).map: {@d.rotor: $_, ∞, :partial};
my class a {
has @.b;
method get-flat { @!b.map(|*.get-flat); }
method p {
say 'A: ', WHAT $.get-flat;
# why doesn't this loop act like D: below?
for self.get-flat() -> $c {
say 'B: ', $c.perl
}
}
@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;