Skip to content

Instantly share code, notes, and snippets.

View mattsta's full-sized avatar
🐢
Moving slowly and fixing things

Matt Stancliff mattsta

🐢
Moving slowly and fixing things
View GitHub Profile
@tompaton
tompaton / kdtree.py
Created March 10, 2011 00:15
Python kd-tree spatial index and nearest neighbour search
#!/usr/bin/env python
# kd-tree index and nearest neighbour search
# includes doctests, run with: python -m doctest kdtree.py
class KDTree(object):
"""
kd-tree spatial index and nearest neighbour search
http://en.wikipedia.org/wiki/Kd-tree
"""
@archaelus
archaelus / netmask.erl
Created February 22, 2011 22:55
CIDR in/out net calculation
-module(netmask).
-export([in_network/3]).
in_network(Net, CIDR, IP)
when is_binary(Net), is_binary(IP), is_integer(CIDR) ->
<<NetworkPrefix:CIDR/bits, _/bits>> = Net,
case IP of
<<NetworkPrefix:CIDR/bits, _Host/bits>> ->
in_net;
_ -> not_in_net
@zaphar
zaphar / date_util.erl
Created May 1, 2009 06:07
set of utility functions that wrap the calendar module and erlangs now() date() and time() functions
-module(date_util).
-compile(export_all).
epoch() ->
now_to_seconds(now())
.
epoch_hires() ->
now_to_seconds_hires(now())
.