Skip to content

Instantly share code, notes, and snippets.

@winhamwr
winhamwr / pr_template.md
Created Apr 30, 2014
PolicyStat's Pull Request Template
View pr_template.md

What does this PR do?

Where should the reviewer start?

How should this be manually tested?

Any background context you want to provide?

Screenshots (if appropriate)

@winhamwr
winhamwr / calc.py
Created Feb 5, 2015
Percentage of active customers using any-site login
View calc.py
from __future__ import division
from django.db.models import Count
system_setting_pks = list(
Customer.objects.annotate(
tenant_count=Count('tenant_set')
).filter(tenant_count__gt=1).values_list('settings__pk', flat=True)
)
num_systems = len(system_setting_pks)
@winhamwr
winhamwr / out.log
Created Feb 23, 2015
berks traceback
View out.log
vagrant up dev
Bringing machine 'dev' up with 'virtualbox' provider...
==> dev: Loading Berkshelf datafile...
==> dev: Sharing cookbooks with VM
==> dev: Couldn't find Cheffile at ./Cheffile.
==> dev: Updating Vagrant's Berkshelf...
The following berks command failed to execute:
/opt/chefdk/bin/berks vendor /home/wes/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150126-5078-1e0wj59-dev --berksfile /home/wes/policystat/workspace/pstat/Berksfile
@winhamwr
winhamwr / exporter.py
Last active Aug 29, 2015
pydocx image handler for resizing images to their displayed size
View exporter.py
import base64
import logging
import cgi
import logging
import os
import posixpath
import re
import subprocess
import time
from tempfile import NamedTemporaryFile
@winhamwr
winhamwr / gist:205450
Created Oct 8, 2009
Celery /etc/init.d script to keep celeryd running
View gist:205450
#!/bin/sh
USER=%(user)s
NAME=celeryd
VIRTUALENV=%(virtualenv_dir)s
PROJECT_ROOT=%(project_root)s
DAEMON=$VIRTUALENV/bin/celeryd
PIDFILE=$PROJECT_ROOT/$NAME.pid
LOGFILE=$PROJECT_ROOT/$NAME.log
@winhamwr
winhamwr / hudson fabric deploy bash script
Created Jan 5, 2010
bash script for use by a hudson job to deploy a project via fabric
View hudson fabric deploy bash script
#!/bin/bash
SSHAGENT=/usr/bin/ssh-agent
SSHAGENTARGS="-s"
PARENT_JOB=pstat_master_unittest
KEY_PATH=$HOME/policystat/fabric/pstat_dev.key
if [ ! -z "$WORKSPACE" ]; then
WORKSPACE=/vol/fs/var/lib/hudson/home/jobs/pstat_master_deploy/workspace
fi
@winhamwr
winhamwr / hudson virtualenv creation
Created Feb 4, 2010
hudson virtualenv creation
View hudson virtualenv creation
#!/bin/bash
# Hosted at: http://gist.github.com/294861
SSHAGENT=/usr/bin/ssh-agent
SSHAGENTARGS="-s"
# Job we're using for deploying the virtualenv
PARENT_JOB=pstat_master_unittest
KEY_PATH=$HOME/policystat/fabric/pstat_dev.key
@winhamwr
winhamwr / gist:309449
Created Feb 20, 2010
fabric stub for getting selenium 2 python bindings to install
View gist:309449
def _install_webdriver(venv_path):
"""
Install/build the python webdriver client. The setup.py is busted, so we have
to do extra work beyond the virtualenv.
See: http://groups.google.com/group/webdriver/browse_thread/thread/f5c3484ab5ae5800/fdae02fa223d00b0
"""
webdriver_dir = os.path.join(venv_path, 'src', 'webdriver')
py_bin = os.path.join(venv_path, 'bin', 'python')
with cd(webdriver_dir):
@winhamwr
winhamwr / hacked setup.py for selenium2
Created Feb 21, 2010
working-ish setup.py for development
View hacked setup.py for selenium2
#!/usr/bin/env python
# Copyright 2008-2009 WebDriver committers
# Copyright 2008-2009 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@winhamwr
winhamwr / virtualenv.txt
Created Feb 24, 2010 — forked from hugs/virtualenv.txt
Now with virtualenvwrapper goodness
View virtualenv.txt
# Install virtualenv
sudo pip install virtualenv
# Install virtualenvwrapper
sudo pip install virtualenvwrapper
# Configure virtualenvwrapper
echo "export WORKON_HOME=$HOME/.virtualenvs" | tee -a ~/.bashrc
echo "source /usr/local/bin/virtualenvwrapper_bashrc" | tee -a ~/.bashrc
source ~/.bashrc