Skip to content

Instantly share code, notes, and snippets.

View hornc's full-sized avatar
๐Ÿ‡บ๐Ÿ‡ฆ
๐Œ€๐Œ„๐Œ…

Charles Horn hornc

๐Ÿ‡บ๐Ÿ‡ฆ
๐Œ€๐Œ„๐Œ…
View GitHub Profile
@hornc
hornc / pixelimg.py
Created July 31, 2025 06:02
pixel art to numeric text grid
#!/usr/bin/env python3
import sys
from PIL import Image
# opens a limited palette
# pixel art image and outputs
# a 0-9 digit grid
# + palette
@hornc
hornc / rb-cachebuster.py
Last active August 26, 2025 23:47 — forked from Hans5958/rb-cachebuster.py
Roblox Cache Buster: Simple script to convert Roblox cache files in `%appdata%\Local\Roblox\rbx-storage` folder to normal, openable files (if valid). Run the script inside `%appdata%\Local\Roblox\rbx-storage` normally in Windows OR ~/.var/app/org.vinegarhq.Sober/cache/sober/http for Sober under Linux. Now tested in Linux and original Windows witโ€ฆ
from genericpath import isfile
import puremagic, io, os
os.makedirs('cachebuster', exist_ok=True)
# Tries to identify rbx file not identifiable by puremagic:
def rbx_format(data):
head = data.read(20)
if head.startswith(b'version'):
# https://devforum.roblox.com/t/roblox-filemesh-format-specification/326114
#!/usr/bin/env python3
import argparse
import csv
def main():
parser = argparse.ArgumentParser(description='Convert CSV to TSV.')
parser.add_argument('csv', help='CSV file to convert')
args = parser.parse_args()
@hornc
hornc / iacite.py
Created June 22, 2023 21:09
Generate a Wipkipedia cite book template for an archive.org identifier (with optional page number + link)
#!/usr/bin/env python
import argparse
import internetarchive as ia
import biblionames
#from isbn_hyphenate import hyphenate
from isbnlib import mask as hyphenate
OCLC_TAG = 'urn:oclc:record:'
@hornc
hornc / rename_images_and_make_pdf.sh
Created June 1, 2023 08:03
Rename images to correctly sort them, and make a pdf
# Install reqs
sudo apt install rename
# Test rename command:
rename -n 's/(\d+)(?=.*\.)/sprintf("%03d",$1)/eg' *.jpg
# Bash commands to 0 pad (to 3 digits) numbers in .jpg filenames
rename 's/(\d+)(?=.*\.)/sprintf("%03d",$1)/eg' *.jpg
@hornc
hornc / validISSN.py
Created May 18, 2023 03:06
Validate and format ISSNs
# Validate and format ISSNs
def validISSN(issn):
issn = issn.upper().replace('X', 'A').replace('-', '')
return len(issn) == 8 and sum((8 - i) * int(n, 16) for i, n in enumerate(issn)) % 11 == 0
def formatISSN(issn):
issn = issn.upper().replace('-', '')
return f'{issn[:4]}-{issn[4:]}'
from baseconv import base58
from isbnlib import is_isbn13, check_digit13
def compress_isbn(isbn):
# compresses a valid checkdigit ISBN13
isbn = isbn.replace('-', '')
assert is_isbn13(isbn)
prefix = isbn[:3]
body = isbn[3:-1]
@hornc
hornc / validISNI.py
Last active November 20, 2022 21:21
Validate and ISNI
"""
[copied from https://github.com/internetarchive/openlibrary/pull/6841#issuecomment-1207507062]
I'm recording this here because there is very little information currently about ISNI check digits online.
ISNI uses a checkdigit {0-9, X} calculation system which is called something like "MOD 11-2" and is
defined in the standard [ISO 7064](https://en.wikipedia.org/wiki/ISO/IEC_7064), but you have to pay to read it....
The same "MOD 11-2" system is used by the
Chinese [Resident Identity Card](https://en.wikipedia.org/wiki/Resident_Identity_Card),
which has its own specs and more publicly available code examples.
@hornc
hornc / gc.py
Last active January 10, 2023 23:36
G_arD^EN CorUtY@rD esolang interpreter
#!/usr/bin/env python
"""
Esoteric programming language interpreter for
G_arD^EN CorUtY@rD
https://esolangs.org/wiki/G_arD%5EEN_CorUtY@rD
Interpreter by Salpynx, 2022.
"""
import sys
@hornc
hornc / pypmm.py
Last active September 9, 2022 03:48
"""
Python Portable Minsky Machine
Implements a Python version of
https://esolangs.org/wiki/Portable_Minsky_Machine_Notation
"""
counters = {}
def inc(counter):