This file contains 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
For simplicity, the cypher spec uses a pair of bytes for each entry: opcode, and (optional) argument |
This file contains 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
type Column = Int | |
type Crate = Char | |
type Stacks = Map.Map Column [Crate] | |
data Move = Move Int Column Column deriving (Show, Eq) | |
parse :: [String] -> (Stacks, [Move]) | |
parse ls = | |
let | |
[stackDesc, moveDesc] = ls & splitOn [""] | |
stacks = foldl' stackLine Map.empty stackDesc |
This file contains 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
This is a bit ugly. | |
We need to ensure that socat doesn't discard zero-size payloads (because they're a request for the value assigned to the | |
null identifier.) | |
We use a single standalone single-threaded process to serve up the persistent DB. | |
We can't shutdown sockets, which means that we can't just `cat` content from the `downstream` packet handler into a receiving | |
`cat` in the zdb; this'll hang because nothing is closing the TCP connection to it. If we close the outgoing connection, the | |
read connection (that associates a request to a response) gets closed too. |
This file contains 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
This has a performance problem with the multiclient tests on the host I run it on. | |
I initially used an alternative jq-only naive primality test - this was too slow as well, so I dropped into openssl's checker. | |
``` | |
# replace from `number=` | |
<<<"$req" jq -c ' | |
def isInteger: | |
(. | type == "number") and | |
(. | floor == .) | |
; |
This file contains 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
socat TCP-LISTEN:12345,fork,reuseaddr SYSTEM:"cat -u" |
This file contains 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
Sed doesn't do lookbehind/lookahead. | |
This works because the tests don't try foo-7abcdefghijklmnopqrstuvwxyz; using capture groups around the expression | |
and backrefs in the replacement doesn't work if you have two bogusCoin addresses separated by a single space. | |
Replacing the implementation of munge with some other stdio pipe that does the business is left as an exercise to the reader. |
This file contains 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
This is an image! | |
# IMAGE: foo.jpg | |
+ restart? | |
# RESTART | |
-> END |
This file contains 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 | |
# Invoke with | |
# ./v1.py {source-file} {n} {m} | |
# where {n} is the size of the n-gram used (3 for trigrams) | |
# {m} is the amount of output text required. | |
from collections import Counter | |
import os | |
from random import choice |
This file contains 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
# This is a poor approximation at looking for the history of implementations as they were copied between games. | |
# Although various things might have a similar routine (OWN-FEET, for instance), it's clear that these all underwent | |
# change as the basic parser grew more capabilities. | |
A-AN planetfall planetfall-gold | |
A-O-K seastalker | |
A-PRSI lurkinghorror spellbreaker | |
A-PRSI? lurkinghorror spellbreaker | |
A-PRSO lurkinghorror spellbreaker |
This file contains 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 | |
# From the introduction, pp. 5-6. | |
# Two approaches to generate anagrams. | |
from collections import Counter | |
from functools import cmp_to_key | |
from math import log2, factorial | |
from string import ascii_lowercase # not very internationally-minded, but it'll do for these purposes |
NewerOlder