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
diff --git a/Engine/Graphics/ImageLoader.cpp b/Engine/Graphics/ImageLoader.cpp
index bc08c22..8aa9b8b 100644
--- a/Engine/Graphics/ImageLoader.cpp
+++ b/Engine/Graphics/ImageLoader.cpp
@@ -24,15 +24,17 @@ GLuint CreateTexture ( SDL_Surface* surface, bool autofree, bool rectangle )
glBindTexture(target, texID);
if (surface->format->BytesPerPixel == 3)
{
+ GLenum format = (surface->format->Rmask) != 0xFF ? GL_RGB : GL_BGR_EXT;
glTexImage2D(target, 0, GL_RGB,
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 / review-ws.sh
Created December 3, 2013 14:30
A script for testing content differences on whitespace changes in srweb
#!/bin/bash
# Usage: review-ws (gerrit change number) when in an srweb clone
SSH_HOST=badger
set -e
REF=$(ssh $SSH_HOST gerrit query --current-patch-set $1 | grep '^ ref: ' | cut -d' ' -f6)
git fetch https://www.studentrobotics.org/gerrit/srweb $REF
git checkout FETCH_HEAD
FILES=$(git diff --name-only HEAD~1 HEAD | grep '^content/en')
for FILE in $FILES
do
formats = {}
formats['vanilla'] = {'player_join': '(?P<name>[A-Za-z0-9_]{1,16}) has joined the game\.'}
formats['bukkit'] = {'plugin_loading': '\[(?P<plugin_name>.+\] plugin loaded\.'}
formats['ping_1.6'] = {...}
# Select which combinations to use, taking right-to-left precedence
options = ['ping_1.6', 'vanilla']
messages = dict(itertools.chain.from_iterable(formats[x].items() for x in options))