Skip to content

Instantly share code, notes, and snippets.

Kuan Butts kuanb

Block or report user

Report or block kuanb

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
kuanb / gist:2f75e66c8b7c827717c2
Created Aug 8, 2014
Example Homework Assignment from Introductory Python course 6.00
View gist:2f75e66c8b7c827717c2
# 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 *
View gist:e7155e51d6ba9950dbfd
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 / gist:a76cce362aec8f0b9000
Created Aug 8, 2014
Page I made to use Google's Distance Matrix API
View gist:a76cce362aec8f0b9000
<!DOCTYPE html>
<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=""></script>
<script type="text/javascript" src="read-csv.js"></script>
<script src=""></script>
<script src=""></script>
kuanb / header.html
Created Sep 8, 2015
Simple locked header with class toggle on scroll
View header.html
<title>CSS Only Dynamic Header</title>
<script type="text/javascript" src=""></script>
<style type="text/css">
body {
View insert ctracks output
'use strict';
const fs = require('fs');
const parse = require('csv-parse');
const db = require('knex')({
client: 'postgresql',
connection: {
user: '',
database: 'clientcomm',
kuanb /
Created Apr 14, 2017
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 /
Created Apr 26, 2017
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.
import geopandas as gpd
import pandas as pd
from shapely.geometry import Point
import osmnx as ox
kuanb / traffic-cameras.json
Created Sep 8, 2015
All traffic camera locations in NYC
View traffic-cameras.json
"lat": "40.79142677512476",
"lng": "-73.93807411193848",
"name": "1 Ave @ 110 St",
"camera": ""
}, {
"lat": "40.800426144169315",
"lng": "-73.93155097961426",
"name": "1 Ave @ 124 St",
"camera": ""
kuanb /
Created Jun 7, 2017
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 /
Created Jul 1, 2017
Run this script via: time python {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
You can’t perform that action at this time.