Skip to content

Instantly share code, notes, and snippets.

@boppreh
boppreh / Programming Language Checklist 2024.txt
Last active February 27, 2024 02:32
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;
}
}
@boppreh
boppreh / ipconfig_parser.py
Created November 17, 2021 12:47
Parse `ipconfig /all` in Python
import subprocess
import collections
Interface = collections.namedtuple('Interface', 'name description subnet_mask ipv4_addresses ipv4_gateway ipv6_addresses ipv6_gateway dhcp_server dns_servers')
def parse_ipconfig():
"""
Parses results from ipconfig. PowerShell has more structured functions, but
they don't serialize properly
(https://stackoverflow.com/questions/69997138/serialization-differences-between-powershells-format-list-and-convertto-json).
def make(goal, book, pantry, costs):
def guess(steps, required_ingredients):
if all(pantry.count(ingredient) >= required_ingredients.count(ingredient) for ingredient in required_ingredients):
yield tuple(sorted(required_ingredients)), steps
for ingredient in set(required_ingredients) & set(book):
new_required_ingredients = required_ingredients + book[ingredient]
new_required_ingredients.remove(ingredient)
yield from guess([ingredient] + steps, new_required_ingredients)
yield from guess([goal], book[goal])
const 𝗫 = 1;
const 𝖷 = 0;
x = list => list.length
Array.prototype.ꭓ = Array.prototype.reduce
Array.prototype.ჯ = Array.prototype.slice
Array.prototype.X = Array.prototype.push
𝚇 = (𝕏) => {
𝚾 = []