Skip to content

Instantly share code, notes, and snippets.

View moritz's full-sized avatar

Moritz Lenz moritz

View GitHub Profile
@moritz
moritz / hellworm-drops.md
Last active April 13, 2024 21:30
Fallen London: Hellworm Drops

Statistics

Statistic Value
Total Drops 1022
Number of Distinct Items 32
Average Item Drop Count 31.94
Standard Deviation 7.80
Average Drop value¹ 92.68
Total Monetary value¹ 94716.18
@moritz
moritz / pdf-autosplit
Created April 15, 2022 12:35
pdf-autosplit, for splitting a PDF based on annotations (chapters).
#!/usr/bin/env raku
# Written in Raku, former Perl6: https://raku.org/
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 {
@borders.push(%bookmark<BookmarkPageNumber>);
@moritz
moritz / recalcitrant
Created April 4, 2022 19:19
Python: dynamically load a script (without .py) extension and mock things in it
#!/usr/bin/env python3
# scrript being tested. Goal: patch out getpid
from os import getpid
def double_pid():
return 2 * getpid()
if __name__ == '__main__':
print(double_pid())
@moritz
moritz / mol.txt
Last active September 25, 2021 21:04
Fallen London: Khanate Memory of Light Grind
Number of samples: 346
Total : 1739
Average : 5.03 ± 0.27
Error : 5.38%
1 ( 4 ): xxxx
2 ( 19 ): xxxxxxxxxxxxxxxxxxx
3 ( 38 ): xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
4 ( 65 ): xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
5 ( 93 ): xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
6 ( 59 ): xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
@moritz
moritz / lib-noris-StableRandom.pm
Created July 21, 2021 11:46
Generate "random" but stable names for pseudonymification
package noris::StableRandom;
use 5.024;
use strict;
use warnings;
use utf8;
# note: we use a separate random number generator
# because we need stable "random"ness based on the database IDs,
# and don't want to confuse any of the libraries we use
@moritz
moritz / expression.raku
Created December 19, 2020 14:13
Advent of Code day 18 solultion in Raku #rakulang
grammar Expression {
token integer { \d+ }
proto token operator { <*> }
token operator:sym<+> { <sym> }
token operator:sym<*> { <sym> }
rule term { <integer> | <parens> }
rule parens { '(' ~ ')' <expression> }
rule expression { <term> + % <operator> }
token TOP { <.ws> <expression> }
}
@moritz
moritz / fooo
Created July 30, 2020 13:06
Raku Match.gist output
$ ./rakudo-m -e ' for ("a1a2a3a4a5" ~~ m:g/(a \d)/) { say "match {$++}: ", $_}'
match 0: 「a1」
0 => 「a1」
match 0: 「a2」
0 => 「a2」
match 0: 「a3」
0 => 「a3」
match 0: 「a4」
0 => 「a4」
match 0: 「a5」
@moritz
moritz / inverse-regex.p6
Last active August 31, 2020 02:20
Generate shortest strings that match a regex
use v6;
role Generator {
method shortest() { ... }
}
class Literal does Generator {
has Str $.atom is required;
method shortest() { return $.atom.list }
}
@moritz
moritz / ergebnis.txt
Created March 20, 2020 17:12
Wörterhäufigkeit WirVsCorona Hackathon
6264 und
5642 die
3657 wie
3427 der
3416 können
3051 in
2498 zu
2482 werden
2353 wir
2349 von
@moritz
moritz / error.log
Created August 25, 2019 20:06
Moar build failure
compiling src/jit/compile.o
compiling src/jit/dump.o
Precompiling templates from src/jit/core_templates.expr
"pairkeys" is not exported by the List::Util module
"pairvalues" is not exported by the List::Util module
"pairgrep" is not exported by the List::Util module
Can't continue after import errors at tools/expr-template-compiler.pl line 9.
BEGIN failed--compilation aborted at tools/expr-template-compiler.pl line 9.
Makefile:675: recipe for target 'src/jit/core_templates.h' failed
make: *** [src/jit/core_templates.h] Error 255