Skip to content

Instantly share code, notes, and snippets.

View philchristensen's full-sized avatar

Phil Christensen philchristensen

View GitHub Profile
bijaz
stilgar
othyem
farok
kaitan
caladan
tabr
fedaykin
korba
tlielax
@philchristensen
philchristensen / r2sync.sh
Created March 24, 2017 16:13
RSync between two remote hosts
# r2sync stage-jira /var/lib/jira/ prod-jira /var/lib/jira
ssh -R localhost:50000:$1:22 $3 'rsync -e "ssh -p 50000" -vuar $2 localhost:$4'
@philchristensen
philchristensen / homers-revenge-list.md
Last active February 9, 2016 17:55
Homer's Revenge List
  • Bill of Rights
  • Grandpa
  • fat free lard
  • gravity
  • Emmys
  • Darwin
  • H2-WHOA!
  • Billy Crystal
  • God
  • Soloflex
@philchristensen
philchristensen / reload.sh
Created October 19, 2015 17:50
Execute docker commands for particular containers
#!/bin/bash -x
WEBAPPS=$(docker ps | grep "philchristensen/insite:latest" | awk '{print $1}')
WORKERS=$(docker ps | grep "philchristensen/insite:worker" | awk '{print $1}')
BEATER=$(docker ps | grep "philchristensen/insite:beat" | awk '{print $1}')
find /opt/insite-web -name '*.pyc' -delete
echo "$WEBAPPS" | xargs -I ID docker exec ID pip install -r requirements.txt
date > /opt/insite-web/reload
@philchristensen
philchristensen / DPColorPickerView.m
Created July 28, 2015 18:45
Draw a color wheel in Objective-C
//
// DPColorPickerView.m
// DMXPerformer
//
// Created by Phil Christensen on 4/14/13.
// Copyright (c) 2013 bubblehouse. All rights reserved.
//
#import "DPColorPickerView.h"
#import "DPColorGrabberView.h"
@philchristensen
philchristensen / docker_names.py
Created July 13, 2015 16:56
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 = [
"admiring",
"adoring",
@philchristensen
philchristensen / java.pp
Created May 29, 2015 19:06
Puppet Java manifest
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
philchristensen / xaz_host.rb
Created April 8, 2015 21:11
Custom puppet function for finding sibling autoscaling group instances in other AZs
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] = Aws::Credentials.new(
"AKIAJSUKG23H6XC3FE3A",
"byQczPLjJwDMCcYjtnKgPS/7NfM1D0XpuEU9scmt"
@philchristensen
philchristensen / bash_profile.sh
Created March 11, 2015 21:00
Enable ssh-agent automatically on a per-session basis
SSH_ENV="$HOME/.ssh/environment"
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
/usr/bin/ssh-add;
}
@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