Skip to content

Instantly share code, notes, and snippets.

Phil Christensen philchristensen

Block or report user

Report or block philchristensen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@philchristensen
philchristensen / eth1.cfg.erb
Created Sep 22, 2014
Sample Ubuntu config to recognize an attached ENI
View eth1.cfg.erb
# /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 Sep 19, 2014
Simpler Git/Gitolite post-update hook for single modules
View simple-update-puppetmaster-hook.git
#!/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 Sep 19, 2014
Script to checkout/refresh per-environment puppet modules
View refresh_puppet_modules.py
#!/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 Aug 1, 2014
Update script for split-environment Puppetmaster module dirs
View refresh-puppet-modules.py
#!/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 Aug 1, 2014
Gitolite post-update script to auto-update a multi-environment puppetmaster
View post-update.sh
#!/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 Jan 13, 2014
Generate nonsense words out of integers
View mnemo.py
# Port of rufus-mnemo to Python
# https://github.com/jmettraux/rufus-mnemo
# Original copyright (c) 2007-2011, John Mettraux, jmettraux@gmail.com
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 Sep 5, 2013
Minimal script for sending/reading from Amazon SQS using Boto/Python.
View sqs.py
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 Jul 23, 2019
A very slow way to serve Django when all you have is CGI
View django.cgi.py
#!/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 Dec 17, 2015
Data file of "funny-sounding" names
View names.txt
Aardwolf
Abdol, Ahmet
Abner Little
Abominable Snowman
Abomination
Abominatrix
Abraxas
Absalom
Absorbing Man
Abyss
@philchristensen
philchristensen / YQL.py
Created Apr 29, 2013
Example of querying the YQL console.
View YQL.py
import restkit
import simplejson
YQL_URL = ('http://query.yahooapis.com', '/v1/public/yql')
value = '11215'
pmr = restkit.Resource(YQL_URL[0])
query = 'SELECT * FROM geo.places WHERE text = "%s"'
qs = value.replace(r'"', r'\"')
You can’t perform that action at this time.