Skip to content

Instantly share code, notes, and snippets.

View reborough.py
import math
import pickle
import random
import tqdm
known_adjacent = set()
known_non_adjacent = set()
try:
with open('/tmp/adjacencies.pkl', 'rb') as f:
View parserle.py
"""
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
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;
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
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):
@prophile
prophile / scheme.py
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',)
View equine.awk
awk: cmd. line:1: equine.awk
awk: cmd. line:1: ^ syntax error
@prophile
prophile / equine.pl
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?)
@prophile
prophile / calcmatches.py
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')
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
You can’t perform that action at this time.