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
module Geo | |
def self.distance(point_a = {}, point_b = {}) | |
# http://en.wikipedia.org/wiki/Haversine_formula | |
r = 6371.009 # IUGG mean radius of the Earth | |
deg2rad = lambda { |d| d * Math::PI / 180 } | |
sin2 = lambda { |x| Math.sin(x) ** 2 } | |
lat1 = deg2rad.call(point_a['lat']) |
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
require 'singleton' | |
module U2 | |
class Edge | |
include Singleton | |
attr_accessor :delay | |
def set_delay_for_tempo(bpm) | |
# http://5cense.com/Edge_Delay.htm |
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
# == Active Model North American Telephone Number Validator | |
# http://en.wikipedia.org/wiki/North_American_Numbering_Plan#Current_system | |
# [Author] Roger Rohrbach ([email protected]) | |
class NanpValidator < ActiveModel::EachValidator | |
def self.matcher(require_area_code) # :nodoc: | |
%r{ | |
(?<country_code> \+1 ){0} | |
(?<trunk_prefix> 1 ){0} | |
(?<delimiter> ([-\.]|\ +) ){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
class VersionVector | |
# D. S. Parker, et al. Detection of Mutual Inconsistency in | |
# Distributed Systems. IEEE Trans. Softw. Eng. 9, 3 (May 1983), 240-247. | |
def initialize | |
@versions = {} | |
@versions.default = 0 | |
end | |
def [](site) |