Skip to content

Instantly share code, notes, and snippets.

@baya
baya / README.markdown
Created January 21, 2012 09:15 — forked from AndorChen/README.markdown
Howto Depoly Rails App to VPS

#如何将 Rails 应用程序部署到 VPS 上

如果已经在 VPS 上假设好了 Rails 生产环境,接下来就可以将部署应用程序了。

###需要用到的工具


@baya
baya / ruby-blocks-as-dynamic-callbacks.rb
Created December 6, 2011 04:29
ruby blocks as dynamic callbacks
# From http://www.mattsears.com/articles/2011/11/27/ruby-blocks-as-dynamic-callbacks
class Proc
def callback(callable, *args)
self === Class.new do
method_name = callable.to_sym
define_method(method_name) { |&block| block.nil? ? true : block.call(*args) }
define_method("#{method_name}?") { true }
def method_missing(method_name, *args, &block) false; end
end.new
@baya
baya / rubber.rb
Created November 10, 2010 09:10
help method for visting a url
module Rubber
def self.try(diftimes = [3, 8, 2], options = { }, &block)
val = timeout(diftimes.shift) do
block.call
end
rescue options[:on] || Exception => e
Rails.logger.info("#{Time.now}:#{__FILE__}:#{__LINE__}}:#{e.backtrace.join("\n")}")
retry if diftimes.first
return ""