Skip to content

Instantly share code, notes, and snippets.

@antoniusf
antoniusf / tnetstring-parser.js
Created January 15, 2023 11:52
wrote a cute lil tnetstring parser in javascript. it has some correctness issues and doesn't handle unexpected input well, but i like the structure and how painless it makes it to handle input in a streaming fashion. also, it doesn't actually parse actual tnetstring, but the thing that in my head is called tnetstring, where the type tag goes on …
const zero_ascii = '0'.charCodeAt(0);
let text_decoder = new TextDecoder();
export function* readTNetstringPrefix() {
let length = 0;
while (true) {
const read_byte = yield 1;
if (read_byte >= zero_ascii && read_byte <= zero_ascii + 9) {
#!/usr/bin/env python3
# Copyright (c) 2010 Joshua Harlan Lifton.
# See LICENSE.txt for details.
#
# keyboardcontrol.py - Abstracted keyboard control.
#
# Uses OS appropriate module.
"""Keyboard capture and control.
@antoniusf
antoniusf / converter.py
Last active February 27, 2017 09:57 — forked from anonymous/converter.py
import json, struct
##########################
#### data decoding to json
key_order = ["#", "S", "T", "K", "P", "W", "H", "R", "A", "O", "*", "E", "U", "F", "R", "P", "B", "L", "G", "T", "S", "D", "Z"]
keys = [(2**(len(key_order) - index -1), key) for (index, key) in enumerate(key_order)]
keys.insert(key_order.index("*") +1, (~0, "-"))