Skip to content

Instantly share code, notes, and snippets.

View chronos-tachyon's full-sized avatar

Donald King chronos-tachyon

View GitHub Profile
https://youtu.be/-RdOwhmqP5s?t=832
Chaos at the boundaries between regions, where each region represents contiguous points that end up having the same root as the root they are closest to after N iterations.
P vs NP, where many NP-complete problems are easy in the region where the answer is obviously yes or obviously no, but hard in the region where the answer approaches the boundary.
https://youtu.be/WFbgfknnWqA?t=308
S[x_i(t), x_i'(t)] = Integ[min=t0,max=t1] L(x_i(t), x_i'(t)) dt
@chronos-tachyon
chronos-tachyon / try-vmware-modconfig.py
Last active July 1, 2022 22:06
Python script for automatically running vmware-modconfig and signing the result for UEFI SecureBoot.
#!/usr/bin/env python3
import argparse
import os
import subprocess
import sys
from pathlib import Path
MOK_DIR = Path('/var/lib/shim-signed/mok')
MOK_DER = MOK_DIR / 'MOK.der'
@chronos-tachyon
chronos-tachyon / fix-pub.py
Created March 26, 2022 18:22
Script to fix Unix ownership and permissions on a multi-user writable public directory.
#!/usr/bin/env python3
#
# Written by Donald King <chronos@chronos-tachyon.net>
# Public Domain.
#
# ==== CC0 https://creativecommons.org/publicdomain/zero/1.0/ ====
# [To the extent possible under law, I have waived all copyright ]
# [and related or neighboring rights to this script. This work is]
# [published from the United States of America. ]
@chronos-tachyon
chronos-tachyon / foobar2000-file-op-rename-string.txt
Created March 24, 2022 19:49
My personal Foobar2000 file naming convention for my music library
$puts(y,$if2($meta(ALBUM DATE),$year(%date%)))$puts(at,$trim($replace($replace($replace($swapprefix(%album%),' (Original Motion Picture Soundtrack)',),' (Original Motion Picture Score)',' (Score)'),' (Original Video Game Soundtrack)',)))$puts(ats,$replace($replace($trim($replace($replace($replace($stripprefix(%album%),' (Original Motion Picture Soundtrack)',),' (Original Motion Picture Score)',' (Score)'),' (Original Video Game Soundtrack)',)),' (Score)',),' [CENSORED]',))$puts(aa,$stripprefix(%album artist%))$puts(tt,$trim(%title%))$puts(taraw,$trim($stripprefix(%artist%)))$puts(ta,$if($strcmp($get(taraw),$get(aa)),,$get(taraw)))$puts(root,$if2($meta(CATEGORY),$get(aa)))$get(root)/[$get(y) - ]$if2($get(at),Unknown Album)$if($get(aa),$if($or($strcmp($get(aa),$get(root)),$strcmp($get(aa),$get(ats)),$strcmp($get(aa),Various Artists)),, '['$get(aa)']'))/$if(%tracknumber%,$if($and(%discnumber%,$not($strcmp(%totaldiscs%,1))),$num(%discnumber%,1)'.',)$num(%tracknumber%,2)-,)$if2('['$get(ta)']' ,)$get(tt)
@chronos-tachyon
chronos-tachyon / split-pem.py
Created March 23, 2022 04:03
A tool for splitting a key+cert+chain X.509 PEM file into separate key, cert, and chain PEM files.
#!/usr/bin/env python3
#
# Written by Donald King <chronos@chronos-tachyon.net>
# Public Domain.
#
# ==== CC0 https://creativecommons.org/publicdomain/zero/1.0/ ====
# [To the extent possible under law, I have waived all copyright ]
# [and related or neighboring rights to this script. This work is]
# [published from the United States of America. ]
@chronos-tachyon
chronos-tachyon / wireguard-config-sync.py
Last active July 8, 2022 01:16
Script to synchronize Wireguard configs across a fleet from a central command-and-control host.
#!/usr/bin/env python3
#
# Written by Donald King <chronos@chronos-tachyon.net>
# Public Domain.
#
# ==== CC0 https://creativecommons.org/publicdomain/zero/1.0/ ====
# [To the extent possible under law, I have waived all copyright ]
# [and related or neighboring rights to this script. This work is]
# [published from the United States of America. ]
@chronos-tachyon
chronos-tachyon / ssh-key-sync.py
Created March 23, 2022 00:49
Script to synchronize SSH keys across a fleet from a central command-and-control host; meant for use with a Wireguard VPN but others may find it useful to crib from.
#!/usr/bin/env python3
#
# Written by Donald King <chronos@chronos-tachyon.net>
# Public Domain.
#
# ==== CC0 https://creativecommons.org/publicdomain/zero/1.0/ ====
# [To the extent possible under law, I have waived all copyright ]
# [and related or neighboring rights to this script. This work is]
# [published from the United States of America. ]
@chronos-tachyon
chronos-tachyon / peggysue.peg
Created September 25, 2021 01:28
A self-describing PEG grammar (WIP)
package peggysue;
option go:import_path = "github.com/chronos-tachyon/peggysue/grammar";
private rule WS ::= [\t\n\v\f\r\x85\p{Z}]+ ;
private rule OWS ::= <WS>? ;
private rule OctDigit ::= [0-7] ;
private rule DecDigit ::= [0-9] ;
private rule HexDigit ::= [0-9A-Fa-f] ;
// SpiderScript compiler.
#version(1)
module spdr::compiler
import argparse
import io
import os
import runtime
import spdr::ast
@chronos-tachyon
chronos-tachyon / rot13-bookmark.js
Created April 28, 2019 09:57
Bookmarklet for applying ROT13
javascript:var coding = "abcdefghijklmnopqrstuvwxyzabcdefghijklmABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM"; function rot13(t) { for (var r = "",i=0;i<t.length;i++) { character = t.charAt(i); position = coding.indexOf(character); if (position > -1) character = coding.charAt(position + 13); r += character; } return r; } S=window.getSelection(); function t(N) { return N.nodeType == N.TEXT_NODE; } function r(N) { if (t(N)) N.data = rot13(N.data); } for (j=0;j<S.rangeCount;++j) { var g=S.getRangeAt(j), e=g.startContainer, f=g.endContainer, E=g.startOffset, F=g.endOffset, m=(e==f); if(!m||!t(e)) { /* rot13 each text node between e and f, not including e and f. */ q=document.createTreeWalker(g.commonAncestorContainer, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT, null, false); q.currentNode=e; for(N=q.nextNode(); N && N != f; N = q.nextNode()) r(N); } if (t(f)) f.splitText(F); if (!m) r(f); if (t(e)) { r(k=e.splitText(E)); if(m)f=k; e=k;} if (t(f)) g.setEnd(f,f.data.length); } void 0