Skip to content

Instantly share code, notes, and snippets.

View moritz's full-sized avatar

Moritz Lenz moritz

View GitHub Profile
@moritz
moritz / interleaving.pod6
Created December 18, 2018 21:01
Perl 6 phase interleaving
Perl 6 first compiles code, and then runs it.
The C<BEGIN> phaser interleaves a run time phase into the
compilation phase, that is, the code inside the C<BEGIN>
phaser is first compiled, then run, and then the rest of the
compilation continues.
In the hypothetical code example
A;
@moritz
moritz / perl6-coding-contest.md
Last active November 6, 2018 11:57
Revival of the Perl 6 Coding Contest

In the good old times, I really enjoyed participating in Carl Mäsak's Perl 6 Coding Contest.

I'd like to revive this kind of contest, with a few small modifications.

Since running such a contest is a lot of work, I'd like to crowd-source parts of it. This is my idea of how it could work.

  • People can volunteer to be part of the group that crowd-sources the tasks. Of course, task creators cannot participate in the actual contest.
@moritz
moritz / stuff.txt
Last active November 28, 2019 17:00
Tau Stations: Weapons & Armor I own
Armor Ajax Systems Tactical Vest
Armor Alamin Kinetic Vest
Armor Anti-Ballistic Harness
Armor Anti-Energy Coat
Armor Anti-Energy Flak Jacket
Armor Anti-Energy Harness
Armor Anti-Energy Jump Suit
Armor Anti-Energy Kaftan
Armor Anti-Energy Kataginu
Armor Anti-Energy Plate Armor
@moritz
moritz / taustation-nav.user.js
Last active May 31, 2018 15:38
Tau station navigation extension
// ==UserScript==
// @name taustation_extended_nav
// @namespace https://github.com/moritz/
// @description Navigationi extension for taustation.space
// @match https://alpha.taustation.space/*
// @version 1
// @grant none
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
grammar Enhanced-Paragraph {
token TOP { <superword>[ (\s+) <superword>]+ }
token superword { <word> | <enhanced-word> }
token word { \w+ }
token enhanced-word { \* <word> \* }
}
class Enhanced-Paragraph-actions {
method TOP ($/) { make [~] $/.caps».value.map({ .made // .Str }) }
method superword($/) { make $<enhanced-word>?? $<enhanced-word>.made !! $<word>.made }
@moritz
moritz / pdf-autosplit.p6
Created September 20, 2017 19:21
A Tool that Splits PDF files by Chapter (as Bookmarks; uses pdftk)
#!/usr/bin/env perl6
use v6;
sub page-numbers-from-chapters($filename) {
my $proc = run :out, 'pdftk', $filename, 'dump_data_utf8';
my %bookmark;
my @borders;
sub handle-bookmark() {
if %bookmark && (%bookmark<BookmarkLevel> // 0) == 1 {
@moritz
moritz / example-criteria.md
Created March 5, 2017 14:57
Criteria for examples included in "Perl 6 by Example"

Criteria for Ideas

  • short enough to fit on a single page (usually; at most two)
  • doesn't require too much domain knowledge to appreciate
  • illustrates a Perl 6 feature or concept, preferably two
  • preferably something at least somewhat practical (no mammal hierarchy)
  • not too much setup work (no dependencies on a Zookeeper cluster or so)
@moritz
moritz / output.txt
Last active February 25, 2017 20:49
moritz@pete:~/src/perl6book$ perl6 examples/uni.p6 dog
⺨ - U+02ea8 - CJK RADICAL DOG (2)
⽝ - U+02f5d - KANGXI RADICAL DOG (2)
🌭 - U+1f32d - HOT DOG (2)
🐕 - U+1f415 - DOG (2)
🐶 - U+1f436 - DOG FACE (2)
our $count = 0;
class MagicVal {
has Int $.constant;
has Int $.varies = 0;
method varies is rw {
$count++;
return-rw Proxy.new(
# note that FETCH and STORE cannot go through the accessors
@moritz
moritz / slooow.p6
Created January 30, 2015 19:09
rakudo pod parsing slowness when '=end pod' is missing
use v6;
sub timeit(Int $lines-after) {
my $preamble = qq[=begin code\n];
my $str = join "\n", $preamble, "Some more happy, happy lines of B<pod>\n\n including code\n\n" xx $lines-after;
my $before = now;
try EVAL qq[=begin pod\n\n$str\n\n\=end pod\n"];
my $after = now;