Skip to content

Instantly share code, notes, and snippets.

View philchristensen's full-sized avatar

Phil Christensen philchristensen

View GitHub Profile
@philchristensen
philchristensen / mdserv
Last active August 29, 2015 14:07 — forked from smoser/mdserv
#!/usr/bin/python
"""
To use this to mimic the EC2 metadata service entirely, run it like:
# where 'eth0' is *some* interface. if i used 'lo:0' i got 5 second or so delays on response.
sudo ifconfig eth0:0 169.254.169.254 netmask 255.255.255.255
sudo ./mdserv 169.254.169.254:80
Then:
wget -q http://169.254.169.254/latest/meta-data/instance-id -O -; echo
curl --silent http://169.254.169.254/latest/meta-data/instance-id ; echo
@philchristensen
philchristensen / eth1.cfg.erb
Created September 22, 2014 15:29
Sample Ubuntu config to recognize an attached ENI
# /etc/network/interfaces.d/eth1.cfg
# The secondary network interface
auto eth1
iface eth1 inet dhcp
address <%= @ipaddress_eth1 %>
netmask <%= @netmask %>
up ip route add default via <%= GATEWAY_ADDRESS %> dev eth1 table out
up ip rule add from <%= @ipaddress_eth1 %>/32 table out
up ip rule add to <%= @ipaddress_eth1 %>/32 table out
up ip route flush cache
@philchristensen
philchristensen / simple-update-puppetmaster-hook.git
Created September 19, 2014 01:49
Simpler Git/Gitolite post-update hook for single modules
#!/bin/bash
branch=$(git rev-parse --symbolic --abbrev-ref $1)
module=$(basename $PWD)
valid=0
if [[ "$module" == "puppet.git" ]]; then
valid=1
modulename="dram"
fi
@philchristensen
philchristensen / refresh_puppet_modules.py
Created September 19, 2014 01:09
Script to checkout/refresh per-environment puppet modules
#!/usr/bin/env python
import sys
import os
import os.path
import logging
import subprocess
ENV_DIR = "environments"
MODULES = ['core', 'client']
@philchristensen
philchristensen / refresh-puppet-modules.py
Created August 1, 2014 16:22
Update script for split-environment Puppetmaster module dirs
#!/usr/bin/env python
import sys
import os
import os.path
import logging
import subprocess
ENV_DIR = "environments"
MODULES = ['core', 'site']
@philchristensen
philchristensen / post-update.sh
Created August 1, 2014 16:20
Gitolite post-update script to auto-update a multi-environment puppetmaster
#!/bin/bash
branch=$(git rev-parse --symbolic --abbrev-ref $1)
module=$(basename $PWD)
valid=0
for modname in site-puppet.git core-puppet.git; do
if [[ "$module" == "$modname" ]]; then
valid=1
fi
@philchristensen
philchristensen / mnemo.py
Created January 13, 2014 01:12
Generate nonsense words out of integers
# Port of rufus-mnemo to Python
# https://github.com/jmettraux/rufus-mnemo
# Original copyright (c) 2007-2011, John Mettraux, [email protected]
consonants = list('bdghjkmnprstz')
vowels = list('aeiou')
syllables = [c + v for c in consonants for v in vowels] + ['wa', 'wo', 'ya', 'yo', 'yu']
negative = 'wi'
replacements = [
@philchristensen
philchristensen / sqs.py
Created September 5, 2013 16:28
Minimal script for sending/reading from Amazon SQS using Boto/Python.
conf = {
"sqs-access-key": "",
"sqs-secret-key": "",
"sqs-queue-name": "",
"sqs-region": "us-east-1",
"sqs-path": "sqssend"
}
import boto.sqs
conn = boto.sqs.connect_to_region(
@philchristensen
philchristensen / django.cgi.py
Last active March 13, 2022 00:53
A very slow way to serve Django when all you have is CGI
#!/usr/bin/env python
# encoding: utf-8
"""
django.cgi
A simple cgi script which uses the django WSGI to serve requests.
Code copy/pasted from PEP-0333 and then tweaked to serve django.
http://www.python.org/dev/peps/pep-0333/#the-server-gateway-side
@philchristensen
philchristensen / names.txt
Last active May 22, 2022 06:37
Data file of "funny-sounding" names
Aardwolf
Abdol, Ahmet
Abner Little
Abominable Snowman
Abomination
Abominatrix
Abraxas
Absalom
Absorbing Man
Abyss