Skip to content

Instantly share code, notes, and snippets.

KeyValDropdownEditor.prototype.prepare = function () {
Handsontable.editors.BaseEditor.prototype.prepare.apply(this, arguments) // call parent method
var source = this.cellProperties.source
var options
Handsontable.Dom.empty(this.select)
if (typeof source === 'function') {
options = source(this.row, this.col, this.prop)
@timwis
timwis / crime-incidents.json
Last active January 8, 2016 18:01
Philly part 2 crime incidents VizWit
{
"version": "2",
"header": {
"title": "VizWit",
"description": "Lorem ipsum dolor sit amet"
},
"cards": [
{
"x": 0,
"y": 0,
@timwis
timwis / test.json
Last active January 17, 2016 20:22
vizwit provider test
{
"version": "2",
"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 / chicago-crimes.v2.json
Last active January 17, 2016 21:06 — forked from marks/chicago-crimes.v2.json
Chicago crime incidents VizWit configuration
{
"version": "2",
"header": {
"title": "Crime Incidents in Chicago",
"description": "This dataset reflects reported incidents of crime (with the exception of murders where data exists for each victim) that occurred in the City of Chicago from 2001 to present, minus the most recent seven days. Data is extracted from the Chicago Police Department's CLEAR (Citizen Law Enforcement Analysis and Reporting) system. In order to protect the privacy of crime victims, addresses are shown at the block level only and specific locations are not identified.",
"navigation": [{
"label": "Download",
"url": "https://data.cityofchicago.org/api/views/ijzp-q8t2/rows.csv?accessType=DOWNLOAD&bom=true"
}]
},
@timwis
timwis / default.html
Created January 27, 2016 12:30
How to use rows and columns in a Jekyll page
<!DOCTYPE html>
<html>
<body>
<div class="container">
{% assign rows = content | split:"@row" %}
{% for row in rows %}
<div class="row" id="row-{{ forloop.index }}">
{% assign columns = row | split:"@column" %}
@timwis
timwis / index.js
Last active February 10, 2016 14:34
requirebin sketch
var Model = require('ampersand-model')
var View = require('ampersand-view')
var FormTemplate = document.getElementById('form-template').innerHTML
var FormModel = Model.extend({
props: {
'firstName': 'string',
'lastName': 'string'
}
@timwis
timwis / index.js
Last active February 20, 2016 22:21
requirebin sketch
var InputView = require('ampersand-input-view')
var BootstrapInputView = InputView.extend({
template: [
'<div class="form-group">',
'<label data-hook="label"></label>',
'<input class="form-control">',
'<div data-hook="message-container" class="message message-below message-error">',
'<p data-hook="message-text"></p>',
'</div>',
@timwis
timwis / where.rb
Created February 25, 2016 15:08
Jekyll where filter for strings and arrays
def where(input, property, value)
return input unless input.is_a?(Enumerable)
input = input.values if input.is_a?(Hash)
input.select do |object|
input_property = item_property(object, property)
input_property.to_s == value.to_s || Array(input_property).include?(value.to_s)
end
end
var filteredDatasets = _.filter(datasets, function (dataset) {
return (!params.organization || (dataset.organization && slugify(dataset.organization) === params.organization)) &&
(!params.category || (dataset.category && slugify(dataset.category).indexOf(params.category) !== -1))
})
valid_depts = []
with open(DEPT_FILE_PATH, 'rb') as file:
depts = list(load(file))
for dept in depts:
if isinstance(dept, dict):
for key, matches in dept.iteritems(): # only one of these
valid_depts = valid_depts + [{match: key} for match in matches]
else: