Skip to content

Instantly share code, notes, and snippets.

@ghing
ghing / .block
Last active October 6, 2017 14:37
West Virginia Referendum Results Choropleth Example
height: 800
#!/bin/bash
latest_date_file=.last-statement-date
while [[ $# -gt 1 ]]
do
key="$1"
case $key in
-s|--since)
@ghing
ghing / capture_id.sh
Last active June 24, 2017 19:35
Filter tweets stored by https://github.com/ghing/congressional-tweets to predefined list of screen names
#!/bin/bash
# Read one line of ndjson from stdin
read -r line
last_id_file=$1
if [ -z "$last_id_file" ]; then
last_id_file=.last-tweet-id
fi
@ghing
ghing / adding_agcl_coating_to_reference_electrode_wire.jpg
Last active May 5, 2017 03:36
Testing vitamin C with an opensource potentiostat
adding_agcl_coating_to_reference_electrode_wire.jpg
@ghing
ghing / cases.json
Last active June 3, 2016 19:25
portal.iprachicago.org in one JSON file, as of 2016-06-03T13:45:00
[{"incident_datetime": "2016-01-31T04:25:00", "url": "http://portal.iprachicago.org/1079080-2/", "media": [{"url": "https://player.vimeo.com/video/165083122", "id": "165083122", "title": "Video Clip"}, {"url": "https://player.vimeo.com/video/165083123", "id": "165083123", "title": "Video Clip"}, {"url": "https://player.vimeo.com/video/165083121", "id": "165083121", "title": "Video Clip"}, {"url": "https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/262611603&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&visual=true", "id": "262611603", "title": "Audio Clip"}, {"url": "https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/262611600&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&visual=true", "id": "262611600", "title": "Audio Clip"}, {"url": "https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/262464114&auto_play=fals
@ghing
ghing / check_site.sh
Created June 3, 2016 16:18
Script I ran to notify me when the IPRA portal, http://portal.iprachicago.org came out from behind basic auth on Friday, June 3, 2016
#!/bin/bash
while true; do
wget http://portal.iprachicago.org/ 2>/dev/null
if [ $? -ne 0 ]; then
echo "Portal is not live"
else
osascript -e 'display notification "Live!"'
break
@ghing
ghing / keybase.md
Created March 8, 2016 16:36
Keybase.io GitHub verification

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 February 29, 2016 21:42
Truncating floats and formatting
import decimal
'{:.1f}'.format(decimal.Decimal(99.955).quantize(decimal.Decimal('.1'), rounding=decimal.ROUND_DOWN))
@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 / 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()