Skip to content

Instantly share code, notes, and snippets.

View milesrout's full-sized avatar

Miles Rout milesrout

View GitHub Profile
Akaroa
Amuri
Ashburton
Bay of Islands
Bruce
Buller
Chatham Islands
Cheviot
Clifton
Clutha
@milesrout
milesrout / xterm-256color-italic.terminfo
Created July 18, 2018 23:17 — forked from sos4nt/xterm-256color-italic.terminfo
A xterm-256color based TERMINFO that adds the escape sequences for italic
# A xterm-256color based TERMINFO that adds the escape sequences for italic.
#
# Install:
#
# tic xterm-256color-italic.terminfo
#
# Usage:
#
# export TERM=xterm-256color-italic
#
@milesrout
milesrout / DCPU-16Spec.txt
Created April 11, 2018 04:45 — forked from metaphox/DCPU-16Spec.txt
DCPU-16 Specification
DCPU-16 Specification
Copyright 1985 Mojang
Version 1.7
=== SUMMARY ====================================================================
* 16 bit words
* 0x10000 words of ram
@milesrout
milesrout / characters.py
Created March 26, 2018 03:44
Gives the characters of any literary work
print(__import__('random').choice(__import__('sys').stdin.read().strip()))
@compose(E.ControlStructureExpression)
@compose(list)
def linked_control_structure_stmt(self, initial, pos0):
linking_structure = self.linked_control_structures[self.current_token().string]
while True:
pos = self.current_token().pos
name = self.get_token().string
options = linking_structure[name]
params = []
i, j = 0, 0
28 base_linked_control_structures = {
29 'if': {
30 'if': [[None]],
31 'elif': [[None]],
32 'else': []
33 },
34 'while': {
35 'while': [[None]],
36 'else': [],
37 },
if x:
pass
elif y:
pass
elif z:
pass
elif q:
pass
else:
pass
# to print an s-expression
#
# e.g.
# (macro-definition
# (id-expression name)
# (statements
# (...)
# (...)
# (...)))
def to_sexpr(o, indent=None):
return fmt_sexpr(json.loads(MyJSONEncoder().encode(o)))
def fmt_sexpr(o, depth=1):
if isinstance(o, dict):
return fmt_sexpr(list(o.values()), depth)
if isinstance(o, tuple):
return fmt_sexpr(list(o), depth)
if isinstance(o, list):
if len(o) == 0:
@milesrout
milesrout / takes_150_ms.py
Last active March 15, 2018 08:08
iterators are fantastic
def solve(su, cs):
for c in cs:
su1 = unifies(c.t1, c.t2, c.pos)
su = compose_subst(su1, su)
return su