Skip to content

Instantly share code, notes, and snippets.

View mhkeller's full-sized avatar

Michael Keller mhkeller

View GitHub Profile
@wilson428
wilson428 / package.json
Created January 8, 2014 05:22
Recreate the Atlantic's Netflix category data using NodeJS. Requires a Netflix login.
{
"name": "netflix-category-scraper",
"version": "0.0.0",
"description": "Collect all categories from Netflix",
"dependencies": {
"cheerio": "*",
"sqlite3": "*",
"request": "*"
},
"author": {
@andrewxhill
andrewxhill / sql_statements.sql
Created December 8, 2013 18:53
Fun SQL statements for CartoDB
--PART 2
-- a.
SELECT * FROM tornados
SELECT cartodb_id FROM tornados
-- b.
SELECT * FROM tornados LIMIT 1
SELECT * FROM tornados LIMIT 1 OFFSET 1
SELECT * FROM tornados ORDER BY damage DESC LIMIT 10
-- c.
SELECT * FROM tornados WHERE cartodb_id < 30
@mhkeller
mhkeller / import-shp-to-pgsql.sh
Last active October 23, 2018 18:27
Shapefile to PostGIS table.
# SRID is the projection's EPSG code. To find yours, open up the prj file in a text editor and search for that name at http://spatialreference.org/
# The schema is probably already named `public` and the database name is perhaps your username.
# To list your schemas use `\dn` after running `psql`.
# To get info about your current database connnection use `\conninfo`.
# In SQL, get the database name with `select current_database() ;`
# The -D flag will use the postgres dump format, which will be much faster than single row inserts. if any single row fails,
# which is also good to know — instead of not knowing if you insert row by row
# shp2pgsql -I -D -s <SRID> <PATH/TO/SHAPEFILE> <SCHEMA>.<DBTABLE> | psql -d <DATABASE>
@mhkeller
mhkeller / gist:6590111
Last active December 23, 2015 05:49
PostGis query to shp
$ pgsql2shp -f <path to output shapefile> -h <hostname> -u <username> -P <password> databasename "<query>"
$ pgsql2shp -f ca_hex_2000_ided.shp -h localhost -u mike mike "SELECT ca_hex_2000_ided.geom, ca_hex_2000_ided.hex_id FROM ca_hex_2000_ided, bounder WHERE ST_Intersects(ca_hex_2000_ided.geom, bounder.geom) "
/*
Usage:
When generating a page:
var abTest = new AbTest('your-test-slug');
if (abTest.variation == 0)
$('#thediv').addClass('red');
else if (abTest.variation == 1)
@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
@RandomEtc
RandomEtc / README.md
Last active February 12, 2017 15:39
Advanced object constancy.

Fine-grained control of randomly entering and exiting things in D3.js, for impeccable object constancy. Adapted from an example co-authored with Mike Bostock.

@WillTurman
WillTurman / Readme.md
Created January 25, 2013 02:15
D3 Interactive Streamgraph

D3 Streamgraph Example

Series Hover

The series hover interactivity uses the technique from lgrammel seen here: http://bl.ocks.org/1963983

Data Tooltip

It isn't necessarily a tooltip, but data is displayed by inverting the x-axis value into a date, and mapping the date to the corresponding data value for the series.

import requests
import tweepy
import time
import oauth2
import re
from urllib import quote
# THIS IS WHAT YOU CUSTOMIZE #
# terms
LIST = "members-of-congress"
@palewire
palewire / crayola.mss
Created December 20, 2012 21:18
The 133 standard Crayola crayon colors in CartosCSS and ready for use with TileMill.
/*
Crayola crayon colors
Compiled by @LATdatadesk
Source: http://en.wikipedia.org/wiki/List_of_Crayola_crayon_colors
*/
// Standard colors
@almond: #EFDECD;
@antique_brass: #CD9575;