Skip to content

Instantly share code, notes, and snippets.

View wnuqui's full-sized avatar

Wilfrido Nuqui Jr. wnuqui

  • Mandaluyong, Philippines
View GitHub Profile
@wnuqui
wnuqui / gist:3038677
Created July 3, 2012 09:13
in the zone
# default zone
Time.zone # => (GMT+00:00) UTC
# then we can assign zone like use "Hawaii"
Time.zone = "Hawaii" # => "Hawaii"
# then do local using zone
local = Time.zone.local(2012, 8, 1, 15, 30, 45) # => Wed, 01 Aug 2012 15:30:45 HST -10:00
# then save this local to a column and save
@wnuqui
wnuqui / gist:3038693
Created July 3, 2012 09:17
switch zone
def Time.using_zone_of(zone)
Time.zone = zone
yield
Time.zone = 'UTC'
end
Time.using_zone_of("Hawaii") do
puts Time.zone.now
end
@wnuqui
wnuqui / gist:4653064
Last active December 11, 2015 20:09
3 bare bone rails applications using 3 jruby application servers (all running in heroku cedar)
# JAVA_OPTS and Procfiles
JAVA_OPTS: -Djruby.memory.max=384m -Xmx384m -Xms256m -Xss512k -XX:+UseCompressedOops -XX:+PrintGCDetails
# puma backed app's Procfile
web: bundle exec rails server puma -p $PORT -e $RACK_ENV
# torquebox-lite backed app's Procfile
web: bin/torquebox-lite -b 0.0.0.0 -p $PORT --max-threads=8
require "amqp"
EventMachine.run do
connection = AMQP.connect
channel = AMQP::Channel.new(connection)
replies_queue = channel.queue("", :exclusive => true, :auto_delete => true)
replies_queue.subscribe do |metadata, payload|
puts "[response] Response for #{metadata.correlation_id}: #{payload.inspect}"
end