This file contains 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 random | |
import itertools | |
def sample(population, k): | |
"How random.sample should really be defined." | |
if callable(getattr(population, '__len__', None)) and callable(getattr(population, '__getitem__', None)): | |
return random.sample(population, min(k, len(population))) | |
p = iter(population) |
This file contains 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
package message; | |
import "gogo.proto"; | |
option (gogoproto.sizer_all) = true; | |
option (gogoproto.marshaler_all) = true; | |
option (gogoproto.unmarshaler_all) = true; | |
option java_package = "org.mozilla.heka"; | |
option java_outer_classname = "HekaMessage"; |
This file contains 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
package message; | |
import "gogo.proto"; | |
option (gogoproto.sizer_all) = true; | |
option (gogoproto.marshaler_all) = true; | |
option (gogoproto.unmarshaler_all) = true; | |
option java_package = "org.mozilla.heka"; | |
option java_outer_classname = "HekaMessage"; |
This file contains 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
# Usage: . awscli_functions.sh | |
# Suggested: add to ~/.bashrc | |
# This code lazily uses your default profile && region. | |
# It wouldn't take much to add some logic for using ${PROFILE} and/or ${REGION} as some kind of override. | |
# Lots more functions would be helpful, but I've been playing with ec2 & vpcs a lot lately, so... | |
clusters() | |
{ | |
local __resultvar=$1 | |
local __clusters=$(aws ecs list-clusters | jq -r '.clusterArns[]') |
This file contains 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
"""Shadow run attack simulator. | |
Usage: | |
shadow_combat.py [--debug] [--limit LIMIT | -6 | --rule_of_six] [--threshold THRESHOLD | --opposed_pool OPPOSED [--opposed_limit OPPOSED_LIMIT]] [--dv DV --stun [--soak SOAK] [--armor ARMOR [--ap AP]]] [--contact] [--once | -o | [--iterations ITERATIONS] [-D | --distribution]] [--multi ATTACKS] [--min DAMAGE] ATTACK_POOL | |
shadow_combat.py [--debug] [--contact] [-6 | --rule_of_six] --threshold THRESHOLD ATTACK_STRING DAMAGE_STRING SOAK_STRING | |
shadow_combat.py [--debug] [--contact] [-D | --distribution] [-6 | --rule_of_six] --threshold THRESHOLD ATTACK_STRING DAMAGE_STRING SOAK_STRING ITERATIONS | |
shadow_combat.py [--debug] [--contact] [-6 | --rule_of_six] ATTACK_STRING DAMAGE_STRING DEFENSE_STRING SOAK_STRING | |
shadow_combat.py [--debug] [--contact] [-D | --distribution] [-6 | --rule_of_six] ATTACK_STRING DAMAGE_STRING DEFENSE_STRING SOAK_STRING ITERATIONS | |
shadow_combat.py (-h | --help) | |
shadow_combat.py (-v | --version) |
This file contains 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
#cloud-config | |
--- | |
coreos: | |
units: | |
- name: update-fleet-metadata.service | |
command: start | |
content: |- | |
[Unit] | |
Description=Update Fleet metadata tag | |
Before=fleet.service |
This file contains 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
<!doctype html> | |
<html> | |
<head><link href="http://getconnected.southwestwifi.com/unb/unb.css" rel="stylesheet" type="text/css"/> | |
<script type="text/javascript" src="http://getconnected.southwestwifi.com/unb/jqr44-1.8.3.js"></script> | |
<script type="text/javascript">var r44_btime=new Date();var r44_smu_time=1479876620.446</script> | |
<script type="text/javascript" src="http://getconnected.southwestwifi.com/unb/unb.js"></script> | |
<title>Example Domain</title> |
This file contains 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
''' | |
Live cat of file. Uses mmap to try to be efficient with memory, | |
though reads a byte at a time, so it burns through CPU by hitting the | |
python interpreter loop N times. We could add buffering, but that | |
would just make the code more complex, and who wants that? | |
stdout gets the default buffering, so consider invoking with | |
-u flag/PYTHONBUFFERED environment variable if not writing to | |
a file. |
This file contains 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
''' | |
Live tail of a file. Uses mmap to try to be efficient with memory. | |
Requires fsmonitor: https://github.com/shaurz/fsmonitor | |
...which unfortunately lacks a decent monitor for non-Windows/Linux | |
systems, so burns up CPU unnecessarily on those platforms. Despite its | |
reputation, python makes it surprisingly difficult to write clean and | |
correct code. | |
''' |
This file contains 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
from itertools import chain, ifilter, product | |
# These first few functions are just to sanitize data structures to deal with huamns | |
# providing data in ways that are convenient for their minds. | |
def is_iterable(x): | |
return hasattr(x, '__iter__') | |
def as_config_values(values): |