Skip to content

Instantly share code, notes, and snippets.

@BenWiederhake
BenWiederhake / circ.lisp
Last active December 17, 2015 04:09
An extremely simple, dumb, slow, but wonderfully easy-to-use circuit simulator and verifier in roughly 450 "actual" lines of code.
; Install lisp:
;; aptitude install sbcl emacs slime
; Open emacs, and load program:
;; M-x slime
; Now play around:
;; (load "path/to/circ.lisp")
;; (example-1)
;; (example-2)
/ige_demo
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
@BenWiederhake
BenWiederhake / 95voices.py
Created February 6, 2016 16:44
Sentence splicer simulating a crowded head with lots of voices
#!/usr/bin/env python2
# 95voices.py, sentence splicer simulating a crowded head with lots of voices
# This work is in the Public Domain, as per:
# http://creativecommons.org/licenses/publicdomain/
import random
from sys import argv
usage = '''Usage:
./95voices.py "This is a coherent sentence." \\
@BenWiederhake
BenWiederhake / md4.py
Created July 22, 2018 17:45 — forked from bonsaiviking/md4.py
Simple MD4 digest implementation in pure Python
#!/usr/bin/env python3
# Based on https://gist.github.com/bonsaiviking/5644414
# Converted to Python3 by hand.
import codecs
import struct
def leftrotate(i, n):
return ((i << n) & 0xffffffff) | (i >> (32 - n))
@BenWiederhake
BenWiederhake / sha1.py
Created July 22, 2018 17:47 — forked from bonsaiviking/sha1.py
SHA1 implementation in pure Python
#!/usr/bin/env python3
# Based on https://gist.github.com/bonsaiviking/5639034
# Converted to Python3 by hand.
import struct
def leftrotate(i, n):
return ((i << n) & 0xffffffff) | (i >> (32 - n))
@BenWiederhake
BenWiederhake / feel_random.py
Created May 22, 2019 11:11
Generate "diverse" randomness that feels more natural than memory-less uniform distribution
#!/usr/bin/env python3
# Want:
# * Initially, uniform random distribution
# * If new elements appear, they are likely to be picked
# * If an element is picked, it is unlikely to be picked again soon
# * Long-ago-elements are roughly of the same probability (prevent permutation-lock)
# So:
# - Among new elements, pick uniform.
#!/usr/bin/python3
# Example usage:
# $ ./video_cut.py lectXX-raw.mp4 lectXX-cut.mp4 00:07:59 00:56:48 01:06:26 01:56:59
# $ ffmpeg -i lectXX-cut.mp4 -c:v libx264 -preset slow -crf 23 lectXX.mkv # Re-encode (to save some space; make "23" higher for higher compression and lower quality)
# $ chmod -w lectXX.mkv
# $ rsync -Pv lectXX.mkv ${USER}@contact.mpi-inf.mpg.de:/www/inf-resources-0/download.mpi-inf.mpg.de/d1/tkids/
# And maybe remove write permissions, to prevent future mistakes.
import re
@BenWiederhake
BenWiederhake / █████.txt
Created March 9, 2021 13:10
Project "████████" (20██-██-██)
Example "FULL BLOCK": ██████.de = xn--4zhaaaaa.de
Example "SEVEN EIGHTS BLOCK": ▇▇▇▇▇▇.de = xn--3zhaaaaa.de
https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains
Registrars tat don't work:
- DENIC (and thus *.de): Allows only hand-selected Unicode characters.
- Verisign (*.net, *.com): Doesn't let me paste it, even though Wikipedia claims it's supported
- .org: Says "Invalid entry", refuses to elaborate, even though Wikipedia claims it's supported
- OVH: kann's nicht.
@BenWiederhake
BenWiederhake / lint-classes.py
Created September 12, 2021 16:53
Script that tries to identify and remove unused and unjustified headers in Serenity
#!/usr/bin/env python3
# Put this file in Meta/
from collections import defaultdict, Counter
import os
import random
import re
import subprocess
import sys