Skip to content

Instantly share code, notes, and snippets.

@timwis
timwis / gdrivecms.php
Created September 19, 2012 23:48
GDriveCMS allows you to use Google Docs' familiar interface for adding content to a mobile-optimized web page. Simply create a Google Document with whatever content you want, publish it to the web (in the File menu), and render it through this script.
<?php
/* GDriveCRM
Created by Tim Wisniewski (timwis.com)
GDriveCMS allows you to use Google Docs' familiar interface for adding content to a mobile-optimized web page.
Simply create a Google Document with whatever content you want, publish it to the web (in the File menu),
and render it through this script.
1. Create a document in Google Drive (Google Docs)
2. Go to File > Publish to the web
3. Click Start Publishing & check Automatically republish
4. Grab the document link (URL) in that dialog
@timwis
timwis / crime-incidents.v2.json
Last active October 23, 2015 17:49
Philadelphia Crime Incidents VizWit Config
{
"version": "2",
"header": {
"title": "Police Department",
"navigation": [
{
"label": "Download",
"url": "https://www.opendataphilly.org/dataset/crime-incidents"
}
]
@timwis
timwis / fire-statistics.json
Last active October 25, 2015 17:24
Fire Statistics VizWit
{
"version": "2",
"header": {
"title": "Fire Department"
},
"cards": [
{
"x": 0,
"y": 0,
"width": 12,
@timwis
timwis / prisons.json
Last active November 4, 2015 11:42
Prisons VizWit Config
{
"version": "2",
"header": {
"title": "Philadelphia Prison System",
"description": "Mission: To provide a secure correctional environment that adequately detains persons accused or convicted of illegal acts; to provide programs, services, and supervision in a safe, lawful, clean, humane environment; and to prepare incarcerated persons for reentry into society in a frame of mind that will facilitate their becoming law-abiding citizens."
},
"cards": [
{
"x": 0,
"y": 0,
@timwis
timwis / join.js
Created November 11, 2015 17:31
Join 2 JSON objects on common property in JavaScript
$.when(
$.getJSON('https://data.phila.gov/resource/bbgf-pidf.geojson'),
$.getJSON('https://data.phila.gov/resource/r24g-zx3n.json?%24select=count(*)%20as%20value%2C%20%3A%40computed_region_bbgf_pidf%20as%20label&%24group=%3A%40computed_region_bbgf_pidf&%24order=value%20desc')
).done(function(responseGeojson, responseData) {
var data = responseData[0]
var geojson = responseGeojson[0]
// Create hash table for easy reference
var dataHash = {}
data.forEach(function(item) {
var detectType = function(sample) {
if(moment(sample, moment.ISO_8601, true).isValid()) {
return 'datetime'
} else if(moment(sample, 'YYYY-MM-DD', true).isValid()) {
return 'date'
} else if(moment(sample, 'X', true).isValid()) {
return 'timestamp'
} else if( ! isNaN(sample) && sample.indexOf('.') !== -1) {
return 'float'
} else if( ! isNaN(sample)) {
import requests
import requests_mock
import pprint
pp = pprint.PrettyPrinter(indent=4)
session = requests.Session()
adapter = requests_mock.Adapter()
session.mount('mock', adapter)
@timwis
timwis / README.md
Created December 3, 2015 17:20
Fire Stats Sheet2

README is empty

@timwis
timwis / gist:5554718
Last active December 17, 2015 04:59
Integrate filepicker.io with Wordpress' Jetpack contact form plugin

Installation

  1. Go to Plugins > Editor
  2. Select Jetpack by Wordpress.com at the top-right
  3. Select jetpack/modules/contact-form.php from the list of files on the right (changes the directory)
  4. Select jetpack/modules/contact-form/grunion-contact-form.php from the list of files on the right
  5. Search case 'date'
  6. Below that case and before default, add the following case, replacing ***API-KEY-GOES-HERE*** with your filepicker.io API key, and adding any other filepicker.io rules (mime types, file size, etc.) as attributes
@timwis
timwis / gist:5786397
Created June 15, 2013 01:31
ATV Election Data Modifier
<?php
ini_set('memory_limit', '-1');
define("FILE_IN", "2012_PRIMARY_SPECIAL.txt");
define("FILE_OUT", "2012_PRIMARY_SPECIAL_mod.csv");
define("FILE_IN_DELIMITER", "\t");
error_reporting(E_ERROR);
if( ($file = fopen(FILE_IN, 'r')) === FALSE ) {
die('Unable to open file ' . FILE_IN);
}