Skip to content

Instantly share code, notes, and snippets.

View prophile's full-sized avatar

Alistair Lynn prophile

View GitHub Profile
@prophile
prophile / calcmatches.py
Last active August 29, 2015 14:14
Calculate the number of matches in a league
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')
@prophile
prophile / gist:39b6404907475e9e8681
Created January 3, 2015 23:24
Zerg rush build order
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
@prophile
prophile / update-builtins.py
Created November 20, 2014 19:00
Update standard pages for SR Trac
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: ')
@prophile
prophile / get-suite.sh
Created November 12, 2014 13:32
Get the modernised srcomp suite
#!/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
@prophile
prophile / resdist.py
Last active August 29, 2015 14:08
Resource distribution brute-force algorithm in Python
from itertools import permutations
import yaml
import sys
#votes = {'a': ['cheese', 'hats', 'faces'],
# 'b': ['hats', 'cheese', 'faces'],
# 'c': ['hats', 'faces', 'cheese']}
votes = {'a': 'CHWESK',
'b': 'CESWHK',
@prophile
prophile / stv.py
Created October 29, 2014 03:25
An implementation of STV with the Droop quota, using the Gregory method and an ad-hoc tie breaking system
from copy import copy
from collections import defaultdict
from fractions import Fraction
def stv(candidates, ballots, seats=1):
if seats > len(candidates):
raise ValueError('Not enough candidates for election')
rounds = {}
@prophile
prophile / pages.md
Created September 7, 2014 21:25
Some remarks in favour of GitHub Pages

In Promotion of Jekyll

There's been heavy discussion of the various options surrounding the pages for the Sponge wiki. At the time of writing, the current contenders for implementation are:

  • MediaWiki
  • DokuWiki
  • GitHub Wiki
  • GitHub Pages/Jekyll
  • A homebrew option
import itertools
def tail(seq):
return itertools.islice(seq, 1, None)
def fibs():
yield 0
yield 1
yield from (x + y for x, y in zip(fibs(), tail(fibs())))
from collections import namedtuple
import cgi
import sys
import yaml
DATA = """
- type: checkbox
description: Did the robot move?
key: robot_moved
- type: natural
from __future__ import print_function
from collections import namedtuple, defaultdict
Check = namedtuple('Check', 'description check')
Condition = namedtuple('Condition', 'severity format')
Failure = namedtuple('Failure', 'type severity message data')
class Validator(object):
def __init__(self):
self.checks = []