Skip to content

Instantly share code, notes, and snippets.

View kuanb's full-sized avatar
🚌
trains, buses, bikes, and maps

Kuan Butts kuanb

🚌
trains, buses, bikes, and maps
View GitHub Profile
@kuanb
kuanb / gist:2f75e66c8b7c827717c2
Created August 8, 2014 17:13
Example Homework Assignment from Introductory Python course 6.00
# Problem Set 7: Simulating the Spread of Disease, Body Temperature and Virus Population Dynamics
# Name: Kuan Butts
# Time: 22:00
import numpy
import random
import pylab
# for checking work from prob. 3, 4, 5, 6
#from ps7_precompiled_27 import *
@kuanb
kuanb / gist:a76cce362aec8f0b9000
Created August 8, 2014 17:17
Page I made to use Google's Distance Matrix API
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Find a route using Geolocation and Google Maps API</title>
<script type="text/javascript" src="jquery-2.1.1.js"></script>
<script src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript" src="read-csv.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
def adjacent_hanoi(num_discs, start_peg, end_peg):
"""
For this problem, discs should always start on the first peg and
end on the last peg.
num_discs: an integer number of discs
start_peg: starting peg
end_peg: ending peg
returns: integer number of moves, actual moves required
"""
@kuanb
kuanb / header.html
Created September 8, 2015 15:29
Simple locked header with class toggle on scroll
<!DOCTYPE HTML>
<html>
<head>
<title>CSS Only Dynamic Header</title>
</head>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<style type="text/css">
body {
@kuanb
kuanb / traffic-cameras.json
Created September 8, 2015 15:40
All traffic camera locations in NYC
[{
"lat": "40.79142677512476",
"lng": "-73.93807411193848",
"name": "1 Ave @ 110 St",
"camera": "http://207.251.86.238/cctv261.jpg"
}, {
"lat": "40.800426144169315",
"lng": "-73.93155097961426",
"name": "1 Ave @ 124 St",
"camera": "http://207.251.86.238/cctv254.jpg"
'use strict';
const fs = require('fs');
const parse = require('csv-parse');
const db = require('knex')({
client: 'postgresql',
connection: {
user: '',
database: 'clientcomm',
},
@kuanb
kuanb / Dusk_GeoDataFrame_aggregation.py
Created April 14, 2017 22:26
Example of Dask variation of GeoDataFrame buffer aggregation
import sys, csv, time
from dask import dataframe as dd
import geopandas as gpd
import pandas as pd
from shapely.wkt import loads
# log/monitor performance
start_time = time.time()
def log(message):
@kuanb
kuanb / clean_intersections.py
Created April 26, 2017 23:07
Using OSMnx, pull down a network and remove "unneeded" intersections from boulevards and like, so as to not double count.
import matplotlib
# Force matplotlib to not use any Xwindows backend.
matplotlib.use('Agg')
import geopandas as gpd
import pandas as pd
from shapely.geometry import Point
import osmnx as ox
COUNTER = 0
@kuanb
kuanb / accessibility_shed.py
Created June 7, 2017 06:27
Sketch of using networkx to calculate accessibility sheds
import networkx as nx
import numpy as np
import pandas as pd
import time
from dgna.utils import format_pandana_edges_nodes
# read in osm data, load into top level variable
osm_edges = pd.read_csv('./data/osm_edges.csv')
osm_nodes = pd.read_csv('./data/osm_nodes.csv')
@kuanb
kuanb / example_parallelized_dask_geometry_operation.py
Created July 1, 2017 00:51
Run this script via: time python test_dask.py {desired_row_count_of_dfs}
import dask.dataframe as dd
import geopandas as gpd
import logging
import math
import numpy as np
import pandas as pd
import sys
from dask.distributed import Client
from shapely.wkt import loads as wkt_loads
from shapely.wkb import loads as wkb_loads