Skip to content

Instantly share code, notes, and snippets.

View prophile's full-sized avatar

Alistair Lynn prophile

View GitHub Profile
Dutch lights on sticks
Flashing aspects indicated by *
R: Red
Y: Yellow
G: Green
Main signals may or may not be fitted with a number display.
Main signals without numbers:
states = [
'Normal',
'Inbound',
'Unlocked',
]
transitions = [
('Normal', 'Inbound', 'B_enter & correct'),
('Inbound', 'Unlocked', 'timeout'),
('Unlocked', 'Normal', 'B_arrived'),
import math
import pickle
import random
import tqdm
known_adjacent = set()
known_non_adjacent = set()
try:
with open('/tmp/adjacencies.pkl', 'rb') as f:
"""
RLE extractor for EV Nova resource files.
Usage information available through python3 parserle.py --help
Requires both `pillow` and `rsrcfork` from PyPI. Alas this is unlikely to
work on non-Darwin platforms.
"""
import os.path
function drive() {
var getSquare = function(i, j) {
return $('#' + i + '_' + j);
}
// detect extents
var W, H;
for (var i = 1; i <= 100; ++i) {
if (getSquare(i, 1).length == 0) {
W = i - 2;
break;
try:
from collections.abc import Iterable
except ImportError:
from collections import Iterable
import heapq
class AStar(Iterable):
def __init__(self, transition, heuristic, start, zero_score=0, pure_heuristic=False):
self.transition = transition
self.heuristic = heuristic
class TraceIO(object):
def __init__(self, stream, log=print):
self.stream = stream
self.log = log
def __enter__(self):
return self.stream.__enter__()
def __exit__(self, *args):
@prophile
prophile / scheme.py
Last active August 29, 2015 14:19
A quick Scheme implementation in Python, as a programming exercise
from functools import wraps
from collections import namedtuple
from collections.abc import MutableMapping
import string
import operator
import sys
import numbers
class Parser(object):
__slots__ = ('parse',)
@prophile
prophile / equine.awk
Created March 5, 2015 20:47
Quine in Awk
awk: cmd. line:1: equine.awk
awk: cmd. line:1: ^ syntax error
@prophile
prophile / equine.pl
Created March 4, 2015 16:08
A Quine, in Perl
String found where operator expected at equine.pl line 1, near "near "near ""
(Do you need to predeclare near?)
Bareword found where operator expected at equine.pl line 1, near ""near "near"
(Missing operator before near?)
String found where operator expected at equine.pl line 1, near "near """
(Do you need to predeclare near?)
Use of ?PATTERN? without explicit operator is deprecated at equine.pl line 2.
Semicolon seems to be missing at equine.pl line 4.
String found where operator expected at equine.pl line 5, near "near "near ""
(Do you need to predeclare near?)