Skip to content

Instantly share code, notes, and snippets.

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)) {
@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) {
@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 / 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 / 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 / mass-commonwealth-connect.json
Last active September 30, 2015 01:14
Massachusetts Service Requests VizWit config
{
"version": "1",
"header": {
"title": "Improve Detroit: Submitted Issues",
"description": "This data set reflects parking violations reported by authorized agencies in Philadelphia. The data represented below is a sample of parking violations occurring between 2012-2015 with license plate numbers anonymized for privacy.",
"navigation": [
{
"label": "Download",
"url": "https://data.phila.gov/api/views/3bxz-a5sb/rows.csv?accessType=DOWNLOAD&bom=true"
}
{
"version": "1",
"header": {
"title": "Improve Detroit: Submitted Issues",
"description": "This data set reflects parking violations reported by authorized agencies in Philadelphia. The data represented below is a sample of parking violations occurring between 2012-2015 with license plate numbers anonymized for privacy.",
"navigation": [
{
"label": "Download",
"url": "https://data.phila.gov/api/views/3bxz-a5sb/rows.csv?accessType=DOWNLOAD&bom=true"
}
{
"version": "2",
"header": {
"title": "Business Licenses in Chicago",
"description": "Business licenses issued by the Department of Business Affairs and Consumer Protection in the City of Chicago from 2002 to the present. January 1, 2006 to present. Data is updated daily.",
"navigation": [
{
"label": "Download",
"url": "https://data.cityofchicago.org/api/views/r5kz-chrr/rows.csv?accessType=DOWNLOAD&bom=true"
}
@timwis
timwis / parking-violations.json
Last active September 26, 2015 01:03
Parking Violations Full width
{
"version": "1",
"header": {
"title": "Parking Violations",
"description": "This data set reflects parking violations reported by authorized agencies in Philadelphia. The data represented below is a sample of parking violations occurring between 2012-2015 with license plate numbers anonymized for privacy.",
"navigation": [
{
"label": "Download",
"url": "https://data.phila.gov/api/views/3bxz-a5sb/rows.csv?accessType=DOWNLOAD&bom=true"
}
@timwis
timwis / gsheets.json
Last active September 25, 2015 18:32
Google Sheets VizWit testing
{
"version": "1",
"header": {
"title": "Parking Violations",
"description": "This data set reflects parking violations reported by authorized agencies in Philadelphia. The data represented below is a sample of parking violations occurring between 2012-2015 with license plate numbers anonymized for privacy.",
"navigation": [
{
"label": "Download",
"url": "https://data.phila.gov/api/views/3bxz-a5sb/rows.csv?accessType=DOWNLOAD&bom=true"
}