This file contains hidden or 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
-- Haversine Formula based geodistance in miles (constant is diameter of Earth in miles) | |
-- Based on a similar PostgreSQL function found here: https://gist.github.com/831833 | |
-- Updated to use distance formulas found here: http://www.codecodex.com/wiki/Calculate_distance_between_two_points_on_a_globe | |
CREATE OR REPLACE FUNCTION public.geodistance(alat double precision, alng double precision, blat double precision, blng double precision) | |
RETURNS double precision AS | |
$BODY$ | |
SELECT asin( | |
sqrt( | |
sin(radians($3-$1)/2)^2 + | |
sin(radians($4-$2)/2)^2 * |
This file contains hidden or 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
def geodist(a, b) | |
rads = Math::PI/180 | |
# 7926.3352 is diameter of earth in miles | |
7926.3352 * Math.asin( | |
Math.sqrt( | |
Math.sin( (b[1] - a[1])*rads / 2 )**2 * | |
Math.cos( a[0] * rads ) * | |
Math.cos( b[0] * rads ) + | |
Math.sin( (b[0] - a[0])*rads / 2 )**2 | |
) |
This file contains hidden or 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 'open-uri' | |
def get_file(url) | |
filename = url.split("/").last.gsub(/_[0-9a-f\-]{36}\./,".") | |
begin | |
file = open( url ) | |
file.instance_variable_set(:@original_filename, filename) | |
def file.original_filename; @original_filename; end | |
file | |
rescue OpenURI::HTTPError |
This file contains hidden or 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
[user] | |
name = Your Full Name | |
email = [email protected] | |
[alias] | |
st = status | |
d = diff | |
co = checkout | |
ci = commit -v | |
cia = commit -v -a | |
b = branch |
This file contains hidden or 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 STOP < Exception | |
def initialize(msg) | |
super | |
puts "STOP! #{msg}" | |
end | |
def time; Time.now; end | |
end | |
def Time.cant_touch_this |
This file contains hidden or 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
CREATE USER username IDENTIFIED BY 'password'; | |
GRANT ALL ON *.* TO username@localhost IDENTIFIED BY 'password'; |
This file has been truncated, but you can view the full file.
This file contains hidden or 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
function getNovel(){ | |
return | |
{"title":"War and Peace","content":"The Project Gutenberg EBook of War and Peace, by Leo Tolstoy\r\n\r\nThis eBook is for the use of anyone anywhere at no cost and with\r\nalmost no restrictions whatsoever. You may copy it, give it away or\r\nre-use it under the terms of the Project Gutenberg License included\r\nwith this eBook or online at www.gutenberg.org\r\n\r\n\r\nTitle: War and Peace\r\n\r\nAuthor: Leo Tolstoy\r\n\r\nPosting Date: January 10, 2009 [EBook #2600]\r\nRelease Date: April, 2001\r\n[Last updated: August 22, 2012]\r\n\r\nLanguage: English\r\n\r\n\r\n*** START OF THIS PROJECT GUTENBERG EBOOK WAR AND PEACE ***\r\n\r\n\r\n\r\n\r\nAn Anonymous Volunteer\r\n\r\n\r\n\r\n\r\n\r\nWAR AND PEACE\r\n\r\nBy Leo Tolstoy/Tolstoi\r\n\r\n\r\n\r\n\r\n\r\nBOOK ONE: 1805\r\n\r\n\r\n\r\n\r\n\r\nCHAPTER I\r\n\r\n\r\n\"Well, Prince, so Genoa and Lucca are now just family estates of the\r\nBuonapartes. But I warn you, if you don't tell me that this means war,\r\nif you still try to de |
This file has been truncated, but you can view the full file.
This file contains hidden or 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
function getNovel(){ | |
return {"title":"War and Peace","content":"The Project Gutenberg EBook of War and Peace, by Leo Tolstoy\r\n\r\nThis eBook is for the use of anyone anywhere at no cost and with\r\nalmost no restrictions whatsoever. You may copy it, give it away or\r\nre-use it under the terms of the Project Gutenberg License included\r\nwith this eBook or online at www.gutenberg.org\r\n\r\n\r\nTitle: War and Peace\r\n\r\nAuthor: Leo Tolstoy\r\n\r\nPosting Date: January 10, 2009 [EBook #2600]\r\nRelease Date: April, 2001\r\n[Last updated: August 22, 2012]\r\n\r\nLanguage: English\r\n\r\n\r\n*** START OF THIS PROJECT GUTENBERG EBOOK WAR AND PEACE ***\r\n\r\n\r\n\r\n\r\nAn Anonymous Volunteer\r\n\r\n\r\n\r\n\r\n\r\nWAR AND PEACE\r\n\r\nBy Leo Tolstoy/Tolstoi\r\n\r\n\r\n\r\n\r\n\r\nBOOK ONE: 1805\r\n\r\n\r\n\r\n\r\n\r\nCHAPTER I\r\n\r\n\r\n\"Well, Prince, so Genoa and Lucca are now just family estates of the\r\nBuonapartes. But I warn you, if you don't tell me that this means war,\r\nif you still try to de |
This file contains hidden or 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 'pp' | |
require 'bigdecimal' | |
File.join(ENV["PWD"],'lib').tap do |lib| | |
if File.directory?(lib) | |
$LOAD_PATH.unshift(lib) unless defined?(Rails) | |
end | |
end | |
class BigDecimal |
This file contains hidden or 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 HashStruct | |
def self.new(*args) | |
Struct.new(*args) do | |
def initialize(hash) | |
super( *self.class.members.map{|k| hash[k] } ) | |
end | |
end | |
end | |
end |