Skip to content

Instantly share code, notes, and snippets.

#!/bin/sed -rf
# How to run:
# echo 'A A<1+B1-C>B<1-A1+B>D<1-B1qC> 0<0>0'
# Note: Your local sed may use a different flag for "extended" regexes; this is written for GNU sed.
#
# tape: [active-state] " " (state-name "<" (write move next-state)_0 (write move next-state)_1 ">")* " " tape... "<" curpos ">" tape...
# State names can be any character not in " <>".
# The tape consists of 0's and 1's.
# The "move" field can be "-" to move left, "+" to move right, or "q" to halt.
@thequux
thequux / symboltable.py
Created May 11, 2014 19:17
A sketch of a symbol table
import collections
import contextlib
import itertools
class SymbolTable(collections.MutableMapping):
__slots__ = ('_content')
def __init__(self):
self._content = []
def _top_dict(self):
if not self._content:

Keybase proof

I hereby claim:

  • I am thequux on github.
  • I am thequux (https://keybase.io/thequux) on keybase.
  • I have a public key whose fingerprint is D3F4 3C11 0147 B6BD A90E D97B C262 C9B2 FA65 AB11

To claim this, I am signing this object:

char BASE64_ILUT[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
char BASE64_LUT[256];
void init_base64_lut(void) {
int i;
for (i = 0; i < 256; i++) {
BASE64_LUT[i] = 255;
}
@thequux
thequux / cfdec.py
Created October 1, 2013 11:10
Dump an uncompressed colorforth image (eg, for the GreenArrays IDE) to an easier-to-work-with JSON. The output format is a list of blocks, each block being a list of "words", where a "word" is a list of tag, text, and optional value. This code will mangle binary blocks; the first useful block for the GA IDE is 18.
#!/usr/bin/python
# This code is utter crap; that said, it's intended to be a quick and dirty hack.
# To dump JSON from a Colorforth image:
# - Load the image into colorforth
# - type '0 !back '
# - At your terminal, run "python cfdec.py <OkadBack.cf >Okad.json"
#
# On Windows, you will find OkadBack.cf in C:\GreenArrays\EVB001\OkadBack.cf
# On Linux, it's in ~/.wine/dosdevices/c:/GreenArrays/EVB001/OkadBack.cf
@thequux
thequux / gist:6034448
Created July 19, 2013 01:35
Putative C++ bindings for hammer
// Bindings MUST have a consistent mapping from the base Hammer API to
// the binding, suitable for mechanical translation. The binding MAY
// also support additional convenience methods. (see +type+ for an
// example)
const hammer::Parser& init_parser() {
// The default constructor gives you an +h_indirect()+ parser.
static hammer::Parser ret;
hammer::Parser &domain = init_domain();