Skip to content

Instantly share code, notes, and snippets.

Avatar

Charles Horn hornc

  • Wellington, New Zealand
  • Twitter @kynesis
View GitHub Profile
View pypmm.py
"""
Python Portable Minsky Machine
Implements a Python version of
https://esolangs.org/wiki/Portable_Minsky_Machine_Notation
"""
counters = {}
def inc(counter):
@hornc
hornc / isbnregions.sh
Created Nov 30, 2021
Takes an input list of ISBN13s and counts how many belong to each of the possible regional agencies.
View isbnregions.sh
#!/bin/bash
# Takes an input file argument (a sorted list of ISBN13s)
# and counts how many ISBNs are present belonging to each
# regional agency as listed in the official
# ISBN export_rangemessage.xml data.
wget -nc https://www.isbn-international.org/export_rangemessage.xml
while read prefix agency; do
View gdriveget.py
#!/usr/bin/env python3
# Based on Google Drive v3 API Quickstart example
# https://developers.google.com/drive/api/v3/quickstart/python
import os.path
import io
import sys
from googleapiclient.discovery import build
from googleapiclient.http import MediaIoBaseDownload
@hornc
hornc / barcode-checks.py
Created Jul 2, 2020
testing some barcode check digit validations
View barcode-checks.py
# Library codabar (14 digit barcode) check digit validator
# (1 digit):material type + (4 digits):library code + (8 digits):item code + (1 digit): checksum
# source: http://www.makebarcode.com/specs/codabar.html
# - GOOD!
def vcodabar(n):
"""Validate the checkdigit of a 14 digit library barcode."""
check = int(n[-1])
data = n[:-1]
total = 0
for i, c in enumerate(data):
View get-ol-data.sh
#!/bin/bash
# Openlibrary.org data dumps are generated at the end of each month, this downloads them.
# This will save the separate dump files with the redirected filename containing dates.
wget --trust-server-names https://openlibrary.org/data/ol_dump_authors_latest.txt.gz
wget --trust-server-names https://openlibrary.org/data/ol_dump_works_latest.txt.gz
wget --trust-server-names https://openlibrary.org/data/ol_dump_editions_latest.txt.gz
gunzip *.gz
View hello-world.sas
-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
@hornc
hornc / README.md
Last active Sep 22, 2020
Thue-Mirr esolang Interpreter
View README.md

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 / README.txt
Last active Jan 3, 2019
Retropie GPIO control script
View README.txt
# 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 / APLBAONWSJAS.py
Last active Oct 14, 2021
A ridiculous interpreter for the joke esoteric programming language APLBAONWSJAS https://esolangs.org/wiki/APLBAONWSJAS
View APLBAONWSJAS.py
#!/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 / bf8
Last active Nov 21, 2018
Brainfoctal Interpreter
View bf8
#!/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