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
( roughly to the tune of the Ultraman theme song: | |
http://www.televisiontunes.com/Ultraman.html ) | |
Tenderlove, Tenderlove | |
Ruby programming guy | |
Tenderlove, Tenderlove | |
he's as awesome as _why | |
Seattle is his home | |
he's a Ruby brigadier |
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 'rubygems' | |
require 'rack' | |
class Object | |
def webapp | |
class << self | |
define_method :call do |env| | |
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?) | |
[200, {}, send(func, *attrs)] | |
end |
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 Numeric | |
def to_rad | |
self * Math::PI / 180 | |
end | |
end | |
# http://www.movable-type.co.uk/scripts/latlong.html | |
# loc1 and loc2 are arrays of [latitude, longitude] | |
def distance loc1, loc2 | |
lat1, lon1 = loc1 |
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 Crypto | |
class UnexpectedAlgorithmException < Exception | |
end | |
class << self | |
def hashtext thing, *extras | |
Digest::SHA1.hexdigest(([thing] + extras).join(" ")) | |
end | |
# Always returns a different hex salt, using +extras+ for added |
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
# this is a stupid simple random stringifier | |
"#{10.times.map{(rand(26) + 97).chr}.join}_#{Time.now.to_i.to_s}" | |
#=> "qnoqszbiam_1285701912" |
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
awk '{ sub(/([0-9]+\.?)+/, ":id", $3); | |
sub(/[0-9]+/, ":id", $3); | |
sub(/=.*&/, "=:param\\&", $3); | |
sub(/=.*$/, "=:param", $3); | |
sub(/\?[:a-z0-9]+$/, "", $3); | |
print $1, $2, $3, $4 | |
}' | sort | uniq -c | sort |
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
namespace :test do | |
desc "Ensures there are no dependencies between test classes." | |
task :each => %w(each:functional each:unit each:integration) | |
namespace :each do | |
def each_test(tests) | |
# This is where the magic happens | |
ENV['TESTOPTS'] = '--verbose=progress' unless ENV['TESTOPTS'] | |
tests.each do |path| | |
puts "\n#{path}" |