Skip to content

Instantly share code, notes, and snippets.

winhamwr /
Created Dec 10, 2013
Script to check the status of ipsec tunnels and refresh them if they're down. This should be run from cron every minute. To add monitoring on a tunnel, add a commented-out `monitor` line with the IP and port to use for establishing connection status. eg. `#monitor 9898` Adapted from a script posted by user "c b" on Strongswan [issu…
function main()
monitor_from_file $*
function monitor_vpn_ip_port()
local CONN_NAME=$1
winhamwr /
Created Jun 4, 2012
Creating a repeatable, dynamic site to site VPN with OpenSwan on Ubuntu 10.04 from Amazon EC2

Creating a dynamic site-to-site VPN with OpenSwan on Ubuntu 10.04 on EC2

Wes Winham

There are many tutorials floating around the web that almost get you a dynamic VPN in EC2. The goal of this tutorial is to be a one-stop-shop for this specific setup.

winhamwr / celery task using wait()
Created Mar 12, 2010
celery task using wait()
View celery task using wait()
def build_document_pdf(document, realtime=False, timeout=None, watermark=True):
Builds and caches a PDF copy of this document.
If ``realtime`` is True, returns the URL to the PDF. Otherwise, the PDF is
generated as asynchronously in the background.
if not timeout:
timeout = print_settings.PRINTING_TIMEOUT
pdf_generator = DocumentPdfGenerator()
winhamwr / kegbot.conf
Created Jan 10, 2011
supervisord configuration for kegbot
View kegbot.conf
winhamwr / celeryd_rotate
Created May 17, 2010
logrotate.d configuration for celery
View celeryd_rotate
/var/log/celery/*.log {
rotate 52
winhamwr / jquery.wymeditor.embed.js
Created Jun 19, 2012
WYMeditor embed plugin with video/source support
View jquery.wymeditor.embed.js
* WYMeditor : what you see is What You Mean web-based editor
* Copyright (c) 2005 - 2009 Jean-Francois Hovinne,
* Dual licensed under the MIT (MIT-license.txt)
* and GPL (GPL-license.txt) licenses.
* For further information visit:
* File Name:
winhamwr / wym_autosave.js
Created Nov 1, 2011
Javascript to do autosave on a form using WYMeditor
View wym_autosave.js
Automatically saves a policy every REFRESH milliseconds through AJAX,
but only when the .autosave form has changed. To use, add the class autosave
to your form.
Note: REFRESH must always be bigger than SAVE_TIMEOUT, otherwise a broken
save will cause deadlock for pending.
function processJson(data) {
winhamwr /
Created May 17, 2012
Celery base task that adds some niceties for longish-running or singleton jobs.
Celery base task aimed at longish-running jobs that return a result.
``AwesomeResultTask`` adds thundering herd avoidance, result caching, progress
reporting, error fallback and JSON encoding of results.
from __future__ import division
import logging
import simplejson
winhamwr /
Created Oct 23, 2013
Bash script to wait until a vagrant box is ready
#! /bin/bash
# Sleep until we can successfully SSH into a vagrant box.
# eg. $ wait_for_vagrant devbox && vagrant ssh devbox --command 'cd project && ./ runserver'
# Uses doublinng backoff while waiting
# with_backoff() adapted from
# Retries a command a configurable number of times with backoff.
# The retry count is given by ATTEMPTS (default 5), the initial backoff
winhamwr / Script for creating a personal package repository in ubuntu
Created Feb 26, 2010
Script for creating a personal package repository in ubuntu
View Script for creating a personal package repository in ubuntu
#!/usr/bin/env python
import optparse, subprocess, logging, os, sys, shutil
APT_COMMAND = 'apt-get -o Dpkg::Options::="--force-confnew" -y --force-yes -qq install %s'
def apt_install(app):"Calling: %s" % (APT_COMMAND % app)) % app, shell=True)