This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from sys import argv, exit | |
if len(argv) < 2: | |
print 'USAGE: %s MODULE [SYMBOL]\nOpen help() for given module, or given symbol from module.' % \ | |
argv[0] | |
exit(1) | |
module = argv[1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file should be renamed ~/.xinitrc | |
# However, CAUTION: Your window manager / desktop environment may already use this file. | |
# In which case you should PREPEND the file with this file's contents. | |
# (The same applies if you have a custom xinitrc - just add this file's contents where appropriate. | |
# For example, in my home .xinitrc, this clause comes after common setup (such as setting the cursor) | |
# but before specifics for setting up my window manager.) | |
if [ -n "$XRUN" ]; then | |
eval $XRUN | |
exit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def combat(*forces): | |
"""Run a combat between any combination of forces. | |
Each force represents all involved ships owned by a given player. | |
The first force should be the defender, with forces then proceeding in order of player index (wrapping around). | |
Each force has form (player_WS, force_list). | |
Each force list should be a list of integers, giving the ships of the player and how they're split. | |
The force list should be the order in which the ships fight. | |
Note that, in a normal situation, a player's ships orbiting a star fight first, | |
followed by each fleet they have, from largest to smallest. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
import sys | |
from subprocess import check_call as cmd | |
from subprocess import check_output as cmd_out | |
from subprocess import CalledProcessError | |
out = cmd_out(['git', 'ls-remote', 'origin']) | |
refs = [line.split("\t") for line in out.strip().split("\n")] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IDENTITY = lambda x: x | |
class Pool(object): | |
"""Implements a generic pool of resources. | |
The resource is an object that: | |
* is created by the given factory function / class | |
* is intended to be re-used | |
* is hashable and unique (ie. multiple calls to factory() won't return the same object) | |
* optionally, gets prepared for re-use by given clean_fn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
USAGE="$0 EXECUTABLE PATH | |
For all shared libraries used by EXECUTABLE, copy that .so file to PATH" | |
if [ "$#" -ne 2 ]; then | |
echo "$USAGE" >&2 | |
exit 1 | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import random | |
import re | |
import sys | |
import argh | |
ROOT = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import signal | |
import subprocess | |
class Timeout(Exception): | |
"""This is raised when a timeout occurs""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools | |
import itertools | |
import sys | |
from collections import namedtuple | |
import argh | |
from ipaddress import IPv4Network | |
import easycmd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Render any jsonnet value (except functions) to TOML format. | |
local | |
inlineTable(body) = | |
"{" + | |
std.join(", ", ["%s = %s" % [escapeKeyToml(k), renderBody(body[k])] for k in std.objectFields(body)]) + | |
"}", | |
renderArray(body) = | |
local |