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 'ostruct' | |
# OpenStruct | |
class OStruct | |
def initialize | |
@attributes = {} | |
end | |
def method_missing(name, arg = nil) | |
if name.to_s =~ /=/ | |
@attributes[name.to_s.sub(%r{=}, '')] = arg |
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
# This FSM recognizes the sequence 1 2 3 anywhere in the | |
# input. Note that 1 2 1 2 3 and 1 1 2 3 and both valid. | |
class FSM | |
class State | |
def initialize(name) | |
@name = name | |
@hash = {} | |
end |
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
defaults write com.macromates.textmate OakDefaultLanguage E00B62AC-6B1C-11D9-9B1F-000D93589AF6 |
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
namespace :test do | |
desc 'Measures test coverage' | |
task :coverage do | |
rm_f "coverage" | |
rm_f "coverage.data" | |
rcov = "rcov --rails --aggregate coverage.data --text-summary -Ilib -Itest -x /ruby\/1.8\/gems -x /Gems\/1\.8 -x /Library\/Ruby -x /Library\/Frameworks" | |
system("#{rcov} --no-html test/unit/*_test.rb") | |
system("#{rcov} --no-html test/functional/*_test.rb") | |
system("#{rcov} --html test/integration/*_test.rb") |
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
Bennett.get "/blog" do | |
"Hello World" | |
end | |
Bennett.get "/home" do | |
"<html><body><h1>Welcome to my home page!</h1> | |
Look at my <a href='/blog'>Blog</a>. | |
</body></html>" | |
end |
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 'webrick' | |
class MyServlet < WEBrick::HTTPServlet::AbstractServlet | |
def do_GET(request, response) | |
response.body = "Whatever you want" | |
end | |
end | |
server = WEBrick::HTTPServer.new(:Port => 8082) | |
server.mount "/whatever", MyServlet |
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
$ sudo gem search -r calendar_date_select | |
*** REMOTE GEMS *** | |
artmotion-calendar_date_select (1.10.9) | |
atd-calendar_date_select (1.15) | |
batasrki-calendar_date_select (1.13.3) | |
calendar_date_select (1.15) | |
DavidWhite-calendar_date_select (1.15.6) | |
edwinmoss-calendar_date_select (1.11.1) |
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
select joy_journeys.id from joy_journeys, memberships, profiles, circles | |
INNER JOIN memberships on memberships.circle_id = circles.id | |
INNER JOIN profiles on memberships.profile_id = profiles.id | |
INNER JOIN joy_journeys on joy_journeys.profile_id = profiles.id | |
WHERE circles.id = #{self.id} |
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 A | |
end | |
class B < A | |
end | |
module X | |
end | |
A.send(:include, X) |
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 Thing | |
end | |
class SubThing < Thing | |
end | |
module IneffectiveOverride | |
end | |
Thing.send(:include, IneffectiveOverride) |