Skip to content

Instantly share code, notes, and snippets.

View clhenrick's full-sized avatar

Chris Henrick clhenrick

View GitHub Profile
@pgiraud
pgiraud / index.html
Created February 13, 2014 13:18
d3js Elevation profile - Ratio automatically chosen
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font: 10px sans-serif;
}
.axis path,
.axis line {
@andrewxhill
andrewxhill / run.sql
Created July 16, 2014 01:32
Grid snapping only in SQL!
CREATE OR REPLACE FUNCTION axh_miles_test(input GEOMETRY)
RETURNS GEOMETRY AS $$
DECLARE
-- sql TEXT;
first GEOMETRY;
next GEOMETRY;
back GEOMETRY;
last GEOMETRY;
@fitosegrera
fitosegrera / index.html
Last active August 29, 2015 14:04
example_8 Generative Drawing in javascript (SUPER ADVANCED!!!!)
<!--
///////////////////////////////////////
// example_8 web class bootcamp 2014 //
///////////////////////////////////////
//////////// Parsons MFADT ////////////
///////////////////////////////////////
//Created by: fito_segrera
//fii.to
GENERATIVE DRAWING
@andrewxhill
andrewxhill / run.sql
Last active August 29, 2015 14:06
Tim's transform of dentists
select * from (
select the_geom as the_geom_webmercator,
min(ST_Distance_Sphere(st_transform(st_centroid(the_geom), 4326), st_transform(otherGeom, 4326)))/1600 as minDist
from (
select grids.the_geom, st_collect(st_transform(timchung.allbusiness.the_geom, 3857)) as otherGeom
from (
SELECT CDB_HexagonGrid(
ST_SetSRID(
ST_Envelope(
ST_Collect(
@andrewxhill
andrewxhill / app.js
Created September 6, 2014 18:28
Node.js app to harvest a georss feed into CartoDB
var express = require('express');
var app = express();
var http = require('http'),
https = require('https'),
querystring = require('querystring'),
Step = require('step'),
fs = require('fs'),
// jQuery = require('jquery');
parseString = require('xml2js').parseString;
@clhenrick
clhenrick / get lat lon from x y
Created February 27, 2015 16:54
NYC Pluto x, y to lat, lon
Select ST_AsText(
ST_Transform(
ST_SetSRID(
ST_MakePoint(xcoord,ycoord),
2263)
, 4326)
) from pluto limit 10;
import sysconfig
config = sysconfig.get_config_vars()
keys = config.keys()
keys.sort()
for k in keys:
print '%s: %s' % (k, config[k])
import csv
import urllib
import re
from nyc_geoclient import Geoclient
from sys import argv
from sys import exit
script, infile, outfile = argv
g = Geoclient('9cd0a15f', '54dc84bcaca9ff4877da771750033275')

A day in SQL HELL: or how I learned to like (or at least appreciate) SQL by ziggy

In short: the secret to who owns nyc will probably be found in a really complicated sql statement

Here's how this all started. I was working on my project to analyze heat/hot water complaints. I downloaded all the complaints for this heat season (there's over 200,00), geocoded them to obtain the bbls, and then imported them into postgres. I wanted to match complaints with their owners in order to find out whose responsible for not providing tenants' with essential services.

So I fired up PSQL and started typing out some queries.

SELECT bbl,