Skip to content

Instantly share code, notes, and snippets.

View lucaswerkmeister's full-sized avatar

Lucas Werkmeister lucaswerkmeister

View GitHub Profile
@lucaswerkmeister
lucaswerkmeister / instructions.md
Last active December 24, 2016 16:46
Make your Arch Linux device emit ownership information on boot

Make your Arch Linux device emit ownership information on boot

Scenario: You’ve lost your device. Actually Honest Achmed finds it, and would like to return it to you. However, the label that you had carefully attached to your device was ripped off. How does Achmed know who to return the device to? He attempts to boot the device, but since you use full-disk encryption (you do use full-disk encryption, don’t you?), that doesn’t get him any further than the decryption password prompt. Fortunately, you have arranged for a simple message to be printed before that prompt,

@lucaswerkmeister
lucaswerkmeister / opendmarc.service
Last active December 15, 2016 12:19
systemd configuration files for OpenDMARC
# /etc/systemd/system/opendmarc.service
[Unit]
Description=OpenDMARC email validation system
Documentation=man:opendmarc(8) man:opendmarc.conf(5) man:opendmarc-import(8) man:opendmarc-reports(8) http://www.trusteddomain.org/opendmarc/
After=network.target nss-lookup.target
[Service]
RuntimeDirectory=opendmarc
Type=forking
PIDFile=/run/opendmarc/opendmarc.pid
@lucaswerkmeister
lucaswerkmeister / pipeline.sh
Created December 11, 2016 14:29
Days on which Postfix sent most outgoing emails
journalctl -u postfix -o json | jq -r 'select(.MESSAGE | contains("to=")) | .["_SOURCE_REALTIME_TIMESTAMP"]' | awk '{sec=int($1/(1000*1000)); print sec, int(sec/(60*60*24))}' | uniq -f 1 -c | sort -rn | head | while read count stamp day; do printf '%s\t%s\n' "$count" "$(date -Idate -d @$stamp)"; done
@lucaswerkmeister
lucaswerkmeister / var.tex
Last active November 27, 2016 18:40
Make ? indicate a single-letter variable in math mode
\documentclass{article}
\usepackage[utf8]{inputenc}
\DeclareUnicodeCharacter{3BB}{\lambda} % λ
\newcommand{\var}[1]{\mathtt{#1}}
\let\qm=?
\catcode`?=13
\def?{%
@lucaswerkmeister
lucaswerkmeister / cul.sty
Created November 27, 2016 17:42
Colored underline, with Beamer overlay support
% colored underline, with Beamer overlay support
% usage: \cul{x} or \cul[blue]{x} or \cul<2->{x} or \cul<2->[blue]{x}
\newcommand<>{\cul}[2][red]{%
import ceylon.language.meta.model {
ClassOrInterface
}
shared interface Enumeration<Element> of Element
given Element satisfies Enumeration<Element> {
shared static Element? byName(String name) {
assert (is ClassOrInterface<Element> coi = `Element`);
return coi.caseValues.find((element) => name == element.name);
}
@lucaswerkmeister
lucaswerkmeister / make-orphan.sh
Created October 28, 2016 11:37
Rough sketch on how to turn a Git branch into an orphan branch
branch=... # the branch you want to turn into an orphan branch
base=master # the branch which $branch is based on and shouldn’t be anymore
firstCommit=... # the first commit on $branch that’s not on $base
# rename $branch to $branch-bak
git checkout $branch
git checkout -b $branch-bak
git branch -d $branch
# new orphan $branch
DataDirectory /var/lib/tor
#PidFile /var/run/tor/tor.pid
#RunAsDaemon 1
#User debian-tor
ControlSocket /var/run/tor/control
ControlSocketsGroupWritable 1
CookieAuthentication 1
CookieAuthFileGroupReadable 1
@lucaswerkmeister
lucaswerkmeister / ctsl.md
Last active August 23, 2016 18:39
Google Summer of Code 2016 final evaluation

Ceylon TypeScript loader

[Original proposal][proposal]

The original goal was to finish the first iteration of the program, and to get as far as possible with the second iteration, including necessary changes to the compiler.

As explained in the proposal, both iterations produce a Ceylon module (i. e., modname/modver/modname-modver{,-model}.js{,.sha1} files) in a Ceylon module repository (e. g. modules/). This module can then be used like any other Ceylon module – moved between repositories, imported from a module descriptor, etc.

@lucaswerkmeister
lucaswerkmeister / run.ceylon
Created August 19, 2016 20:45
HotSpot boxing, Ceylon, anomaly
import java.lang { System { o=\iout, nanoTime }, Double, Long }
Integer additions = 10_000_000_000;
String format = "%04d. iteration, %8s: %04.1f seconds (%12d ns): %d\n";
Float seconds(Integer t1, Integer t2) => (t2 - t1) / 1.0e9;
Integer nanos(Integer t1, Integer t2) => t2 - t1;
class C() {
@unboxed variable Integer i1 = 0;
@boxed variable Integer i2 = 0;