Skip to content

Instantly share code, notes, and snippets.

View patrickbkr's full-sized avatar

Patrick Böker patrickbkr

View GitHub Profile
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((8(large-header(
(lk(__)lk) (lb(___)lb)
(lr(_______)lr)(la(_____)la) (lk(| | __)lk)(lu(__ _)lu)(lb(\ |_________ ______ _ __)lb)
(lr(\_ __ \)lr)(la(__ \)la) (lk(| |/ /)lk)(lu( | \)lu)(lb( __ \_ __ \_/ __ \ \/ \/ /)lb)
(lr( | | \/)lr)(la(/ __ \)la)(lk(| <)lk)(lu(| | /)lu)(lb( \_\ \ | \/\ ___/\ / )lb)
(lr( |__|)lr) (la((______/)la)(lk(__|__\)lk)(lu(____/)lu)(lb(|_____/__| \_____>\/\_/ )lb)
(ver()ver)
)large-header)(medium-header(
(lk(__)lk)
(lr(_______)lr)(la(_____)la) (lk(| | __)lk)(lu(__ __)lu)
Nice ways to construct Lists, Arrays, Maps and Hashes.
Is this as nice as it gets?
Without assignment (mostly passed or returned to/from functions):
| mutable | immutable
------------|------------------------|--------------------------------
Positional | ['a', 1, 'b', 2] | ('a', 1, 'b', 2)
Associative | %(a=>1, b=>2) | Map.new((a=>1, b=>2))
#!/usr/bin/env perl6
unit sub MAIN($file-dir, Bool :$exec) {
#for $file-dir.IO.lines -> $file {
for $file-dir.IO.dir -> $file {
if $file.basename ~~ /
^
( rakudo | nqp | rakudo\-star )
\- (\d\d\d\d) <[ \. \- ]> (\d\d) [ <[ \. \- ]> (\d+) ]?
( <-[ \. ]>+ )?
$ PERL6LIB=./lib ./perl6-m -e "require Inline::Perl5"
WARNINGS for -e:
Useless use of constant integer 1 in sink context (line 1)
===SORRY!=== Error while compiling /home/patrick/p6-repos/rakudo/site#sources/3ECC0B3D017463A31ED44AC02473634C96813BB1 (Inline::Perl5::ClassHOW)
Cannot find method 'original' on object of type NQPAttribute
at /home/patrick/p6-repos/rakudo/site#sources/3ECC0B3D017463A31ED44AC02473634C96813BB1 (Inline::Perl5::ClassHOW):13
in block <unit> at -e line 1
use Cro::HTTP::Client;
react {
# for 1 .. 100 -> $e {
for 1 .. * -> $e {
say "started $e";
whenever Cro::HTTP::Client.get('http://rcalc-devel/') {
say "Stuff works: $e";
}
}
#!/usr/bin/env perl6
class Paramsub is Parameter {
has Str $.literal-value is required;
}
my $param = Paramsub.new(literal-value => "asdf");
say "Literal value is: {$param.literal-value}";
@patrickbkr
patrickbkr / run.sh
Last active April 8, 2019 10:35
Cro::OpenAPI::RoutesFromDefinition calling the wrong handler
#!/usr/bin/env sh
SMP_APP_HOST=localhost SMP_APP_PORT=20000 perl6 service.p6
@patrickbkr
patrickbkr / bat_exec.md
Last active April 27, 2019 18:12
How to programatically call a .bat file on Windows

How to programatically call a .bat file on Windows

Using Perl 6 on Windows I want to programatically call a .bat file. Both the path to the .bat file and one of its arguments have a space in it. I can not call the .bat file directly for reasons given at the end of the question. The call I want to make is:

"C:\data\p6 repos\rakudo\perl6-m.bat" --target=mbc "--output=C:/data/p6 repos/rakudo/lib/.precomp/EA6F1A9F9A17B17B899C4C7C4A775A883DAF537E/33/33A52796DB3EBB40BEF94B7696A1B0AB7A29B5C5.bc" "C:/data/p6 repos/rakudo/lib/CompUnit/Repository/Staging.pm6"

I need to capture its STDIN and STDOUT and retrieve the exit code.

How do I do this?

@patrickbkr
patrickbkr / second_try.md
Last active January 16, 2019 20:05
Python and Perl6 relocatability
What Python does
================
See `Python-3.7.0/Modules/getpath.c`. Python always determines its library locations at runtime (prefix and exec_prefix).
It first determines the executable location (robustly, including $PATH and symlink handling), then performs several methods to determine `prefix` and `exec_prefix`, two paths that point to library and shared object folders in the
installation.
1. Check if it's run from the build directory (by looking for a marker file). Use a separate path layout matching the build directory in that case.
@patrickbkr
patrickbkr / converter.pl6
Last active August 29, 2015 14:16
Propagating Cursor state
#!/usr/bin/env perl6
grammar Tracker {
regex TOP {
{ make {:!inQuote} }
Beginning
<quoteStart>
.*
<laterRule>
End