Instantly share code, notes, and snippets.

# Alistair Lynnprophile

• Sort options
Created Feb 10, 2017
View mineexpand.js
 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;
Created Jan 7, 2017
View astar.py
 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
Created Apr 11, 2016
View traceio.py
 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):
Last active Aug 29, 2015
A quick Scheme implementation in Python, as a programming exercise
View scheme.py
 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',)
Created Mar 5, 2015
Quine in Awk
View equine.awk
 awk: cmd. line:1: equine.awk awk: cmd. line:1: ^ syntax error
Created Mar 4, 2015
A Quine, in Perl
View equine.pl
 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?)
Last active Aug 29, 2015
Calculate the number of matches in a league
View calcmatches.py
 from __future__ import print_function, division import argparse from datetime import timedelta from math import ceil, floor def parse_time(x): hours, minutes = x.split(':') return timedelta(hours=int(hours), minutes=int(minutes)) parser = argparse.ArgumentParser(description='Calculate statistics about matches for an SR competition')
Created Jan 3, 2015
Zerg rush build order
View gist:39b6404907475e9e8681
 7 SpawningPool 10 Extractor 10 Overlord 10 Zergling 11 Queen 13 +1 Drone on gas 16 +1 Drone on gas 16 +1 Drone on gas 18 EvolutionChamber 18 Overlord
Created Nov 20, 2014
Update standard pages for SR Trac
View update-builtins.py
 from xmlrpc.client import ServerProxy as TracAPI from xmlrpc.client import Fault as TracFault from urllib.parse import quote from getpass import getpass from pathlib import Path import sys import time username = input('SR Username: ') password = getpass('SR Password: ')
Created Nov 12, 2014
Get the modernised srcomp suite
View get-suite.sh
 #!/bin/bash GERRIT=https://www.studentrobotics.org/gerrit function getgit { PROJECT=\$1 URL=\$GERRIT/comp/\$PROJECT PATCH=\$2 git clone \$URL \$PROJECT cd \$PROJECT git fetch \$URL \$PATCH
You can’t perform that action at this time.