Skip to content

Instantly share code, notes, and snippets.

@wangmh
wangmh / mysql time
Created May 3, 2012 03:29
mysql time
select id from chouti_links where pool = 0 and (createTime > (unix_timestamp(now())-86400)*1000000) order by score desc limit 1
@wangmh
wangmh / eventmachine.rb
Created April 6, 2012 08:07 — forked from joshuasiler/eventmachine.rb
Initializer that allows EventMachine to run within Rails, and work with AMQP, Passenger, Thin and Capybara
require 'amqp'
module HiringThingEM
def self.start
if defined?(PhusionPassenger)
PhusionPassenger.on_event(:starting_worker_process) do |forked|
# for passenger, we need to avoid orphaned threads
if forked && EM.reactor_running?
EM.stop
end
Thread.new {