Skip to content

Instantly share code, notes, and snippets.

@softr8
softr8 / gist:6466376
Created September 6, 2013 16:39
nginx config params
./configure \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--user=www-data \
--group=www-data \
--without-mail_pop3_module \
--without-mail_imap_module \
--without-mail_smtp_module \
--without-http_fastcgi_module \
@softr8
softr8 / gist:3815777
Created October 2, 2012 02:12
SG 1 oct
# Como usarlo:
# ruby sleep.rb "6:15 AM"
# ruby sleep.rb
require 'date'
require 'time'
desired_hour = ARGV.first || "7 AM"
wakeup_at = Time.parse("#{Date.today} #{desired_hour}")
@softr8
softr8 / gist:2955680
Created June 19, 2012 18:13
Rails cache wrapper
module MyApp
# See ActiveSupport::Cache::Store for documentation.
module Cache
class << self
def fetch(key, options = {}, &block)
if block_given?
if ActionController::Base.perform_caching && options && options[:expires_in].to_i > 0
Rails.cache.fetch(key, options, &block)
else
yield
@softr8
softr8 / gist:1035981
Created June 20, 2011 16:53
Mocking methods at instance level
class Una
def get
"Esta es una prueba"
end
end
dos = Class.new(Una) do
def get
"desde aca"
end
@softr8
softr8 / gist:972462
Created May 14, 2011 18:07
ruby 1.9.2 and ticketmaster
ruby-1.9.2-p180 :009 > driver.projects.first.tickets
RuntimeError: can't typecast "252"
from /Users/ecruz/.rvm/gems/ruby-1.9.2-p180@panorama/gems/activesupport-3.0.6/lib/active_support/core_ext/hash/conversions.rb:96:in `typecast_xml_value'
from /Users/ecruz/.rvm/gems/ruby-1.9.2-p180@panorama/gems/activesupport-3.0.6/lib/active_support/core_ext/hash/conversions.rb:118:in `block in typecast_xml_value'
from /Users/ecruz/.rvm/gems/ruby-1.9.2-p180@panorama/gems/activesupport-3.0.6/lib/active_support/core_ext/hash/conversions.rb:117:in `each'
from /Users/ecruz/.rvm/gems/ruby-1.9.2-p180@panorama/gems/activesupport-3.0.6/lib/active_support/core_ext/hash/conversions.rb:117:in `inject'
from /Users/ecruz/.rvm/gems/ruby-1.9.2-p180@panorama/gems/activesupport-3.0.6/lib/active_support/core_ext/hash/conversions.rb:117:in `typecast_xml_value'
from /Users/ecruz/.rvm/gems/ruby-1.9.2-p180@panorama/gems/activesupport-3.0.6/lib/active_support/core_ext/hash/conversions.rb:78:in `from_xml'
from /Users/ecruz/.rvm/gems/ruby-1