Skip to content

Instantly share code, notes, and snippets.

View calston's full-sized avatar

Colin Alston calston

View GitHub Profile
@calston
calston / gist:2358289
Created April 11, 2012 09:44
Vumi puppet
class vumi-base {
user {"vumi":
home => "/var/praekelt",
ensure => present
}
group {"vumi":
require => user["vumi"],
ensure => present
}
--- HA Proxy config ---
frontend zero-http-in
bind *:8040
default_backend zero-backend
backend zero-backend
server zero_backend1 127.0.0.1:8041 weight 1 check maxconn 500
server zero_backend2 127.0.0.1:8042 weight 1 check maxconn 500
server zero_backend3 127.0.0.1:8043 weight 1 check maxconn 500
@calston
calston / logstash
Created May 6, 2012 06:20
Logstash init script
#! /bin/sh
### BEGIN INIT INFO
# Provides: logstash
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
@calston
calston / gist:2894864
Created June 8, 2012 10:19
backup script
#!/bin/bash
s3cmd="/usr/bin/s3cmd"
for host in `ls /backups`; do
echo "Backing up $host"
$s3cmd sync --delete-removed /backups/$host/ s3://prd-backups/$host/
done
@calston
calston / gist:3697349
Created September 11, 2012 09:59
Iptables ERB
# Allowed ports
<% if has_variable?("open_ports") then %>
<% open_ports.each do |port| -%>
iptables -t filter -A INPUT -p tcp --dport <%= port %> -j ACCEPT
<% end -%>
<% end %>
<% if has_variable?("open_ports_from") then %>
<% open_ports_from.each_pair do |port, host| -%>
iptables -t filter -A INPUT -p tcp --dport <%= port %> -s <%= host %> -j ACCEPT
@calston
calston / readImageStack.py
Created September 26, 2012 14:30
readImageStack
from PIL import Image, ImageOps
from matplotlib import pyplot
import numpy
def readImageStack(filename, w, h):
im = ImageOps.invert(Image.open(filename)).convert('L')
x, y = im.size
blY = y/h
#!/bin/bash
name=$1
mkdir -p $name/manifests
mkdir -p $name/files
mkdir -p $name/templates
echo "class $name {" >> $name/manifests/init.pp
echo "}" >> $name/manifests/init.pp
@calston
calston / zabbixapi.py
Created November 28, 2012 11:36
Add puppet host to Zabbix
#!/usr/bin/python
import urllib, json, httplib, socket, sys, os
def httpRequest(request):
body = json.dumps(request)
headers = {"Content-type": "application/json"}
conn = httplib.HTTPSConnection(host, 443)
URL Count Max Ave Min
/calendar/event/special-k-with-kyleigh-lazarus 1 0.003 0.003 0.003
/post/pistorius-bail-conditions-amended 2 0.004 0.004 0.004
/social-authlogin/facebook/ 1 0.032 0.032 0.032
/fetch-new-comments-ajax/65/2823/0/ 1 0.035 0.035 0.035
/fetch-new-comments-ajax/91/2862/0/ 2 0.039 0.022 0.005
/fetch-new-comments-ajax/32/3417/0/ 4 0.042 0.022 0.005
/fetch-new-comments-ajax/32/3431/0/ 1 0.043 0.043 0.043
/admin/jsi18n/ 3 0.046 0.038 0.027
/fetch-new-comments-ajax/32/3162/0/ 1 0.047 0.047 0.047
@calston
calston / gist:5352673
Created April 10, 2013 07:56
Milestone assignees are semantically confusing
diff --git a/central/projects/models.py b/central/projects/models.py
index a094fca..e99c24d 100644
--- a/central/projects/models.py
+++ b/central/projects/models.py
@@ -130,7 +130,6 @@ class PlanMilestone(models.Model):
created_by_user = models.ForeignKey(User,
related_name='MilestoneCreatedBy')
plan = models.ForeignKey(Plan)
- assignee = models.ForeignKey(User)