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 CachedComputation | |
attr_accessor :persist, :retreive, :compute, :cache | |
def [](key) | |
prep | |
if result = @retreive[key] | |
result | |
else | |
result = @compute[key] | |
@persist[key, result] |
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
#ChronicDuration is just a random library that parses/outputs strings of time | |
#The meat of this the last expression/statement | |
%w{foo bar baz} # ["foo", "bar", "baz"] | |
ChronicDuration.parse("1:30") # 90 | |
ChronicDuration.output(90) # "1:30" | |
class Object | |
def pat(&block) # backwards of 1.9.2 method "tap" but arbitrary name |
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
guard 'rspec' do | |
watch('spec/spec_helper.rb') { "spec" } | |
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } | |
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } | |
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
30 | |
79.01, -146.66 | |
43.64, -131.04 | |
73.65, -74.58 | |
-94.01, 86.07 | |
136.93, -109.06 | |
-135.06, 156.47 | |
-152.41, 128.86 | |
131.16, -111.68 | |
-107.87, -162.49 |
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
10 | |
153.66, 178.35 | |
-69.98, 177.80 | |
-40.43, -190.60 | |
40.81, 146.07 | |
-151.05, -117.09 | |
197.53, 145.16 | |
-188.28, -100.28 | |
34.92, 16.42 | |
-194.16, -159.82 |
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
17 | |
94.94, -28.18 | |
76.47, -113.90 | |
-120.14, -181.20 | |
-115.41, 93.00 | |
-35.11, 59.41 | |
36.24, -179.82 | |
-111.93, 8.18 | |
-127.18, -80.15 | |
80.93, 117.31 |
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 'pstore' | |
class KVS | |
def self.open(path) | |
KVS.new(path) | |
end | |
def initialize(path) | |
@pstore = PStore.new path | |
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 Dir | |
def self.current | |
Dir.new(Dir.pwd) | |
end | |
def children | |
p = path | |
entries.reject{|f| f =~ /^\..*/ }.map do |name| | |
child_path = p + "/" + name | |
if File.directory? child_path |
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
#environment.rb | |
require 'active_record' | |
require 'sqlite3' | |
require 'logger' | |
ActiveRecord::Base.configurations = YAML::load(IO.read('config/database.yml')) | |
ActiveRecord::Base.establish_connection('development') | |
ActiveRecord::Base.logger = Logger.new('log/debug.log') | |
development: | |
adapter: sqlite3 |