Skip to content

Instantly share code, notes, and snippets.

View cameron's full-sized avatar

Cameron Boehmer cameron

  • Empty Vessel
  • Portland, OR
  • 10:50 (UTC -07:00)
View GitHub Profile
#!/usr/bin/env python
'''
Call the function who_wins and pass an array, e.g.:
who_wins([[1,0,1],
[1,2,2],
[1,2,2]])
and it will return 1 or 2, corresponding to a tic-tac-toe
win by either player 1 or player 2 (or, in fact, a triplet
of any repeating character).
#! /usr/bin/env python
import time
LOG = '/tmp/dev_log'
def log_development():
entries = []
while True:
input = raw_input()
@cameron
cameron / gist:3731901
Created September 16, 2012 10:29
Reduce Your Carbon Footprint with Meditation

I can't claim to be a particularly energy-conscious human being. I drive my car infrequently and I try to buy local comestibles, but for purely selfish reasons. I sometimes leave the lights on, and yesterday I noticed that I turn on the faucet to rinse my toothbrush well before I've finished brushing. My point is that I don't think about saving energy a lot, but listen to this...

We humans do a lot of things in the world. Most of the things we do, we do in order to be happy (in a broad sense). Now, it's obvious that all of the things we do have an energy cost: they take time, and we have to eat; they often happen someplace else, so we have to get there; they frequently involve other people, so we have to coordinate and plan; sometimes there are materials involved that require energy to create and acquire. All of that time and movement and activity requires food and gas and electricity. Finally, we get there, do the thing, achieve some happiness (maybe), and start the whole cycle over again. It's continuous,

@cameron
cameron / gist:3736152
Created September 17, 2012 08:21
Fear Makes You Less Human, Love Makes You More

Here's some rough neuroscience: the brain is composed of three regions, each corresponding to a stage of our species' evolution. Let's just say we have three brains: a reptilian brain, a mammalian brain, and a human brain. The reptilian brain generates basic instinctual impulses, the mammalian brain adds emotion and memory into the mix [1] , and the human brain gives us all that make us unique amongst mammals, of which the most commonly discussed feature is our capacity for abstraction and symbolic information processing.

While the entire brain is involved in the experience of fear, it's the limbic system, or the mammalian brain, that triggers a range of physiological and neurological changes when your being perceives a threat. These changes include activation of your sympathetic nervous system, which is hardware dedicated to saving your ass. It slows digestion to save energy and redirects blood to major muscle groups; it draws blood away from the surface of your skin to avoid blood loss in case of injury;

@cameron
cameron / gist:6514484
Created September 10, 2013 19:39
put your pub key on a remote machine
if [ $# -lt 2 ]; then
echo "Usage: $0 <key-file> <host> [<user>]"
return
fi
key="$1"
host="$2"
user="$USER"
if [ $# -eq 3 ]; then
user=$3
@cameron
cameron / sitecustomize.py
Created December 4, 2013 10:05
Launch pdb on runtime exceptions -- put this in site-packages/sitecustomize.py or somesuch.
# auto stop in pdb on noneexceptions
def info(exc_type, value, tb):
# dont do anything for keyboard interrupts or exit signals
if exc_type in (KeyboardInterrupt, SystemExit):
return
if hasattr(sys, 'ps1') or not sys.stderr.isatty():
# we are in interactive mode or we don't have a tty-like
# device, so we call the default hook
sys.__excepthook__(exc_type, value, tb)
else:
@cameron
cameron / docker.sh
Created December 14, 2013 23:53
For those running docker inside a vagrant vm, a shell function that makes it feel native.
# the DOCKER_WRAPPER bit silences the warning that results from running the latest git version
vagrant ssh -c "echo 'DOCKER_WRAPPER'; sudo docker $@" 2>/dev/null | sed '1,/DOCKER_WRAPPER/d'
var floatingButtonDirective = function() {
return {
restrict: 'AE',
scope: {
text: '@'
},
template: '<div class="floating-button">Text: {{ text }}</div>'
};
};
@cameron
cameron / init.sh
Last active August 1, 2017 12:57
initialize a CoreOS vm with the latest docker and DNS service discovery via skydock
This gist is old. Check out http://gijs.github.io/blog/2014/09/09/docker-and-service-discovery/
@cameron
cameron / docker-ssl-cert-generate
Last active February 2, 2023 10:09
Generate self-signed SSL certs for docker client <— HTTPS —> daemon
#! /bin/bash
# HEADS UP! Make sure to use '*' or a valid hostname for the FDQN prompt
echo 01 > ca.srl
openssl genrsa -des3 -out ca-key.pem
openssl req -new -x509 -days 365 -key ca-key.pem -out ca.pem
openssl genrsa -des3 -out server-key.pem
openssl req -new -key server-key.pem -out server.csr