Skip to content

Instantly share code, notes, and snippets.

Geoffrey Hing ghing

Block or report user

Report or block ghing

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ghing
ghing / keybase.md
Created Mar 8, 2016
Keybase.io GitHub verification
View keybase.md

Keybase proof

I hereby claim:

  • I am ghing on github.
  • I am ghing (https://keybase.io/ghing) on keybase.
  • I have a public key ASC2JLk_Wl7YdKZ7eJ0p5aVcDdzVSxnidveF6n5SLacjMwo

To claim this, I am signing this object:

@ghing
ghing / truncate_floats.py
Created Feb 29, 2016
Truncating floats and formatting
View truncate_floats.py
import decimal
'{:.1f}'.format(decimal.Decimal(99.955).quantize(decimal.Decimal('.1'), rounding=decimal.ROUND_DOWN))
@ghing
ghing / iframe.html
Last active Oct 12, 2015
Iframe event test
View iframe.html
<html>
<body>
<h1>This is an iframe</h1>
<script>
console.log("Iframe loaded")l;
window.addEventListener('resize', function() {
console.log('resize');
});
</script>
</body>
@ghing
ghing / README.md
Last active Aug 29, 2015
Reshaping data
View README.md

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 / BaseView.js
Created Feb 4, 2015
Template rendering views in Backbone
View BaseView.js
var BaseView = Backbone.View.extend({
children: {},
checkId: null,
shown: false,
events: {
'click .back-to-top': 'backToTop',
'click h2 a': 'jumpTo'
},
@ghing
ghing / client.py
Created Jan 20, 2015
Test python-elections from filesystem
View client.py
"""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 / csv2md.py
Created Nov 8, 2014
Output GitHub Flavored Markdown tables for a CSV file
View csv2md.py
#!/usr/bin/env python
import csv
import sys
import click
def underlines(fieldnames):
underlines = []
for fieldname in fieldnames:
@ghing
ghing / pick_xls_row.py
Created Oct 5, 2014
Grab a row from an Excel spreadsheet and output it. Useful for extracting test cases for OpenElections loaders from source results.
View pick_xls_row.py
#!/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 / index.html
Last active Aug 29, 2015
Playing with rainfall data
View index.html
<!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 / loader_process_notes.md
Last active Aug 29, 2015
Openelections loader implementation notes
View loader_process_notes.md

Loader process

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

Document fields

  • names
  • types
  • formatting conventions.
You can’t perform that action at this time.