Skip to content

Instantly share code, notes, and snippets.

# 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 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
defaults write com.macromates.textmate OakDefaultLanguage E00B62AC-6B1C-11D9-9B1F-000D93589AF6
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")
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
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
$ 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)
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}
class A
end
class B < A
end
module X
end
A.send(:include, X)
class Thing
end
class SubThing < Thing
end
module IneffectiveOverride
end
Thing.send(:include, IneffectiveOverride)