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
# | |
# = Capistrano database.yml task | |
# | |
# Provides a couple of tasks for creating the database.yml | |
# configuration file dynamically when deploy:setup is run. | |
# | |
# Category:: Capistrano | |
# Package:: Database | |
# Author:: Simone Carletti <weppos@weppos.net> | |
# Copyright:: 2007-2010 The Authors |
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) |
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 (roger@ecstatic.com) | |
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
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
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']) |