Skip to content

Instantly share code, notes, and snippets.

@boppreh
boppreh / garbo_lol.sh
Created August 1, 2026 12:22
Change name of items in Kingdom Of Loathing's Garbo script to use IoTMs from Legacy of Loathing path
echo "Camp Scout backpack
Deck of Every Card
designer sweatpants
Elvish sunglasses
Fourth of May Cosplay Saber
Greatest American Pants
haiku katana
genie bottle
January's Garbage Tote
jewel-eyed wizard hat
@boppreh
boppreh / update
Last active March 4, 2025 14:39
Git update hook that builds and auto-deploys on push, with automatic rollback on failure
#!/usr/bin/env bash
# Script to deploy new releases on git push, automatically rolling back and rejecting pushes that fail to start.
# The repo must have a Makefile with `build`, `start` and `stop` targets.
# Each deployment starts from scratch, and ALL FILES UNDER THE REPO WORKTREE ARE DELETED.
# Use the parent dir if persistence is important.
# This script is meant to be executed as an `update` hook, which runs on every pushed ref, before it's accepted.
# Documentation: https://git-scm.com/docs/githooks
# - Exiting with an error rejects the push.
from collections import deque
def find_moves(target):
stack = deque([(0, 0, "")])
while True:
# current: how many X's we currently have.
# clipboard: how many X's were copied.
# history: sequence of "T", "C" and "P"
current, clipboard, history = stack.popleft()
if current >= target:
@boppreh
boppreh / Programming Language Checklist 2024.txt
Last active June 22, 2026 06:04
Updated version of the tongue-in-cheek Programming Language Checklist
Programming Language Checklist
by Colin McMillen, Jason Reed, and Elly Fong-Jones, 2011-10-10
updated by BoppreH, 2024-01-24
You appear to be advocating a new:
[ ] functional [ ] imperative [ ] object-oriented [ ] stack-based [ ] concurrent
[ ] interpreted [ ] compiled [ ] JIT [ ] cloud [ ] AI [ ] beginner-friendly
[ ] academic-friendly [ ] visual [ ] sharable [ ] esoteric
[ ] memory safe [ ] memory unsafe [ ] provable [ ] Turing-incomplete
[ ] statically-typed [ ] dynamically-typed [ ] completely incomprehensible
@boppreh
boppreh / stack_fanatic.py
Last active July 5, 2023 14:37
Visit every StackExchange site
"""
Login and visit each stackexchange site. Schedule it daily to win the Fanatic Badge after 100 days.
"""
# Create account.py module with 'email', 'password', and 'stackexchange_user_id'.
import account
import requests
import re
session = requests.Session()
@boppreh
boppreh / time_rotation.py
Last active May 5, 2023 17:52
Creates two GIFs, where the second one swaps the Y and time axis.
import sys
from PIL import Image, ImageDraw
if len(sys.argv) > 1:
gif_path, = sys.argv[1:]
im = Image.open(gif_path)
width, before_height = im.size
images_before = [im.copy()]
while im.tell() < im.n_frames-1:
im.seek(im.tell()+1)
@boppreh
boppreh / proxy.py
Created April 1, 2023 22:52
Proxy class to track modifications in a Python object and its children
class Proxy:
"""
Wraps an object to keep track of modifications, including to its children.
"""
def __init__(self, obj, modified_flag=None):
# Must use `super().__setattr__` to avoid recursing on itself.
super().__setattr__('_obj', obj)
super().__setattr__('_modified_flag', modified_flag or [False])
@property
@boppreh
boppreh / grep_and_sort.py
Last active February 9, 2023 10:46
Python implementation of `grep 'lasagna' beef.txt | sort -n`
# Python implementation of
# $ grep 'lasagna' beef.txt | sort -n | uniq
import re
lines = list(set(line for line in open('beef.txt') if 'lasagna' in line))
lines.sort(key=lambda line: int(re.match('\d*', line)[0] or 0))
for line in lines: print(line, end='')
@boppreh
boppreh / grey_goo.ash
Last active June 13, 2022 07:58
Kingdom of Loathing - 3-day auto-ascend and reincarnation with Grey Goo path, no requirements
# Runs Grey Goo ascensions with no input required. Just run this script once a day and it'll do some basic farming (11-leaf clovers, eating fortune cookies, etc) and reincarnate in the same path when possible.
void do_jobs() {
# Spend time doing Jobs Boards adventures. Not very rewarding, but
# levels us up enough to cast daily skills and gives some pocket change.
if (my_adventures() >= 10) {
visit_url("place.php?whichplace=town&action=town_oddjobs");
while (my_adventures() >= 10) {
run_choice(985, "pwd&option=3");
}
@boppreh
boppreh / userContent.css
Created May 17, 2022 19:49
Give a grey title to visited Youtube links based on browser history, without enabling watch history
# Save to C:\Users\{USER}\AppData\Roaming\Mozilla\Firefox\Profiles\{PROFILE_NAME}\chrome\userContent.css
# And enable "toolkit.legacyUserProfileCustomizations.stylesheets" on about:config
@-moz-document domain(www.youtube.com)
{
a:visited {
color: grey !important;
}
}