Skip to content

Instantly share code, notes, and snippets.

View bennuttall's full-sized avatar

Ben Nuttall bennuttall

View GitHub Profile
@bennuttall
bennuttall / img.py
Created March 29, 2023 11:36
Scripts for organising photos
from pathlib import Path
from structlog import get_logger
from PIL import Image
logger = get_logger()
dir = Path.cwd()
import json
import argparse
with open("words.json") as f:
WORDS = json.load(f)
def starts_with(chars):
return {
word
for word in WORDS
from string import ascii_lowercase
import argparse
import random
LINUX_SYSTEM_DICT = '/usr/share/dict/american-english'
MAC_SYSTEM_DICT = '/usr/share/dict/words'
BIG_WORDLIST = 'words.txt'
# wordlist = LINUX_SYSTEM_DICT
wordlist = MAC_SYSTEM_DICT
@bennuttall
bennuttall / solutions.txt
Last active May 11, 2024 11:26
Wordle checker
CIGAR
REBUT
SISSY
HUMPH
AWAKE
BLUSH
FOCAL
EVADE
NAVAL
SERVE
from pathlib import Path
from piwheels.slave.builder import Builder, Wheel
wheel_file_path = Path("awkward-1.0.0-cp37-cp37m-linux_armv7l.whl")
builder = Builder(None, None)
wheel = Wheel(wheel_file_path)
builder.build_dependencies(wheel)
from itertools import product
def count_neighbours(x, y):
deltas = set(product((-1, 0, 1), repeat=2)) - {(0, 0)}
return len({(x + dx, y + dy) for (dx, dy) in deltas} & lights_on)
def evolve(lights_on):
still_on = {(x, y) for x, y in lights_on if count_neighbours(x, y) in (2, 3)}
now_off = set(product(range(SIZE), repeat=2)) - lights_on
turn_on = {(x, y) for x, y in now_off if count_neighbours(x, y) == 3}
from pathlib import Path
from collections import defaultdict
missing_wheels = defaultdict(set)
extra_wheels = defaultdict(set)
rewrites = set()
total_missing = 0
total_extra = 0
with open('missing.txt') as f:
from mosromgr.mostypes import MosFile
from glob import glob
from git import Repo
files = glob('*.mos.xml')
ro, *mosfiles = sorted(MosFile.from_file(f) for f in files)
repo = Repo.init('.')
ro_id = ro.ro_id.replace(';', '_')
for f in */*LOG*.csv; do
tr < $f -d '\000' > $f.tmp
mv $f.tmp $f
done
@bennuttall
bennuttall / .htaccess
Created May 23, 2020 12:26
wordpress dev .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^wp-content/uploads/(.*)$ https://bennuttall.com/wp-content/uploads/$1 [L,R=302]
</IfModule>