Skip to content

Instantly share code, notes, and snippets.

@kei-sato
kei-sato / clustering-lance-williams.coffee
Last active November 9, 2015 18:18
Clustering with Lance-Williams updating formula
# Clustering with Lance-Williams updating formula
# http://ibisforest.org/index.php?Lance-Williams%20updating%20formula
calcSquare = (n) -> n * n
haversine = (lat1, lng1, lat2, lng2) ->
6371000 * 2 * Math.asin(Math.sqrt(Math.pow(Math.sin((lat1 - Math.abs(lat2)) * Math.PI / 180 / 2), 2) + Math.cos(Math.abs(lat1) * Math.PI / 180 ) * Math.cos(Math.abs(lat2) * Math.PI / 180) * Math.pow(Math.sin((lng1 - lng2) * Math.PI / 180 / 2), 2) ))
##
# calculate distance between 2 numbers
@kei-sato
kei-sato / usdex
Last active August 29, 2015 14:24
Exchange usd to any currency, or any currency to usd
#!/usr/bin/env python
#coding:utf-8
# Exchange usd to any currency, or any currency to usd
# help: python convert_usd.py -h
import os.path
from datetime import date, datetime
import argparse
import urllib