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 'sinatra' | |
require 'activerecord' | |
require 'sqlite3' | |
configure do | |
ActiveRecord::Base.establish_connection( | |
:adapter=>'sqlite3', :dbfile=>'delish.db') | |
@results = ActiveRecord::Base.connection.execute(<<-TABLESQL) |
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
Who: Aaron Blohowiak, copyright 2008 (c) FooMojo, Inc. MIT license. | |
Why: The Goal of Play It Once, Sam (henceforth: PIOS) is to bring programming | |
best practices to projects that haven't followed them. | |
What: In achieving this goal, PIOS is presently a tool that creates Integration | |
Tests. | |
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
# Behavior filter turns method names into select/reject filters | |
# Example | |
# class User | |
# has_manny :comments, :extend => BehaviorFilter | |
# end | |
module BehaviorFilter | |
# creates magic methods like these | |
# user.comments.from_blocked_commentors | |
# # => user.comments.select{ |c| user.blocking?(c.commentor) } |
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
def inspect_it(name, thing) | |
%w{to_s class inspect}.each do |m| | |
print "#{name}.#{m}: "+ thing.send(m.to_sym)+"\n" | |
end | |
end | |
set_trace_func proc { |event, file, line, id, binding, classname| | |
%w{event file line id binding classname}.each do |arg| | |
inspect_it(arg, eval(arg)) | |
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
>> a = Hash.new({}) | |
=> {} | |
>> a["hi"]["pants"] = "clamdiggers" | |
=> "clamdiggers" | |
>> a.inspect | |
=> "{}" | |
>> a["hi"] | |
=> {"pants"=>"clamdiggers"} | |
>> #hmmmmm... | |
>> |
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 'ostruct' | |
class Pearl < OpenStruct | |
alias_method :open_structs_method_missing, :method_missing | |
def method_missing(meth, *args) | |
if meth.to_s =~ /=$/ | |
open_structs_method_missing(meth, *args) | |
else | |
self.new_ostruct_member(meth) |
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 'sinatra' | |
require 'open-uri' | |
require 'java' | |
require File.dirname(__FILE__)+"/jtidy-r938.jar" | |
Dir.glob(File.dirname(__FILE__)+"/flyingsaucer/*.jar").each do |f| | |
require f | |
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 Face | |
love = 5 | |
get_love = Proc.new{ love } | |
puts get_love.call | |
define_method :get_love, &get_love | |
def love | |
:wtf_lol | |
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
#these are different!!! | |
(1..10).each do |i| | |
if i < 5 | |
puts i | |
else | |
break | |
end | |
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
i=0 | |
10.times{ ++i ; puts i} |
OlderNewer