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
def gimme_class | |
eval %{ | |
class MethodClass | |
def where_am_i? | |
puts "in method!" | |
end | |
end | |
} | |
obj = MethodClass.new |
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
def gimme_class | |
method_class = Class.new do | |
def where_am_i? | |
puts "in method!" | |
end | |
end | |
obj = method_class.new | |
obj.where_am_i? | |
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
def gimme_class | |
class MethodClass | |
def where_am_i? | |
puts "in method!" | |
end | |
end | |
obj = MethodClass.new | |
obj.where_am_i? | |
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
# Date.parse() with Ruby 1.9 is now defaulting to the European date style where the format is DD/MM/YYYY, not MM/DD/YYYY | |
# patch it to use US format by default | |
if RUBY_VERSION >= '1.9' | |
class String | |
def to_date | |
if self.blank? | |
nil | |
elsif self =~ /(\d{1,2})\/(\d{1,2})\/(\d{4})/ | |
::Date.civil($3.to_i, $1.to_i, $2.to_i) | |
else |
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
# ruby 1.9.2 | |
> Date._parse("11/15/2010", false).values_at(:year, :mon, :mday) | |
=> [2010, 15, 11] | |
# ruby 1.8 | |
> Date._parse("11/15/2010", false).values_at(:year, :mon, :mday) | |
=> [2010, 11, 15] |
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 'autotest/growl' | |
Autotest::Growl::clear_terminal = false |
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
$ rvm use ree@global | |
$ gem install ZenTest autotest-rails autotest-growl |
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
server { | |
listen 80; | |
server_name SERVER_NAME; | |
root PATH_TO_PUBLIC; | |
passenger_enabled on; | |
# serve static files directly | |
location ~ .html { | |
root PATH_TO_PUBLIC; | |
} |
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
# %SerialObject types saved as string represents all object properties separated by commas, | |
# for example HM.TimeStampClass may look like "2004-04-16 03:20:07,BOB,2010-06-04 05:25:04,NJM,,117604" | |
# 1. Create a TimeStamp class that wrap %SerialObject | |
# Note the importance of the attributes declaration order, they will be mapped to string in this order | |
# Also you can override default mapping order via mapping method: | |
# def mapping | |
# [:attribute2, :attribute1, ...] | |
# end | |
class TimeStamp < Intersys::Serial::Object |
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
server { | |
listen 80 default; | |
server_name _; | |
set $domain $host; | |
if ($domain ~ "^(w{3}\.)?(.*?)\.com") { | |
set $domain $2; | |
} | |
location / { |