This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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:' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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:]}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
[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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Python Portable Minsky Machine | |
Implements a Python version of | |
https://esolangs.org/wiki/Portable_Minsky_Machine_Notation | |
""" | |
counters = {} | |
def inc(counter): |
NewerOlder