Skip to content

Instantly share code, notes, and snippets.

@skids
skids / gist:fabd0304f40e24db33d0
Last active January 26, 2016 05:53
Questions on latest round of Supply changes
I'm currently going through S17 to bring it up to date.
The following stuck out as things that may not be intentional behaviors,
so I need to know whether to doc current behavior or file an RT on each:
1) Should two different taps of a a serial supply be run simultaneuosly?
$ perl6 -e 'my $p = Supplier.new; my $s = $p.Supply; $s.serial.say; $s.tap({ sleep 1; "42 {now}".say; }); $s.tap({ sleep 1; "43 {now}".say }); $p.emit(42); sleep 3;'
True
42 Instant:1449454902.847377
@skids
skids / screen_no_utf8_info_abort.txt
Created November 26, 2015 15:53
Screen Aborts on info command with defutf8 off
bri@atlas:~/git/perl6-Proc-Screen$ cat /tmp/screenrc
debug on
defutf8 off
bri@atlas:~/git/perl6-Proc-Screen$ screen -D -m -c /tmp/screenrc # then do "screen -Q info" from another window
Aborted
bri@atlas:~/git/perl6-Proc-Screen$ screen -ls
There are screens on:
7478..atlas-queryA (08/07/2015 09:41:20 PM) (Dead ???)
7478..atlas (08/07/2015 09:41:20 PM) (Dead ???)
Remove dead screens with 'screen -wipe'.
@skids
skids / termios-dev-tty.txt
Created November 25, 2015 03:13
snippet from some terminal code
# We have to use NativeCall here as there is otherwise no way to
# get an fd for Term::termios, as of yet. And, it is buried so
# deep in the IO object it'll require guts work to unearth.
use NativeCall;
my sub open (str $pathname, int $flags) returns int is native {*}
my sub read (int $fd, Buf $buf is rw, int $count) returns int is native {*}
my sub close (int $fd) returns int is native {*}
my sub get-input {
@skids
skids / Supply.Channel.txt
Created November 24, 2015 02:45
Input Supply.Channel problems
So, this would seem to be the way to make a Supply from an IO::Pipe useful for waiting for the
pipe to close and then doing something with the pipe output. But it does not work reliably.
Similar schemes working directly with the Supply also have issues, since any state accumulating
the output in tap callbacks may not be complete inside a :done callback. Note that sometimes
(maybe when certain parts of the guts schedule on the same thread) it pretty much works -- I killed
statistically improbable runs with ^C below. Also note failures on run 8 and run 32 are popular.
$ perl6 -e 'sub f { my $cmd = Proc::Async.new(:path<ls>); my $c = $cmd.stdout.Channel; $cmd.start; $'
after 6 times
I think there might be a sliver of performance gain on that test script
with the following, but it is hard to tell. Oddly, it generates smaller
QAST but larger MAST.
diff --git a/src/core/Array.pm b/src/core/Array.pm
index e4960b0..2e03127 100644
--- a/src/core/Array.pm
+++ b/src/core/Array.pm
@@ -319,7 +319,7 @@ my class Array { # declared in BOOTSTRAP
@skids
skids / peap_loop_bug.txt
Created October 7, 2015 13:55
Output for a freeradius github issue
Copyright (C) 1999-2015 The FreeRADIUS server project and contributors
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE
You may redistribute copies of FreeRADIUS under the terms of the
GNU General Public License
For more information about these matters, see the file named COPYRIGHT
Starting - reading configuration files ...
including dictionary file /usr/share/freeradius/dictionary
including dictionary file /usr/share/freeradius/dictionary.dhcp
including dictionary file /usr/share/freeradius/dictionary.vqp
--- a/lib/Language/functions.pod
+++ b/lib/Language/functions.pod
@@ -155,6 +155,58 @@ type:
+=head1 Conventions and Idioms
+
+While the dispatch system described above provides a lot of flexibility,
+there are some conventions that most internal functions, and those in
+many modules, will follow. These produce a consistent look and feel.
+
+=head2 Slurpy Conventions
@skids
skids / gist:7b099e80ce8d378f0cdd
Last active September 10, 2015 01:30
Estimated impact of Backtrace creation on Str.Numeric during soft-failure modes
# This shows the cost of generating backtraces when using Str.Numeric
# to test whether a string can be numified, which is a normal usage
# scenario.
#
# Test code: different from the pre-allomorph original in that it will only
# ever generate one Failure per .Numeric, and as long as a :$backtrace is
# provided and the result is not thrown, should not generate any new backtraces
# (I think.) But -- also different in that it always uses an exception unwind
# instead of letting Failure objects go through the normal return path.
my sub build-cursor-to-template {
my ($x,$y) = 13,13;
my $raw = qq:x{ tput cup $y $x };
my Str sub cursor-template( Int :$x, Int :$y ) {
# there may be single digit numbers in the escape preamble
$raw ~~ s:nth(*-1)[\d+] = $y+1;
$raw ~~ s:nth(*)[\d+] = $x+1;
return $raw;
}
@skids
skids / noflat_in_core.diff
Last active August 29, 2015 14:28
Stuff that will help when protos of Any-iterable sub forms get changed to **@
diff --git a/src/core/Capture.pm b/src/core/Capture.pm
index 80d013c..dacdb85 100644
--- a/src/core/Capture.pm
+++ b/src/core/Capture.pm
@@ -96,8 +96,8 @@ my class Capture { # declared in BOOTSTRAP
if self.^name eq 'Capture' {
"\\({
join ', ',
- (nqp::atpos($!list, $_).perl for ^nqp::elems($!list)),
- %hash.sort.map( *.perl )