Skip to content

Instantly share code, notes, and snippets.

View semarco's full-sized avatar

Marco Sehrer semarco

View GitHub Profile
@semarco
semarco / gist:3136990
Created July 18, 2012 15:37
em::hiredis example
EM.run do
c = EM::Hiredis.connect('redis://127.0.0.1:6379/0')
puts c.inspect
c.callback {puts 'connected'};
c.errback {puts 'error'}
c.publish('test', 'foo:bar').tap do |r|
r.callback {puts 'request with success'};
r.errback { |e| puts 'request with error'; puts e.inspect}
end
end
@semarco
semarco / utc-times.rb
Created July 11, 2012 13:50 — forked from ayosec/utc-times.rb
Force UTC times
class Hash
def times_with_utc
dup.tap do |new_hash|
each_key do |key|
value = self[key]
if ActiveSupport::TimeWithZone === value
new_hash[key] = value.utc
elsif Array === value || Hash === value
new_hash[key] = value.times_with_utc
end