Skip to content

Instantly share code, notes, and snippets.

@n-bar
n-bar / haversine.py
Created March 17, 2017 08:12 — forked from rochacbruno/haversine.py
Calculate distance between latitude longitude pairs with Python
#!/usr/bin/env python
# Haversine formula example in Python
# Author: Wayne Dyck
import math
def distance(origin, destination):
lat1, lon1 = origin
lat2, lon2 = destination
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@n-bar
n-bar / geohash_encode.py
Last active June 22, 2017 09:19
geohash
# https://en.wikipedia.org/wiki/Geohash
__base32 = '0123456789bcdefghjkmnpqrstuvwxyz'
def encode(lat, lon, precision):
"""(Double?, Double? Uint32) -> String?
precision(km):
1 ±2500
@n-bar
n-bar / pnpoly.py
Created June 22, 2017 09:19
Point in Polygon
# http://geomalgorithms.com/a03-_inclusion.html
# https://wrf.ecse.rpi.edu//Research/Short_Notes/pnpoly.html
# https://ru.wikibooks.org/wiki/Реализации_алгоритмов/Задача_о_принадлежности_точки_многоугольнику
# https://github.com/gregvw/pnpoly
def inPolygon(x, y, xp, yp):
c=0
for i in range(len(xp)):
if (((yp[i]<=y and y<yp[i-1]) or (yp[i-1]<=y and y<yp[i])) and \
(x > (xp[i-1] - xp[i]) * (y - yp[i]) / (yp[i-1] - yp[i]) + xp[i])): c = 1 - c
@n-bar
n-bar / osx-for-hackers.sh
Created July 20, 2017 21:44 — forked from brandonb927/osx-for-hackers.sh
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx