Skip to content

Instantly share code, notes, and snippets.

View stuartlynn's full-sized avatar

Stuart Lynn stuartlynn

  • Two Sigma
  • Brooklyn
View GitHub Profile
@stuartlynn
stuartlynn / gist:7778144
Created December 3, 2013 21:55
Small Sinatra script for geocoding ips
require 'sinatra'
require 'pg'
require 'json'
require 'uri'
hash = URI.parse(ENV['HEROKU_POSTGRESQL_WHITE_URL'] || "http://localhost:5432/geo")
Client = PG.connect(hash.host, hash.port, nil , nil , hash.path.gsub("/",""), hash.user, hash.password)
# Client = Mysql2::Client.new(:host => "localhost", :username => "root")
@stuartlynn
stuartlynn / scraper.js
Last active September 25, 2020 18:03
Example query
const ckan = require('ckan');
var client = new ckan.Client('https://data.humdata.org/');
client.requestType = 'GET';
function getPages() {
return new Promise((resolve, reject) => {
const getPage = (offset, page, datasetsToDate) => {
console.log(
'requesting offset ',
@stuartlynn
stuartlynn / download_portals.py
Created August 19, 2020 14:02
Get Department code
import pandas as pd
import json
import requests
import math
from pathlib import Path
from tqdm import tqdm
import pprint
def get_portal_list():
return requests.get('http://api.us.socrata.com/api/catalog/v1/domains').json()['results']
@stuartlynn
stuartlynn / index.md
Last active May 20, 2020 19:09
Good Tech Fest Demos
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stuartlynn
stuartlynn / Nextrad tutorial.ipynb
Created October 8, 2015 17:34
NEXRad to CartoDB data importer
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stuartlynn
stuartlynn / rnn.py
Created January 10, 2016 23:56
RNN from https://gist.github.com/karpathy/d4dee566867f8291f086 with slight modifications to output the model as it trains and predict output
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('buildings.geojson', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@stuartlynn
stuartlynn / point_in_poly.rs
Created October 27, 2019 13:57
Fast Agg point in polygon search
pub fn agg_in(&self, poly: &Geometry<f32>) -> HashMap<String, f32> {
// Find the bounds of the target polygon
let bounds = match poly {
Geometry::Polygon(p) => Ok(p.bounding_rect().unwrap()),
Geometry::MultiPolygon(p) => Ok(p.bounding_rect().unwrap()),
_ => Err("Wrong poly type"),
}
.unwrap();
@stuartlynn
stuartlynn / script.js
Created July 31, 2019 19:18
OpenJSCad data vis tutorial
data = {"1880": [-0.3, -0.21, -0.18, -0.27, -0.14, -0.29, -0.24, -0.08, -0.17, -0.16, -0.19, -0.22], "1881": [-0.1, -0.14, 0.01, -0.03, -0.04, -0.28, -0.07, -0.03, -0.09, -0.2, -0.26, -0.16], "1882": [0.09, 0.08, 0.01, -0.2, -0.18, -0.25, -0.11, 0.03, -0.01, -0.23, -0.21, -0.25], "1883": [-0.34, -0.42, -0.18, -0.25, -0.26, -0.13, -0.09, -0.14, -0.19, -0.12, -0.21, -0.19], "1884": [-0.18, -0.13, -0.36, -0.36, -0.32, -0.38, -0.35, -0.27, -0.24, -0.22, -0.3, -0.3], "1885": [-0.66, -0.3, -0.24, -0.45, -0.42, -0.5, -0.29, -0.27, -0.19, -0.2, -0.22, -0.07], "1886": [-0.43, -0.46, -0.41, -0.29, -0.27, -0.39, -0.16, -0.31, -0.19, -0.25, -0.26, -0.25], "1887": [-0.66, -0.48, -0.32, -0.37, -0.33, -0.21, -0.19, -0.28, -0.19, -0.32, -0.25, -0.38], "1888": [-0.43, -0.43, -0.47, -0.28, -0.22, -0.2, -0.1, -0.11, -0.07, 0.01, 0.0, -0.12], "1889": [-0.21, 0.14, 0.04, 0.04, -0.03, -0.12, -0.05, -0.18, -0.18, -0.22, -0.32, -0.31], "1890": [-0.48, -0.48, -0.41, -0.38, -0.48, -0.27, -0.3, -0.36, -0.36, -0.23, -0.37, -0.3], "1891"
@stuartlynn
stuartlynn / script.js
Last active July 31, 2019 15:41
Temperature Anomaly sculpture
// title : OpenJSCAD.org Logo
// author : Rene K. Mueller
// license : MIT License
// revision : 0.003
// tags : Logo,Intersection,Sphere,Cube
// file : logo.jscad
data = {"1880": [-0.3, -0.21, -0.18, -0.27, -0.14, -0.29, -0.24, -0.08, -0.17, -0.16, -0.19, -0.22], "1881": [-0.1, -0.14, 0.01, -0.03, -0.04, -0.28, -0.07, -0.03, -0.09, -0.2, -0.26, -0.16], "1882": [0.09, 0.08, 0.01, -0.2, -0.18, -0.25, -0.11, 0.03, -0.01, -0.23, -0.21, -0.25], "1883": [-0.34, -0.42, -0.18, -0.25, -0.26, -0.13, -0.09, -0.14, -0.19, -0.12, -0.21, -0.19], "1884": [-0.18, -0.13, -0.36, -0.36, -0.32, -0.38, -0.35, -0.27, -0.24, -0.22, -0.3, -0.3], "1885": [-0.66, -0.3, -0.24, -0.45, -0.42, -0.5, -0.29, -0.27, -0.19, -0.2, -0.22, -0.07], "1886": [-0.43, -0.46, -0.41, -0.29, -0.27, -0.39, -0.16, -0.31, -0.19, -0.25, -0.26, -0.25], "1887": [-0.66, -0.48, -0.32, -0.37, -0.33, -0.21, -0.19, -0.28, -0.19, -0.32, -0.25, -0.38], "1888": [-0.43, -0.43, -0.47, -0.28, -0.22, -0.2, -0.1, -0.11, -0.07, 0.01, 0.0, -0.12