Skip to content

Instantly share code, notes, and snippets.

View mhkeller's full-sized avatar

Michael Keller mhkeller

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<style>
html, body, #map {
height: 100%;
padding: 0;
@mhkeller
mhkeller / gist:5230844
Last active December 15, 2015 08:29
Lat and Lng from geom
SELECT ST_X(ST_Centroid(the_geom)) as longitude, ST_Y(ST_Centroid(the_geom)) as latitude FROM table
@mhkeller
mhkeller / treasury.py
Created June 16, 2013 21:00
An example querying the FMS Treasury database using python.
#!/usr/bin/env python
from json import load
from urllib import urlopen
from urllib import urlencode
from pandas import DataFrame
def treasury(sql):
url = 'https://box.scraperwiki.com/cc7znvq/47d80ae900e04f2/sql/'
@mhkeller
mhkeller / treasury.r
Created June 16, 2013 21:03
An example querying the FMS Treasury database using R.
#!/usr/bin/env Rscript
library(plyr)
library(utils)
library(RJSONIO)
library(RCurl)
treasury <- function(sql) {
url = paste('https://box.scraperwiki.com/cc7znvq/47d80ae900e04f2/sql/?q=', URLencode(sql), sep = '')
handle <- getCurlHandle()
body <- getURL(url, curl = handle)
git diff --diff-filter=D --name-only -z | xargs -0 git rm
@mhkeller
mhkeller / gist:5824430
Last active April 23, 2020 15:03
Good mock-up hex colors
#0cf - Hot blue
#fc0 - Hot orange
#0fc - Hot sea green
#f0c - Hot pink
#f0a - Hot pink two
#01df3a - Hot green
#f3f0df - The Beige
#F76464 - Coral
@mhkeller
mhkeller / calculateStepDimensions.js
Last active December 18, 2015 18:39
A function for creating pixel and percentage calculations for step-based scrolling interactives using Skrollr.js
function calculateStepDimensions(step_obj){
// Create cumulative percentage values for each step
// Because it's easier to declare the percentage in in the config obj
// But it's easier later on to know each step's pixel start and end values
var cml_perc = 0
for (var step in step_obj){
if (_.has(step_obj, step)){
var row = step_obj[step];
var len_pix = Math.round(row.perc * TOTAL_LENGTH);
cml_perc += row['perc'];
@mhkeller
mhkeller / jquery.placeholderText.js
Last active December 18, 2015 18:39
Create blurring of textfields for non-skinny pants browsers that don't know from 'placeholder="my pants are skinny"'
function makeTextfieldsPlaceholderable(){
/* Clears textfields from helper text on click */
var $textfield = $('.placeholder-textfield');
$textfield.focus(function(srcc){
if ($(this).val() == $(this)[0].title){
$(this).removeClass("placeholder-textfield-active");
$(this).val("");
}
});
@mhkeller
mhkeller / json-to-csv.js
Last active December 19, 2015 03:28
Converting json to csv with dsv.js for treasury.io
var $ = require('jquery'),
dsv = require('dsv'),
pi_endpoint = 'https://premium.scraperwiki.com/cc7znvq/47d80ae900e04f2/sql/?q=';
function convertJSONtoCSV(query){
fetchJSON(query).done(function(json){
$download_csv_btn.html('Download .csv')
// This line does all of the json to csv conversion
var csv = dsv.csv.format(json);
console.log(csv)
@mhkeller
mhkeller / job.md
Last active December 19, 2015 07:29
The Daily Beast is seeking an Interactive News Applications Reporter.

To give you a sense of what type of work you would be doing, here are some of our past interactive projects on Super PAC spending, mapping the access to abortion clinics, looking deeper into what force-feeding at Guantanamo Bay does to the body and tracking members' of congress statements on gun control, complete with a Twitter bot.

The job would be a good fit for you if you have an interest in telling engaging journalistic stories through new digital ways -- emphasis on good journalism. You'll need a strong sense of the news and a desire to tell it in new ways.

A typical day could have you pitching your own idea, mocking it up and developin