Contours of San Francisco overlayed over OpenStreeMap vector tiles using code from mbostock's vector tiles with multiple layers example. View the hi-res file
See gist for code used to generate contours.
""" | |
Implement a queue with two stacks | |
Interview practice from coding for interviews - March 2014 | |
""" | |
class Staqueue(object): | |
""" Implements a queue with two stacks | |
One stack is used for enqueing, and the other dequeing. If an enqueue is requested |
var isLeft = function(p1, p2, p3) { | |
return (p2.position[0] - p1.position[0])*(p3.position[1] - p1.position[1]) - (p3.position[0] - p1.position[0])*(p2.position[1] - p1.position[1]); | |
}; | |
// chainHull_2D(): Andrew's monotone chain 2D convex hull algorithm | |
// see: http://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Convex_hull/Monotone_chain | |
// Input: P[] = an array of 2D points | |
// presorted by increasing x- and y-coordinates | |
// n = the number of points in P[] | |
// Output: H[] = an array of the convex hull vertices (max is n) |
import rauth | |
import time | |
def main(): | |
locations = [(39.98,-82.98),(42.24,-83.61),(41.33,-89.13)] | |
api_calls = [] | |
for lat,long in locations: | |
params = get_search_parameters(lat,long) | |
api_calls.append(get_results(params)) | |
#Be a good internet citizen and rate-limit yourself |
license: mit |
### BEGIN INIT INFO | |
# Provides: Xvfb | |
# Required-Start: $local_fs $remote_fs | |
# Required-Stop: | |
# X-Start-Before: | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Loads X Virtual Frame Buffer | |
### END INIT INFO |
import numpy as np | |
def GEPP(A, b, doPricing = True): | |
''' | |
Gaussian elimination with partial pivoting. | |
input: A is an n x n numpy matrix | |
b is an n x 1 numpy array | |
output: x is the solution of Ax=b | |
with the entries permuted in |
# (C) Mathieu Blondel, November 2013 | |
# License: BSD 3 clause | |
import numpy as np | |
def ranking_precision_score(y_true, y_score, k=10): | |
"""Precision at rank k | |
Parameters |
import re | |
import random | |
# Load the file into a graph represented by a dict of lists | |
def load_graph(): | |
g = {} | |
f = open('kargerMinCut.txt') | |
lines = f.readlines() | |
f.close() |
## The MIT License (MIT) | |
## --------------------- | |
## | |
## Copyright (C) 2014 Nicco Kunzmann | |
## | |
## https://gist.github.com/niccokunzmann/6038331 | |
## | |
## Permission is hereby granted, free of charge, to any person obtaining | |
## a copy of this software and associated documentation files (the "Software"), |
Contours of San Francisco overlayed over OpenStreeMap vector tiles using code from mbostock's vector tiles with multiple layers example. View the hi-res file
See gist for code used to generate contours.