Skip to content

Instantly share code, notes, and snippets.

@antlauzon
antlauzon / trivial_python_quine.py
Created January 21, 2019 07:04
trivial python quine
import os; print(open(os.path.basename(__file__)).read())
@antlauzon
antlauzon / cmd_compress.py
Last active January 11, 2023 04:00
create shortened command aliases based on use frequency
import os
import re
import shutil
import sys
cmd_re = re.compile('(\w+)\s+.*')
if 'zsh' in sys.argv[1]:
cmd_re = re.compile(".*;(\w+)\s+.*")
history= open(sys.argv[1], 'rb').read()
@antlauzon
antlauzon / routeclear.py
Last active December 10, 2019 21:03
Heavy Handed MacOS Route Nuking
#!/usr/bin/env python2.7
import re
import shlex
import subprocess
LIST_ROUTES="/usr/sbin/netstat -nr"
IFCONFIG="/sbin/ifconfig"
DELETE_LINK="/sbin/route -n delete {destination} -link {linkno}"
DELETE_NET="/sbin/route -n delete -ifscope {netif} -net {destination}"
@antlauzon
antlauzon / updalsmtime.py
Created March 19, 2019 02:26
Update your Ableton ALS file modified dates
#!/usr/bin/env python3
import glob
import gzip
import logging
import multiprocessing
import os
import re
import sys
MODDATE_RE=re.compile("\s*<LastModDate Value=\"(\d+)\".")
@antlauzon
antlauzon / bitly_roulette.sh
Created March 24, 2019 20:49
Bit.ly Roulette
#!/bin/bash
while true; do
code=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-7} | head -n 1)
aria2c "https://bit.ly/$code"
done
@antlauzon
antlauzon / IRL Qs
Last active September 3, 2019 13:00
autocorrecting hypernet coding
antidiscrete nets
@antlauzon
antlauzon / islocked
Last active May 12, 2021 21:53
islocked
#!/usr/bin/env python3
import sys
import os
import sys
import Quartz
d = Quartz.CGSessionCopyCurrentDictionary()
LOCKED_FILE = '$HOME/tmp/.locked'
@antlauzon
antlauzon / monty_hall.py
Created October 25, 2019 12:47
monty hall
import random
ITERS = 10000
a = ['g', 'g', 'c']
stay_results = []
for i in range(ITERS):
random.shuffle(a)
init_choice = int(random.random()*len(a))
goat = [i for i in range(3) if i != init_choice and a[i] != 'c'][0]
@antlauzon
antlauzon / cwatch.py
Created November 3, 2019 05:01
hash and save files that change on your filesystem in realtime
#!/usr/bin/env python3
import argparse
import datetime
import re
import os
import hashlib
import logging
import sys
import subprocess
@antlauzon
antlauzon / optn_translate.py
Created November 8, 2019 04:40
optn star data for organ donation translation for athena/hive
import csv
import os
import re
import sys
from bs4 import BeautifulSoup
from pathlib import Path
DATA_DIR = sys.argv[1]
TYPE_MAP = {