Skip to content

Instantly share code, notes, and snippets.

# If pylibmc exists within requirements, use vendored libmemcached.
if (grep -Eiq "\s*pylibmc" requirements.txt) then
echo "-----> Noticed pylibmc. Bootstrapping libmemcached."
cd .heroku
if [ -d "vendor/lib/sasl2" ]; then
export LIBMEMCACHED=$(pwd)/vendor
else
# Download and extract libmemcached into target vendor directory.
curl -s -L -o tmp-libmemcached.tar.gz $VENDORED_MEMCACHED
@bennylope
bennylope / ansible.yml
Created April 30, 2014 00:35
Deployment w/ Capistrano style deployments with Ansible & Capistrano
---
- name: Deploy new site release
user: deployer
hosts: all
tasks:
- name: Fetch repo updates
git: >
repo=git@github.com:my/repo.git
@bennylope
bennylope / djcasing.py
Created April 16, 2014 00:12
Apply the `case_insenstive` Django view decorator if you have URLs which should match regardless of case, but you don't want those URLs hanging out there when a user visits.
import string
from django.http import HttpResponseRedirect, HttpResponsePermanentRedirect
def case_insensitive(func, case='lower', code=301):
"""
Django view function decorator which can enforce the case of a URL path by
redirecting to the properly cased URL. This *allows* for case insensitive
matches while ensuring that only a commonly cased-URL is used and seen.
@bennylope
bennylope / custom_backends.py
Created March 11, 2014 20:32
Extending Django Organizations backends. Use mixin custom functionality to override default backends using your own application. This example takes an optional `connection` argument and passes it to `send_mail`.
from organizations.backends.defaults import RegistrationBackend, InvitationBackend
class SendMailMixin(object):
def _send_email(self, user, subject_template, body_template,
sender=None, connection=None, **kwargs):
"""Utility method for sending emails to new users"""
if sender:
from_email = "%s %s <%s>" % (sender.first_name, sender.last_name,

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

Dear Sir or Madam,

I have continued to read about the project and I have found some problems in the most recent study by Davenport.

Please note their first assumption on page 3 of the report. It reads as follows: "All Non-Ballpark (i.e. Retail, Residential, Hotel, Office, Parking, etc.) improvements will be privately financed by the Developer." Underneath this, they repeat, underline, and emphasize their first assumption: "No allowances have been made with respect to development incentives."

Their second assumption contains the first mistake made in the compilation of their report. They appear to have misunderstood the 2009 ERA report. Davenport's study states:

"In conducting our analysis, Davenport has extrapolated the following assumptions from the original 2009 Era Report:

@bennylope
bennylope / gist:7662274
Created November 26, 2013 17:19
Convert shapefiles to SQL and import into an existing, named PostgreSQL database with PostGIS extention already installed.
for SHAPEFILE in $(find . -name "*.shp")
do
BASENAME=$(basename $SHAPEFILE .shp)
DIRNAME=$(dirname $SHAPEFILE)
SQLFILE="${BASENAME}.sql"
shp2pgsql -W UTF-8 $SHAPEFILE $BASENAME > "${DIRNAME}/${BASENAME}.sql"
psql -d richmond -f "${DIRNAME}/${BASENAME}.sql"
done
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
@bennylope
bennylope / managers.py
Created September 18, 2013 21:41
Manager class example for working with generic keys. Keep content type lookups inside the manager.
from django.db import models
from django.contrib.contenttypes.models import ContentType
class BookmarkManager(models.Manager):
def _lookup_kwargs(self, **kwargs):
owner = kwargs.pop('owner', None)
if owner:
owner_type = ContentType.objects.get_for_model(owner)