Skip to content

Instantly share code, notes, and snippets.

@bennylope
bennylope / config.py
Created December 17, 2015 15:32
Use Fabric to manage envdir compatible configuration data
"""
Remote environment variable configuration using envdir
This should be set up using a `fabfile/` module rather than
an individual `fabfile.py` file.
$ fab <env> config -- list environment variables (incl. values)
$ fab <env> config.set:DEBUG=False -- set a single variable
$ fab <env> config.set:DEBUG=False,SECRET=jdkjkjk -- set multiple variables
@bennylope
bennylope / envcopy.py
Last active December 18, 2015 15:23
Copy the contents of a Foreman compatible .env file to an envdir compatible configuration directory
#!/usr/bin/env python
"""
Script that copies contents of .env file to envdir compatible folder
:copyright: Ben Lopatin
:license: BSD
"""
import os
import sys
@bennylope
bennylope / generic_csv_exporter_basic.py
Last active December 22, 2015 14:29
A simple way of avoiding duplication in CSV exports. This example takes advantage of Python's `attrgetter` function to get chained attributes using strings like "attr.subattr.subattr".
import csv
from operator import attrgetter
def generic_csv(csvfile, objects, fields):
writer = csv.writer(csvfile, quoting=csv.QUOTE_ALL)
row_headers = fields.keys()
writer.writerow(row_headers)
for obj in objects:
@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)
---
# ^^^ 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 / 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

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:

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:

@bennylope
bennylope / leanpub.sh
Last active January 3, 2016 17:51
A Leanpub API client script
#!/usr/bin/env bash
# Copyright 2016, Ben Lopatin
# Licensed freely to use, modify, and redistribute under GNUGPLv3
APIKEY=$LEANPUB_API_KEY
SLUG=$LEANPUB_SLUG
case "$1" in
preview)