Skip to content

Instantly share code, notes, and snippets.

View eklitzke's full-sized avatar

Evan Klitzke eklitzke

View GitHub Profile
@eklitzke
eklitzke / conv.py
Created March 11, 2018 18:38 — forked from meighti/conv.py
This gist converts legacy Base58 BitcoinCash addresses to new Bech32 format. It is a combination of codes written by Gavin Andresen and Pieter Wuille.
#!/usr/bin/env python2.7
import math
import sys
import hashlib
__b32chars = "qpzry9x8gf2tvdw0s3jn54khce6mua7l"
__b58chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
def b58encode(v):
/*
Designed for makemkvcon running inside a Docker container writing MKV files to /output.
The problem:
makemkvcon creates MKV files with the maximum of 0644 file mode. The current umask limits the maximum file mode, but
does not itself increase permissions (only decreases). This means when a user has a umask of 0002 and touches a new
file, it will have permissions of 664. However when makemkvcon runs MKV files will have permissions of 644.
The solution:
This code compiles into a shared object which is loaded at the beginning of makemkvcon's execution. This will
ctrl-z
bg
touch /tmp/stdout
touch /tmp/stderr
gdb -p $!
# In GDB
p dup2(open("/tmp/stdout", 1), 1)
p dup2(open("/tmp/stderr", 1), 2)
class Strategy s where
storeOutput :: s -> Ports -> IO ()
nextInput :: s -> IO Ports
isDone :: s -> Bool
failed :: s -> Bool
run :: Strategy s => s -> IO [Ports]
run world = let loop = do w' = next world
if isDone w'
then fetch w'