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 /
Created Aug 1, 2014
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 /
Created Aug 1, 2014
Gitolite post-update script to auto-update a multi-environment puppetmaster
branch=$(git rev-parse --symbolic --abbrev-ref $1)
module=$(basename $PWD)
for modname in site-puppet.git core-puppet.git; do
if [[ "$module" == "$modname" ]]; then
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
branch=$(git rev-parse --symbolic --abbrev-ref $1)
module=$(basename $PWD)
if [[ "$module" == "puppet.git" ]]; then
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
View mdserv
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 netmask
sudo ./mdserv
wget -q -O -; echo
curl --silent ; echo
philchristensen /
Created Mar 11, 2015
Enable ssh-agent automatically on a per-session basis
function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
philchristensen / xaz_host.rb
Created Apr 8, 2015
Custom puppet function for finding sibling autoscaling group instances in other AZs
View xaz_host.rb
require 'aws-sdk'
module Puppet::Parser::Functions
newfunction(:xaz_host, :type => :rvalue) do |args|
current_az = lookupvar('ec2_placement_availability_zone')
asg_prefix, domain = args
Aws.config[:credentials] =
philchristensen / java.pp
Created May 29, 2015
Puppet Java manifest
View java.pp
exec { "accept-oracle-license":
command => "/bin/echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections",
unless => "/usr/bin/debconf-get-selections | /bin/grep shared/accepted-oracle-license-v1-1"
apt::ppa { "ppa:webupd8team/java": }
ensure_packages(['oracle-java7-installer', 'tomcat7'], {
require => Apt::Ppa['ppa:webupd8team/java']
philchristensen /
Created Jul 13, 2015
Generate random Docker-style names.
import random
def get_random_name():
index = random.randint(0, len(adjectives) - 1)
jndex = random.randint(0, len(names) - 1)
return adjectives[index] + ' ' + names[jndex]
adjectives = [
philchristensen / DPColorPickerView.m
Created Jul 28, 2015
Draw a color wheel in Objective-C
View DPColorPickerView.m
// DPColorPickerView.m
// DMXPerformer
// Created by Phil Christensen on 4/14/13.
// Copyright (c) 2013 bubblehouse. All rights reserved.
#import "DPColorPickerView.h"
#import "DPColorGrabberView.h"
You can’t perform that action at this time.