Skip to content

Instantly share code, notes, and snippets.

View hornc's full-sized avatar
👾
🎼

Charles Horn hornc

👾
🎼
  • Wellington, New Zealand
View GitHub Profile
@hornc
hornc / fix_bad_combining.py
Created December 5, 2017 21:52
Script used to fix up ~38,500 Open Library authors' works and editions with Unicode transcoding errors for u0361 (combining diacritical mark) Nov 2017 github issue: https://github.com/internetarchive/openlibrary/issues/150
#!/usr/bin/python
from olclient.openlibrary import OpenLibrary
from olclient.utils import merge_unique_lists
from unicodedata import normalize
import sys
import time
def fix_ufe21(txt):
if u'\u0361' in txt:
@hornc
hornc / move_editions.py
Last active January 31, 2023 01:34
Move OL editions to correct Work
from olclient.openlibrary import OpenLibrary
ol = OpenLibrary()
def move_editions(editions, master):
"""Sets a list of <editions> to a new master work ID using the Open Library Client.
Copies across extra author data from editions to master, if not already present.
Example:
move_editions(['OL8306567M','OL16682544M'], 'OL4005510W')
"""
@hornc
hornc / update-index.py
Last active April 9, 2018 22:27
Update removed authors appearing in search results from OL solr index.
#!/usr/bin/python
# coding: utf-8
from olclient.openlibrary import OpenLibrary
from datetime import datetime
import random
import time
# script to take an OL Author search and incrementally update the solr index
def author_search(ol, term, offset=0, limit=100):
@hornc
hornc / importauthormatch.py
Last active June 6, 2018 21:06
OL Author Matching
from olclient.openlibrary import OpenLibrary
import re
import web
import urllib
import json
ol = OpenLibrary()
# testing OL code to determine existing author matches
# taking old code form
# https://github.com/internetarchive/openlibrary/blob/f8092840a77c7479a352fd83fd068d340f97d3e3/openlibrary/catalog/add_book/load_book.py
@hornc
hornc / addbooktest.py
Last active June 7, 2018 04:49
OL add book testing
from olclient.openlibrary import OpenLibrary
ol = OpenLibrary()
import re
# These functions are to safely test, without adding any new items, how the OL add book endpoint behaves
# with different inputs.
# Scrapes the OL response page for the add book result:
# Probably not production worthy! ;)
@hornc
hornc / bf8
Last active November 21, 2018 07:05
Brainfoctal Interpreter
#!/bin/bash
# Brainfoctal interpreter.
# REQUIREMENTS:
# python3 to convert
# bff4, http://mazonka.com/brainf/bff4.c to interpret,
# $BFI should point to the compiled interpreter
# USAGE:
# ./bf8 <bf8 Gödel number in dec|oct|hex|bin> <input data>
# EX.
# ./bf8 0o6565 Hi
@hornc
hornc / APLBAONWSJAS.py
Last active October 14, 2021 17:00
A ridiculous interpreter for the joke esoteric programming language APLBAONWSJAS https://esolangs.org/wiki/APLBAONWSJAS
#!/usr/bin/env python3
import re
import subprocess
"""
This is a ridiculous interpreter for the joke esoteric programming language APLBAONWSJAS
see https://esolangs.org/wiki/APLBAONWSJAS for details.
!!!WARNING!!! this takes user input and runs it without checking as system commands,
this could have unintended consequences, and what you type could make changes to your
@hornc
hornc / README.txt
Last active January 3, 2019 02:56
Retropie GPIO control script
# shutdown.py script to be at
/home/pi/scripts/shutdown.py
# Copy the unit file to
/lib/systemd/system/pi_shutdown.service
# ensure permissions are correct
sudo chmod 644 /lib/systemd/system/pi_shutdown.service
# To enable the service:
@hornc
hornc / README.md
Last active September 22, 2020 03:51
Thue-Mirr esolang Interpreter

Thue-Mirr interpreter,

https://esolangs.org/wiki/Thue-Mirr

usage: thue-mirr.py [-h] [--debug] [--char] [--num NUM] file

Thue-Mirr https://esolangs.org/wiki/Thue-Mirr Interpreter v1.0 by Salpynx. 2019 CC0

positional arguments:
 file source file to process
@hornc
hornc / hello-world.sas
Last active May 27, 2019 23:38
Experimental notation interpreter for https://esolangs.org/wiki/Sticks_and_Stones
-1c
a72 1c 3c
a29 -1c -3c
a7 1c c-2 2c2 1c
a3 -1c 8c8
a-67 -8c-8 -3c
a-12 1c 3c
a55 -1c -3c
a24 1c 3c
a3 -1c -3c