Skip to content

Instantly share code, notes, and snippets.

@skids
skids / perl6DRYusingVAR.pm6
Last active January 16, 2019 20:26
Neat Perl6 DRY idiom for unpacking named data into locally scoped variables of same name.
# Neat Perl6 DRY idiom
#
# suppose you want to work with named values in a string
# or data structure, and you want to keep the variable
# names the same as the field/key names.
# sample data using a hash just to kep things simple
my %data = :fee(42), :fie<FIE>, :foo<FOO>, :fum(True);
# DRY idiom:
@skids
skids / topic_behavior
Last active March 1, 2018 02:11
Investigating topic behavior on bare blocks, conditionals, and conditional loops
Update: the patch to eliminate most topic ensconses on inlined
immediate blocks turned out to be pretty simple. It is at
https://github.com/skids/rakudo/tree/inline_topic. With those
gome there is little reason to do optimizations specifically
on while loops.
...with the caveat that there may be some way for a topic bind
to appear in inlined immediate block which I am not aware of.
But... it does at least pass all spectests, including the ones
@skids
skids / topic_optimize
Created February 24, 2018 02:22
Playing with rakudo optimization
So there I was asking myself why we have so much nqp code cropping up in
the rakudo core... what prevents rakudo from producing as efficient opcodes
from Perl6 source for even basic things like ifs and whiles? Just how
much performance are we gaining, anyway? Let's take the case of while
versus nqp::while:. Typical results for two comparable busy loops on
my machine are:
```
@skids
skids / gist:04cd1b47792a862755a7b0fddb89f34c
Last active August 19, 2019 13:55
Groundwork for optional PEAP certificates FreeRADIUS support
This document is to feel around the edges of adding support for
ad-hoc certificate handling and extended invalid
certificate handling when using EAP-PEAP-* methods
Current state of affairs:
AFAIK only one client supplicant that can claim any level of market share,
wpa_supplicant, currently supports configuring EAP-PEAP 802.1x
authentication to both use an inner method such as MSCHAPc2 and also
at the same time provide a client certificate. Note that this does not
@skids
skids / nqpslang.nqp
Created September 26, 2017 23:33
NQP slang skeleton for Pel6 devs
# This file is for developers wishing to quickly test
# modifications to Perl6's internal grammars/actions.
#
# Just copy the rules/actions you want to play with from
# src/Perl6/Grammar.nqp and src/Perl6/Actions.nqp
# into the appropriate class below.
#
# Every time you modify, execute (assuming you have it in /tmp/):
# "nqp --target=mbc --output=/tmp/nqpslang.moarvm --encoding=utf8 /tmp/nqpslang.nqp"
#
@skids
skids / nqpmodsixmod.txt
Last active September 26, 2017 15:02
Using an nqp mod from a used Perl6 mod
$ cd /tmp/
$ cat > nqpmod.nqp
use nqp;
sub nqpsub(*@foo) is export { nqp::say("OHAI nqpsub") };
$ nqp --target=mbc --output=/tmp/nqpmod.moarvm --encoding=utf8 /tmp/nqpmod.nqp
$ NQP_LIB=/tmp/ nqp -e 'use nqpmod; nqpsub();'
OHAI nqpsub
@skids
skids / rolevolution.txt
Last active May 23, 2018 18:45
rakudo rolevolution branch
TLDR:
https://github.com/skids/rakudo/tree/rolevolution3
... is a spectest-passing branch of rakudo with:
A) Working diamond role composition
B) A solution to Ovid's complaint about role method overrides
...but the code needs a bit of work.
connections {
swan {
pools = students
remote {
id = %any
auth = eap-radius
}
include swanctl_swan.conf
@skids
skids / ts_unaccept
Last active April 25, 2022 19:19
TS_UNACCEPT on modern CENTOS
SOLVED: there was an old type=transport statement leftover on the initiator, Thermi++
Strongswan rw to strongswan responder
I *think* this problem is on the responder side. I've tried all sorts of
little alterations and tweaks and still get a TS_UNACCEPT which appear in
the logs to be due to no selectors for the remote being present in the
configuration at the point when selectors are narrowed.
sub d (
$obj,
Int :$i = 2,
Int :$j = 0,
Bool :$c = True,
Int :$x = 50,
Bool :$g = False,
Bool :$m = True )
{ say "$i/$j/$c/$x/$g/$m"; } d(42,:!m);