Skip to content

Instantly share code, notes, and snippets.

View semarco's full-sized avatar

Marco Sehrer semarco

View GitHub Profile
@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
@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 / dev-tools.md
Last active December 17, 2015 14:39
misc Dev Tools & Resources
@semarco
semarco / DCI_experiments.rb
Created June 20, 2013 06:09
experiment with module extend vs delegation
require 'delegate'
class D < SimpleDelegator
def foo
puts "foo #{self} #{self.class}"
end
end
D.new("jojo").foo