Skip to content

Instantly share code, notes, and snippets.

View schwuk's full-sized avatar

David Murphy schwuk

View GitHub Profile
@schwuk
schwuk / lp2pt
Created August 10, 2010 13:40
Simple script to slurp bugs from a Launchpad project into Pivotal Tracker stories.
#! /usr/bin/python
"""
Simple script to slurp bugs from a Launchpad project into Pivotal Tracker
stories.
Also useful as an example of using launchpadlib and pytracker.
"""
import sys
@schwuk
schwuk / manage.py
Created April 17, 2012 12:39
Django manage.py for split settings.
#!/usr/bin/env python
import os
import sys
from django.core.management import execute_manager
PRODUCTION = 'production'
DEVELOPMENT = 'development'
ENVIRONMENTS = [
@schwuk
schwuk / forms.py
Created May 18, 2012 13:30
Including Email in the Django UserCreationForm
from django.forms import EmailField
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
class UserCreationForm(UserCreationForm):
email = EmailField(label=_("Email address"), required=True,
@schwuk
schwuk / Preferences.sublime-settings
Created November 8, 2012 15:23
Sublime Text 2 user preferences
// Settings in here override those in "Default/Preferences.sublime-settings", and
// are overridden in turn by file type specific settings.
{
"font_face": "Ubuntu Mono",
"font_size": 10,
"rulers": [80],
"translate_tabs_to_spaces": true,
"dictionary": "Packages/Language - English/en_GB.dic",
"draw_minimap_border": true,
"highlight_line": true,
@schwuk
schwuk / gist:4168007
Created November 29, 2012 10:15
Hubot IRC + Jenkins configuration
HUBOT_IRC_NICK=hubot_test
HUBOT_IRC_PASSWORD=[redacted]
HUBOT_IRC_PORT=[redacted]
HUBOT_IRC_ROOMS=[redacted]
HUBOT_IRC_SERVER=[redacted]
HUBOT_IRC_SERVER_FAKE_SSL=yes
HUBOT_IRC_USESSL=yes
HUBOT_JENKINS_AUTH=[redacted]
HUBOT_JENKINS_URL=[redacted]
HUBOT_PORT=6697
@schwuk
schwuk / flatpage_mixin.py
Last active September 23, 2017 20:44
Django class-based view(CBV) mixin to include flatpage content in the context.
from django.contrib.flatpages.models import FlatPage
class FlatPageMixin(object):
"""
Retrieves the FlatPage object for the specified url, and includes it in the
context.
If no url is specified, request.path is used.
"""
@schwuk
schwuk / plexmediaserver
Created August 29, 2013 10:24
UFW Application Profile for Plex Media Server
[plexmediaserver]
title=Plex Media Server
description=The Plex Media Server is smart software that makes playing Movies, TV Shows and other media on your computer simple
ports=32400/tcp|1900/udp|32469/udp|5353/udp
@schwuk
schwuk / post-receive
Created September 10, 2013 16:02
Git post-receive hook for deploying/updating applications (using gitolite, make, and upstart).
#!/bin/sh
APP_NAME=foo
mkdir -p /srv/$APP_NAME
GIT_WORK_TREE=/srv/$APP_NAMEs GIT_DIR=/var/lib/git/repositories/$APP_NAME.git git reset --hard
sudo /bin/chown -R $APP_NAME:$APP_NAME /srv/$APP_NAME
sudo /bin/chmod -R g+w /srv/$APP_NAME
sudo /sbin/status $APP_NAME | grep "^$APP_NAME start" > /dev/null 2>&1
@schwuk
schwuk / Vagrantfile
Created January 30, 2014 14:58
Vagrantfile that installs the latest version of Puppet into the official Ubuntu 12.04 Vagrant image. Also opens up port 5000 (default Foreman port).
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
$script = <<SCRIPT
INITIAL_PROVISION=/var/cache/initial_provision
DISTRIB_CODENAME=$(lsb_release --codename --short)
DEB="puppetlabs-release-${DISTRIB_CODENAME}.deb"
@schwuk
schwuk / describe_csv.py
Created February 25, 2014 09:05
A quick'n'dirty script to describe a CSV file - outputs the header for each column and the maximum width of that column.
#! /usr/bin/env python
import csv
import sys
with open(sys.argv[1], 'rb') as csvfile:
reader = csv.reader(csvfile, delimiter=',', quotechar='"')
header = reader.next()
columns = []
for row in reader:
for i, v in enumerate(row):
_length = len(v)