Skip to content

Instantly share code, notes, and snippets.

View philchristensen's full-sized avatar

Phil Christensen philchristensen

View GitHub Profile
@philchristensen
philchristensen / anti-spam-autoresponse.txt
Created August 7, 2011 14:59
Anti-Spam Auto-Response
Your post advocates a
( ) technical ( ) legislative (X) market-based (X) vigilante ( ) form-based
approach to fighting spam. Your idea will not work. Here is why it won't work. (One or more of the following may apply to your particular idea, and it may have other flaws which used to vary from state to state before a bad federal law was passed.)
( ) Spammers can easily use it to harvest email addresses
( ) Mailing lists and other legitimate email uses would be affected
( ) No one will be able to find the guy or collect the money
( ) It is defenseless against brute force attacks
@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 / 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
@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 / 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 / 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 / svn-color.py
Created August 10, 2010 20:20
Color-Coded `svn status`

First there was: http://snipplr.com/view/15246/color-coded-svn-status

Then there was: http://snipplr.com/view/16540/color-coded-svn-status-v2

A few days ago, I found a handy script online that colorized the output of SVN status. It worked pretty well, but needed a little polish and a couple of tweaks to make it use more common Python idioms. As I continued to use it and fix bugs and inefficiencies, I ended up replacing nearly every line in the original, but it was still a great starting point.

Additional changes include ANSI word-wrapping, a configurable tab expansion feature (for better code alignment), the 'colorizedSubcommands' sequence so that only applicable commands get colorized, use of proper subprocess module calls so that piping through less will work (for example, try svn-color diff | less -r to see colorized diff output).

To use, stick it somewhere, make executable (`chmod 7

@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']
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'