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
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
kuanb / gist:a76cce362aec8f0b9000
Created Aug 8, 2014
Page I made to use Google's Distance Matrix API
View gist:a76cce362aec8f0b9000
<!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>
@kuanb
kuanb / header.html
Created Sep 8, 2015
Simple locked header with class toggle on scroll
View header.html
<!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 {
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
kuanb / Dusk_GeoDataFrame_aggregation.py
Created Apr 14, 2017
Example of Dask variation of GeoDataFrame buffer aggregation
View Dusk_GeoDataFrame_aggregation.py
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 Apr 26, 2017
Using OSMnx, pull down a network and remove "unneeded" intersections from boulevards and like, so as to not double count.
View clean_intersections.py
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 / 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": "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"
@kuanb
kuanb / accessibility_shed.py
Created Jun 7, 2017
Sketch of using networkx to calculate accessibility sheds
View accessibility_shed.py
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 Jul 1, 2017
Run this script via: time python test_dask.py {desired_row_count_of_dfs}
View example_parallelized_dask_geometry_operation.py
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.