Skip to content

Instantly share code, notes, and snippets.

@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) {
@ghing
ghing / pick_xls_row.py
Created October 5, 2014 15:41
Grab a row from an Excel spreadsheet and output it. Useful for extracting test cases for OpenElections loaders from source results.
#!/usr/bin/env python
import argparse
import xlrd
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Extract rows from an Excel '
'file.')
parser.add_argument('filename', nargs=1,
@ghing
ghing / csv2md.py
Created November 8, 2014 00:37
Output GitHub Flavored Markdown tables for a CSV file
#!/usr/bin/env python
import csv
import sys
import click
def underlines(fieldnames):
underlines = []
for fieldname in fieldnames:
@ghing
ghing / client.py
Created January 20, 2015 22:27
Test python-elections from filesystem
"""AP client that reads data from file instead of from the AP FTP server"""
import os
from elections import AP
class MockFTP(object):
def quit(self):
pass
@ghing
ghing / BaseView.js
Created February 4, 2015 00:08
Template rendering views in Backbone
var BaseView = Backbone.View.extend({
children: {},
checkId: null,
shown: false,
events: {
'click .back-to-top': 'backToTop',
'click h2 a': 'jumpTo'
},
@ghing
ghing / README.md
Last active August 29, 2015 14:24
Reshaping data

Reshaping data

My colleague had a set of temperature readings with one row per date. Another colleague needed to visualize the data in a tool that required one row per day of the month with columns for each year value. He was working with the data in a SQL database, but neither of us knew off the top of our heads the best way to do this. This gist is a number of examples of how to approach the problem.

@ghing
ghing / urls.py
Created August 16, 2010 20:17
Sample Django urls.py that shows how to serve static content when running development server
from django.conf.urls.defaults import *
from django.contrib.gis import admin
import settings
admin.autodiscover()
urlpatterns = patterns('',
(r'^admin/', include(admin.site.urls)),
(r'^$', 'boystown.views.index'),
)
@ghing
ghing / VMware-server-2.0.2-realtime_fix.patch
Created March 8, 2011 17:47
Patch to VMWare Server 2.0.2 Linux kernel module sources that allows the modules to be compiled for use with a realtime kernel.
diff -ru a/lib/modules/source/vmci-only/linux/driver.c b/lib/modules/source/vmci-only/linux/driver.c
--- a/lib/modules/source/vmci-only/linux/driver.c 2009-10-20 19:31:34.000000000 -0500
+++ b/lib/modules/source/vmci-only/linux/driver.c 2011-03-08 10:39:35.305432000 -0600
@@ -360,7 +360,11 @@
memset(vmciLinux, 0, sizeof *vmciLinux);
vmciLinux->ctType = VMCIOBJ_NOT_SET;
#if defined(HAVE_COMPAT_IOCTL) || defined(HAVE_UNLOCKED_IOCTL)
+#if !defined(CONFIG_PREEMPT_RT)
init_MUTEX(&vmciLinux->lock);
+#else