Skip to content

Instantly share code, notes, and snippets.

View cbsmith's full-sized avatar

Christopher Smith cbsmith

View GitHub Profile
@cbsmith
cbsmith / cloud-config.yml
Last active September 26, 2016 06:25 — forked from skippy/cloud-config.yml
modifying fleet metadata (from aws meta-data service) before fleet.service start; this is a proof of concept (but it works!)
#cloud-config
---
coreos:
units:
- name: update-fleet-metadata.service
command: start
content: |-
[Unit]
Description=Update Fleet metadata tag
Before=fleet.service
"""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)
@cbsmith
cbsmith / awscli_functions.sh
Created December 15, 2015 05:13
A handy collection of bash functions to make the aws cli a bit more usable
# 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[]')
@cbsmith
cbsmith / compatible_message.proto
Last active January 16, 2016 05:44
A forward compatible reworking of Heka Message
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";
@cbsmith
cbsmith / message.proto
Last active January 16, 2016 05:43
Proposed change to Heka message format.
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";
@cbsmith
cbsmith / better_random.py
Last active January 4, 2016 10:19
My thoughts on enhancements to make random support a broader set of iterables.
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)
@cbsmith
cbsmith / endian.cpp
Last active December 30, 2015 13:29
My demonstration of how byte swap can still be useful despite http://commandcenter.blogspot.com/2012/04/byte-order-fallacy.html
// -*- compile-command: "g++ -O3 -march=native -std=c++11 -Wall -Werror endian.cpp -o endian" -*-
#include <fstream>
#include <ostream>
#include <istream>
#include <cstdint>
#include <algorithm>
#include <cassert>
#include <string>
#include <vector>
#include <limits>
@cbsmith
cbsmith / keybase.md
Created December 27, 2015 22:19
Proving who I am to the world...

Keybase proof

I hereby claim:

  • I am cbsmith on github.
  • I am cbsmith (https://keybase.io/cbsmith) on keybase.
  • I have a public key ASAP-aANv7TdH9M92MiL7AmjcQmFCR4m9bNymFF-1y6LIgo

To claim this, I am signing this object:

@cbsmith
cbsmith / test.cpp
Last active December 23, 2015 21:19
Attempt to create an operator||=
// -*- compile-command: "clang++ -Weverything -Wno-c++98-compat -ggdb -o test -std=c++11 -stdlib=libc++ test.cpp" -*-
#include <iostream>
#include <type_traits>
template <typename T, typename U, bool boolable = std::is_convertible<T,bool>::value, bool assignable = std::is_assignable<T, U>::value >
struct or_assign_helper;
template <typename T, typename U>
struct or_assign_helper<T, U, true, true> {
@cbsmith
cbsmith / test.cpp
Last active December 23, 2015 20:29
C++11 lambda sorcery
// -*- compile-command: "clang++ -ggdb -o test -std=c++11 -stdlib=libc++ test.cpp" -*-
#include <iostream>
float add(float x, float y) {
return x+y;
}
auto add_fourty_two = +[](float x) { return add(x, 42); };
auto add_pie_and_fourty_two = +[]() { return add_fourty_two(3.1415926); };