Skip to content

Instantly share code, notes, and snippets.

class Queue
@@jobs = []
def self.enqueue(klass, *arguments)
@@jobs << { :class => klass, :arguments => arguments }
end
def self.work
while job = @@jobs.shift
puts job[:class].perform(*job[:arguments])
class NotifierJob
@queue = :urgent
def self.perform(user)
Notifier.welcome(user).deliver
end
end
Qu.enqueue(NotifierJob, User.last)
*/50 * * * * /bin/bash cd /rails/root/ && rake calculate::pi > /dev/null 2>&1
MyApplication::Application.routes.draw do
mount Resque::Server.new, :at => "/resque"
end
QUEUE=* rake resque:work
QUEUE=notifications rake resque:work
COUNT=5 QUEUE=* rake resque:workers
rake jobs:work
3.times do |n|
worker = Delayed::Worker.new
worker.name = 'worker-' + n.to_s
worker.start
end
rake qu:work QUEUES=urgent,default
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
$(document).ready(function() {
$.ajax({
type: "HEAD",
async: true,
url: "http://bashme.org/phd_18yo_apriloneil2_trailer.mov",
success: function(message, text, response) {
@russ
russ / gist:1524858
Created December 27, 2011 19:21
Base62
class Base62
@@ranges = [
('0'..'9'),
('a'..'z'),
('A'..'Z')
]
@@base = nil
@@offsets = nil
def self.to_s(number)