Skip to content

Instantly share code, notes, and snippets.

@pyalot
pyalot / gist:5171175
Last active September 25, 2019 22:27
Minecraft mca/nbt parser
from struct import unpack
from zlib import decompress
class BufferStream:
def __init__(self, data):
self.pos = 0
self.data = data
def get(self, amount):
result = self.data[self.pos:self.pos+amount]
@pyalot
pyalot / base64decode.coffee
Created January 14, 2013 13:44
Coffeescript efficient base64 decode to typed array.
decodingTable = new Uint8Array(256)
for c, i in 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
decodingTable[c.charCodeAt(0)] = i
base64decode = (string) ->
last = string[string.length-2...string.length]
if last == '=='
remainder = 2
else if last[1] == '='
remainder = 1