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
# 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
#!/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
#!/bin/bash | |
USAGE="$0 TIMESPEC [COMMAND {ARGS}] | |
Do a banner-style countdown starting from TIMESPEC. | |
TIMESPEC should be either integer seconds, or in one of the forms: | |
XXm XXmXX XXmXXs XX:XX | |
For example: 10m, 10m00, 10m0s, 10:00 or 600 are all ways of saying 10 minutes. | |
If given, COMMAND will be run with ARGS once the timer has completed. | |
" |
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 | |
BLACK=30 | |
GRAY="$BLACK;1" | |
RED=31 | |
BOLDRED="$RED;1" | |
GREEN=32 | |
BOLDGREEN="$GREEN;1" | |
YELLOW=33 | |
BOLDYELLOW="$YELLOW;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
#!/bin/bash | |
USAGE="$0 [TIMESPEC] | |
A speaking clock that says the time once every TIMESPEC. | |
For example, \"$0 1 hour\" would speak at the boundary of every hour, | |
while \"$0 15 minutes\" would speak four times as often. | |
In technical terms, the time is reported when time since epoch is divisible by TIMESPEC. | |
TIMESPEC defaults to 1 hour. | |
" |
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 [FORMAT]" | |
FORMAT="${1:-%T}" | |
while sleep 1; do | |
clear | |
echo | |
banner "`date "+$FORMAT"`" |
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
# Prefixes current PS1 with a blank space | |
# This blank space changes to a ! character if any command | |
# given in the ALERTS array exits non-zero. | |
# (additionally, a ? character is an error state - this shouldn't happen) | |
# Tip: ALERTS may be appended to thusly: ALERTS+=('mycommand myarg') | |
# Note: Commands in ALERTS are run every time PS1 is printed. | |
# However, if any command fails (indicates an alert), no further commands will be run. | |
declare -a ALERTS[0] |
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 | |
if [ "$#" -lt 2 ]; then | |
echo "USAGE: $0 TIME COMMAND {ARGS}" | |
echo "Run COMMAND with ARGS at specified TIME." | |
echo "TIME may be given in any form understood by date(1)" | |
exit 2 | |
fi | |
duestr="$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
import termios | |
import sys | |
from itertools import count | |
class TermAttrs(object): | |
def __init__(self, attrs, fd=None, when=termios.TCSANOW): | |
"""A context manager for changing terminal attrs. | |
fd defaults to stdin. | |
attrs must be a 7-element iterable as taken by tcsetattr. |