Skip to content

Instantly share code, notes, and snippets.

View douglasgoodwin's full-sized avatar

Doug Goodwin douglasgoodwin

View GitHub Profile
@douglasgoodwin
douglasgoodwin / Measuring the redundancy of text
Last active August 29, 2015 13:57
Some examples of the entropy of text measured with ZLIB
{
"metadata": {
"name": "Measuring the redundancy of text"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@douglasgoodwin
douglasgoodwin / pasteme.sh
Last active August 29, 2015 13:58
launch rodney
#!/bin/bash
# ASSUMPTIONS: you are on the staging server and want to build and run it
# first -- create a file called /var/www/envs/reqs.txt and paste the stuff below into it.
# then:
cd /var/www/envs/ ; rm -Rf rodney ;
virtualenv rodney ; cd rodney/ ; source bin/activate ;
virtualenv --relocatable . ;
pip install -U --force-reinstall --no-deps --ignore-installed -r ../reqs.txt ;
{
"metadata": {
"name": "",
"signature": "sha256:4c29a1ff7ca0f7527fdf8246baed59e51d769e2a4e8365475b522e91736e250c"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="lt-ie9"> <![endif]-->
<!--[if gt IE 8]> <html> <![endif]-->
<head>
@douglasgoodwin
douglasgoodwin / _getclicks(campaign_id=4)
Last active August 29, 2015 14:02
Peeps in the house
from rodney.campaign import Campaign, Click
query=Click.query
myc=query.filter(campaign_id=6).all()
import datetime
print "| click_id | UTC time | blogger_id | campaign_id | job_id | url |"
print "| --- | --- | --- | --- | --- | --- |"
for c in myc:
clickdict = c.to_dict()
@douglasgoodwin
douglasgoodwin / workshop_1.json
Created June 28, 2014 00:44
workshop gist for nbviewer
{
"metadata": {
"name": "",
"signature": "sha256:e60fd5dd6e149c76a21fd2cb0f4d59f091ed8c2c7a6e713e79df1ef3a729d924"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@douglasgoodwin
douglasgoodwin / qrtest.py
Created July 1, 2014 20:22
Batch QR codes
import qrcode
qr = qrcode.QRCode(
version=5,
error_correction=qrcode.constants.ERROR_CORRECT_M,
box_size=10,
border=2,
)
link = 'http://qr.metro.net/stops/10222/'
@douglasgoodwin
douglasgoodwin / qrcode_gen.py
Last active August 29, 2015 14:04
Quick QRcode generator that checks to see if the URL is valid before creating the image
import qrcode
import human_curl as hurl
urls="""http://qr.metro.net/about/gwc/
http://qr.metro.net/about/sba/
http://qr.metro.net/about/wes/
http://qr.metro.net/bikes/bikes-metro/
http://qr.metro.net/news/media-kits/expo-media/
http://qr.metro.net/projects/
http://qr.metro.net/projects/30-10/
#!/usr/bin/env bash
POSTGIS_SQL_PATH=`pg_config --sharedir`/contrib/postgis-2.1
createdb -E UTF8 template_postgis # Create the template spatial database.
createlang -d template_postgis plpgsql # Adding PLPGSQL language support.
psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis';"
psql -d template_postgis -f $POSTGIS_SQL_PATH/postgis.sql # Loading the PostGIS SQL routines
psql -d template_postgis -f $POSTGIS_SQL_PATH/spatial_ref_sys.sql
psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;" # Enabling users to alter spatial tables.
psql -d template_postgis -c "GRANT ALL ON geography_columns TO PUBLIC;"
psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
@douglasgoodwin
douglasgoodwin / maps.json
Created December 2, 2014 18:27
Output from the script at http://www.metro.net/api/service/maps/ now includes order
{
version: 1408473258,
servicetypes: [
{
services: [
{
services: [
],
shortname: "Owl Service",