Skip to content

Instantly share code, notes, and snippets.

@ghing
ghing / HandlebarsTemplateView.js
Created April 11, 2013 14:12
Backbone base view that handles compiling and retrieving templates.
define([
"underscore",
"backbone",
"handlebars"
],
function(_, Backbone, Handlebars) {
var HandlebarsTemplateView = Backbone.View.extend({
templates: {},
initialize: function(options) {
#!/usr/bin/python
## The equivalent of:
## "Working with the Skeleton"
## in the OpenNI user guide.
"""
This shows how to identify when a new user is detected, look for a pose for
that user, calibrate the users when they are in the pose, and track them.
Specifically, it prints out the location of the users' head,
@ghing
ghing / server.py
Created April 30, 2013 13:16
Send OpenNI skeleton data over a websocket. Uses gevent-websocket for the websockety things.
#!/usr/bin/env python
## The equivalent of:
## "Working with the Skeleton"
## in the OpenNI user guide.
"""
This shows how to identify when a new user is detected, look for a pose for
that user, calibrate the users when they are in the pose, and track them,
sending updates about joint position over a websocket.
@ghing
ghing / dump_script_assets.py
Created May 23, 2013 20:25
Create a fixture of all HtmlAsset models that include 'script' in the body
#!/usr/bin/env python
# Create a fixture of all HtmlAsset models that include 'script' in the
# body
# Usage: dump_script_assets.py | python -mjson.tool > script_assets.json
from django.core.management import setup_environ
# Edit this to use a particular settings module
import settings.dev
setup_environ(settings.dev)
@ghing
ghing / index.html
Last active December 18, 2015 11:29 — forked from jwirfs-brock/index.html
<!DOCTYPE html>
<head>
<meta charset="utf-8">
</head>
<body>
<div id="app">
</div>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="tabletop.js"></script>
@ghing
ghing / avg_text_asset_length.py
Created August 21, 2013 13:48
Get the average length (in characters) of published text assets
from django.utils.html import strip_tags
from storybase_asset.models import HtmlAsset
assets = HtmlAsset.objects.filter(stories__status='published')
total_length = 0
for asset in assets:
# Strip HTML from the body to more accurately reflect visible length
total_length += len(strip_tags(asset.body))
avg_length = total_length / assets.count()
@ghing
ghing / piezo_shock_sensor.ino
Created November 29, 2013 15:36
Arduino sketch to read piezoelectric sensor for Florence's science project.
// Use a Radio Shack 273-059 piezo buzzer as a shock sensor
// Based on recipe from http://www.eng.utah.edu/~cs5789/handouts/piezo.pdf
// and the Knock example (http://arduino.cc/en/Tutorial/Knock)
const int ledPin = 13; // Built in LED is pin 13
const int piezoPin = 0; // Piezoelectric element is attached to analog pin 0
const int threshold = 7; // Ignore readings below this value;
const int delayTime = 500; // HTime to pause during each loop
int val, t;
@ghing
ghing / temperature_sensor.ino
Created January 31, 2014 22:01
Read temperature from a TMP102 sensor and push to Xively
//
// Read temperature from a TMP102 sensor and push to Xively
//
#include <SPI.h>
#include <WiFly.h>
#include <Wire.h>
const char ssid[] = "BigBabyBoy";
@ghing
ghing / loader_process_notes.md
Last active August 29, 2015 13:57
Openelections loader implementation notes

Loader process

Starting with the most recent election look at the data files.

Document fields

  • names
  • types
  • formatting conventions.
@ghing
ghing / index.html
Last active August 29, 2015 14:07
Playing with rainfall data
<!doctype html>
<html>
<head></head>
<body>
<div id="chart"></div>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
var ENDPOINT_ROOT = 'http://chicagorains.com/api/hourlyPrecip/';
function getURL(date, location) {