This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Depth-first and Breadth-first graph traversals. | |
* | |
* In this diff we implement non-recursive algorithms for DFS, | |
* and BFS maintaining an explicit stack and a queue. | |
* | |
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com> | |
* MIT Style license | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe("getTweets - Server", function () { | |
var server, fakeData = [ /* ... */ ]; | |
before(function () { | |
// Doesn’t work :( It’s JSONP! | |
server = sinon.fakeServer.create(); | |
server.respondWith( | |
"GET", | |
"https://api.twitter.com/.../elijahmanor.json?count=5", | |
[200, { "Content-Type": "application/json" }, JSON.stringify(fakeData)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env/python | |
# | |
# Little script to play around with the code and | |
# data of H. Tropf, H. Herzog's paper 1981 paper | |
# "Multidimensional Range Search in Dynamically | |
# Balanced Trees". | |
# | |
# Thanks to Bernhard Herzog (unrelated to H. Herzog) | |
# for having a second look at the code. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: apache-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var simplifyPath = function( points, tolerance ) { | |
// helper classes | |
var Vector = function( x, y ) { | |
this.x = x; | |
this.y = y; | |
}; | |
var Line = function( p1, p2 ) { | |
this.p1 = p1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Chan's Convex Hull O(n log h) - Tom Switzer <thomas.switzer@gmail.com> | |
TURN_LEFT, TURN_RIGHT, TURN_NONE = (1, -1, 0) | |
def turn(p, q, r): | |
"""Returns -1, 0, 1 if p,q,r forms a right, straight, or left turn.""" | |
return cmp((q[0] - p[0])*(r[1] - p[1]) - (r[0] - p[0])*(q[1] - p[1]), 0) | |
def _keep_left(hull, r): | |
while len(hull) > 1 and turn(hull[-2], hull[-1], r) != TURN_LEFT: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def between(a, b, c): | |
return a <= b and b <= c | |
class Region(object): | |
def intersects(self, other): | |
raise NotImplemented( | |
"%s does not know how to check for intersection with %s" |
NewerOlder