Skip to content

Instantly share code, notes, and snippets.

@pradeepgatram
pradeepgatram / gist:3403014
Created Aug 20, 2012
Random password generator
View gist:3403014
pwd = ""; 5.times {|i| pwd += (rand(26)+97).chr};pwd += "." + rand(100000).to_s
View subscriber.rb
#...
mq = MQ.new
mq.prefetch(1) # fetching only one message at a time
bound_q = mq.queue(AMQP_CONFIG[:subscriber_queue_for_store_data])
#...
View amqp_replicator
# written by Pradeep Gatram, www.masplantiz.com
# no restrictions whatsoever on usage.
require 'rubygems'
require 'mq'
EM.run do
def replicate source, destination, topic
source_q = MQ::Queue.new(source, "replicator for #{topic}")
source_q.bind(MQ::Exchange.new(source, :topic, topic))