This is a SCRIPT-8 cassette.
#!/usr/bin/env python3 | |
"""Parses the text of Unsong, and the list of chapter initials, and finds | |
longest common subsequences. The idea here is that if the notarikon formed | |
by the first letter of each chapter conceals a secret message, then perhaps | |
parts of that message have already been revealed in the book... so if there | |
were "NIEAC" is somewhere in the list of chapter initials, then that probably | |
stands for "Nothing Is Ever A Coincidence", as per the many times that phrase | |
is mentioned. Idea from 75thTrombone at | |
https://www.reddit.com/r/unsong/comments/69k1im/preemptive_final_exam_suggestion/ | |
This script calculates those substrings. The answers are not all that promising. |
"""2017 general election | |
Given the vote totals, we have a hung parliament. Work out how coalitions | |
might be put together and display possibilities. | |
""" | |
import itertools | |
# vote totals correct as of about 10.30am Friday 9th June 2017 | |
votes= { | |
'Conservative': 318, 'Sinn Fein': 7, 'DUP': 10, | |
'Sylvia Hermon': 1, 'Plaid Cymru': 4, 'Labour': 261, 'SNP': 35, |
~/Scra+/ralight-configs $ python3 -c "import json; print(json.load(open('broken-config.json')))" | |
[snip] | |
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 10 column 20 (char 151) | |
~/Scra+/ralight-configs $ python3 -c "import yaml; print(yaml.safe_load(open('broken-config.yaml')))" | |
[snip] | |
yaml.scanner.ScannerError: while scanning a simple key | |
in "broken-config.yaml", line 9, column 5 | |
could not found expected ':' | |
in "broken-config.yaml", line 10, column 18 |
#!/usr/bin/env python3 | |
"""Daft script to count MPs by first name. | |
Expects to find people.json from https://github.com/mysociety/parlparse/tree/master/members | |
Run as "python3 mpnames.py Keir" or similar. | |
Written to answer Jess Phillips' question at https://twitter.com/sil/status/958750576900296706 | |
""" | |
import json, pprint, sys | |
fp = open("people.json", encoding="utf-8") | |
data = json.loads(fp.read()) | |
fp.close() |
import numpy as np | |
import glob | |
import markdown | |
import re | |
from bs4 import BeautifulSoup | |
def make_pairs(corpus): | |
for i in range(len(corpus)-1): | |
yield (corpus[i], corpus[i+1]) |
Note that this is a very quick thing. In particular, it only handles two levels of documentation in the manual, and it doesn't include images. Both would need to be fixed for this to actually be useful; however, this was entirely sufficient to drop a copy onto my phone where I could read it while my stupid mobile operator pretends to fix my network, sigh, etc.
A thing to convert a Gimp image of multiple layered sprites into a sprite sheet.
The way I make pixel art sprites is this: imagine you're drawing, say, a knight. I have all the frames for that knight in one great big Gimp XCF image, organised into groups.
So there's a layer group called "Running"; this defines a whole sprite, in multiple frames. In there, there's a set of layer groups, one per frame, called "Running 1" to "Running 9" (for example). In "Running 1", there's one or more layers which all go together to form that one single frame. This works out neatly because you can make an individual frame out of a few different parts, and edit those parts separately. This makes it easy to copy unchanging parts from one frame to the next, while just changing the bits that are different.
#!/usr/bin/env python3 | |
import requests | |
import requests_cache | |
import urllib.parse | |
import os.path | |
requests_cache.install_cache(os.path.join(os.path.dirname(__file__), 'million_sellers')) | |
#https://www.officialcharts.com/chart-news/the-best-selling-singles-of-all-time-on-the-official-uk-chart__21298/ |
#!/usr/bin/env python3 | |
import requests | |
try: | |
from requests_cache import CachedSession as MySession | |
except: | |
MySession = requests.Session | |
def unstring(s): |