Skip to content

Instantly share code, notes, and snippets.

require 'uri'
require 'net/http'
require 'base64'
require 'openssl'
require 'json'
class GoogGeocoder
PATH = "/maps/api/geocode/json?sensor=false"
@ashaw
ashaw / calculateDeath.js
Last active December 16, 2015 13:08
How we're calculating death in our HeartSaver experimental news game.
var calculateDeath = function(hospital, pickupTime, travelTime) {
var survivalChance = 1;
// A victim’s chance of survival decreases by 7 to 10 percent / minute
// that passes without defibrillation.
// http://www.heart.org/idc/groups/heart-public/@wcm/@ecc/documents/downloadable/ucm_438703.pdf
survivalChance -= (0.10 * pickupTime);
// Time in transit to ER (.58% / minute, via the Google Directions API)
// http://www.ncbi.nlm.nih.gov/pmc/articles/PMC2464671/table/tbl1/
require 'sinatra'
require 'sanitize'
TO_REMOVE = ["", " ", " "]
get '/' do
<<-HTML
<form method="post" action="sanitize">
<textarea name="dirty" style="width:100%;height:800px;"></textarea>
<input type="submit" value="Submit">
# gem install crack rest-client fastercsv
require 'rubygems'
require 'crack'
require 'rest_client'
require 'fastercsv'
# To use, get an access token here, by clicking "get access token"
# and checking user.groups in the dialog box
# https://developers.facebook.com/tools/explorer?method=GET&path=209024949216061%2Ffeed
#
propublica.views.stickyNav = propublica.View.extend({
cssClass : "sticky_nav",
render : function() {
_.bindAll(this, "stick");
this.jWindow = $(window);
this.jFooter = $("footer");
this.offsetTop = this.el.offset().top;
this.elHeight = this.el.height();
this.jWindow.scroll(this.stick);
var lookup = {
"2001_v1" : 188914,
"2001_v2" : 193305
}
$(function() {
$("#censo, #vars").change(function() {
var year = $("#censo option:selected").val();
var version = $("#vars option:selected").val();
var map_id = lookup[year + "_" + version];
console.log(map_id);
<html>
<head>
<script src="http://code.jquery.com/jquery-1.8.1.min.js"></script>
<script>
$(document).ready(function() {
$("#submit").click(function() {
var username = $("#username").val();
<html>
<head>
<style>
#box {
width:200px;
height:200px;
background:black;
}
#box.red {
<html>
<head>
<style>
#box {
width:200px;
height:200px;
background:black;
}
#box.red {
@ashaw
ashaw / simple-fb-app.html
Created August 28, 2012 13:09
Simple FB JavaScript app example for HHBA
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
</head>
<body>
<div id="fb-root"></div>
<script src="//connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({