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 / barplot.py
Created August 3, 2017 00:26
bar plot end point
@app.route('/bar.img')
def bar():
query = request.args.get('q')
username = request.args.get('username')
api_key = request.args.get('apikey')
xlabel = request.args.get('xlabel')
ylabel = request.args.get('ylabel')
title = request.args.get('title')
# Run a query over the CARTO SQL api
def carto_query(query,username,api_key):
params = {'q' : query, 'format':'csv'}
if api_key:
params['api_key'] = api_key
url = 'https://{}.carto.com/api/v2/sql?'.format(username) + urlencode(params)
return pandas.read_csv(url)
@stuartlynn
stuartlynn / index.md
Created March 8, 2017 16:36
Thoughts on running Analysis Functions on AWS Lambda

Analysis on AWS Lambda

What is AWS Lambda

Lambda is a serverless code execution enviromnent on AWS that can run abitrary python or node code. When a function is triggered it spins up runs and then exists.

Issues with the current setup for Analysis

Analysis currently is run at the Database level through plpythonu functions.

@stuartlynn
stuartlynn / index.md
Created March 8, 2017 15:59
FCC install requirements

Requirements for the FCC project

The Linear programing framework we where using is called CVXOPT, which consists of some C libraries and a python module that calls them

This is the install that worked in a Docker container we have been using for development of tha algorthum. The full docker container is

apt-get install -yq libopenblas-dev libatlas-dev libblas-dev libglpk-dev glpk-utils liblapack-dev libsuitesparse-dev gsl-bin libgsl0-dev libfftw3-dev libblas-test  libopenblas-base libopenblas-dev
git clone https://github.com/cvxopt/cvxopt.git                                                                                                                                                                                 
cd cvxopt                                                                                                                                                                                                                   
@stuartlynn
stuartlynn / Dockerfile
Created March 8, 2017 15:59
Stuarts Docker File
from kaggle/python
RUN apt-get install -yq libopenblas-dev libatlas-dev libblas-dev libglpk-dev glpk-utils liblapack-dev libsuitesparse-dev gsl-bin libgsl0-dev libfftw3-dev libblas-test libopenblas-base libopenblas-dev
RUN git clone https://github.com/cvxopt/cvxopt.git
@stuartlynn
stuartlynn / index.md
Created March 7, 2017 15:09
FOSS4G Workshop - CARTOFRAMES
@stuartlynn
stuartlynn / PageFreeze.py
Last active February 28, 2017 00:53
PageFreeze class
import requests
import json
import pandas as pd
class PageFreezer:
state_lookup = { -1: "Removal", 0: "Change", 1: "Addition" }
def __init__(self,url_1, url_2, api_key = None):
self.api_key = api_key
@stuartlynn
stuartlynn / dot_density.sql
Created February 22, 2016 04:47
dot_density.sql
CREATE OR REPLACE FUNCTION cdb_dot_density(g geometry , no_points Integer, max_iter Integer DEFAULT 1000 )
RETURNS setof geometry AS
$$
DECLARE
extent GEOMETRY;
test_point Geometry;
width NUMERIC;
height NUMERIC;
x0 NUMERIC;
y0 NUMERIC;
import pandas as pd
from urllib import urlencode
from IPython.display import IFrame
from urllib import urlencode
from collections import OrderedDict
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import urllib2
import requests