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 / ratchetscrollfix.css
Created January 8, 2013 19:20
Ratchet/junior leverages `-webkit-overflow-scrolling` but seems to have a bug on Safari Mobile when you drag the header and then try to scroll the body. This CSS reverts to standard scrolling with a fixed-position header.
/* Fix scrolling */
body, .content, #app-container { position: static; } /* #app-container is for junior */
.content { -webkit-overflow-scrolling: auto; }
header + .content { padding-top: 44px; }
header + .content-padded { padding-top: 55px; }
.bar-title .title + [class*="button"]:last-child { top: 5px; } /* From ratchet.css, overridden by junior.css */
@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);
}
@timwis
timwis / gist:6539220
Last active December 22, 2015 22:19
Tax balance API data structure
/**
* /taxbalances/883309000
*/
{
status: "success",
data: {
property: {
account_number: "883309000"
},
balances: [
@timwis
timwis / gist:7882901
Created December 9, 2013 23:17
Convert between 4326 and 2272 with Proj4js. Written by @davewalk. Uses http://trac.osgeo.org/proj4js/
convertCoordinates: function (coords) {
Proj4js.defs['EPSG:2272'] = '+proj=lcc +lat_1=40.96666666666667 +lat_2=39.93333333333333 +lat_0=39.33333333333334 +lon_0=-77.75 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192 +no_defs';
var source = new Proj4js.Proj('EPSG:4326');
var dest = new Proj4js.Proj('EPSG:2272');
var point = new Proj4js.Point(-75.163789, 39.952335);
Proj4js.transform(source, dest, point);
return point;
}
@timwis
timwis / gist:d4ce0ffb3f2f616ef892
Created March 5, 2015 19:06
Embed Open Budget
<iframe src="http://www.phila.gov/openbudget/" width="100%" height="700" frameborder="0"></iframe>
@timwis
timwis / gist:8ab6607d8f744e70437c
Created April 23, 2015 17:58
bike share swagger
swagger: "2.0"
info:
description: |
Locations of Indego bike share stations in Philadelphia
**Endpoint:** http://api.phila.gov/bike-share-stations/v1
version: "1.0"
title: Bike Share Stations
@timwis
timwis / gist:f24586ace7e43d6c6145
Created May 3, 2015 23:34
Election results kimono modification script
function transform(data) {
var newCandidates = [];
var raceIndex = -1; // start at -1 since first index is 0
// Loop through candidates
data.results.candidates.forEach(function(row, index) {
if(row.candidate === 'Candidate Name') {
raceIndex++;
} else {
row.race = data.results.races[raceIndex].race;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.