Skip to content

Instantly share code, notes, and snippets.

@defunkt
defunkt / gist:226603
Created November 5, 2009 01:34
Resque Design Goals
Persistence
See what's pending
Modify pending jobs in-place
Tags
Priorities
Fast pushing and popping
See what workers are doing
See what workers have done
See failed jobs
Kill fat workers
@joshk
joshk / em_deferrable.rb
Created March 6, 2011 18:05
em deferrable faraday adapter
module Faraday
class Adapter
class EMHttpRequest < Faraday::Adapter
self.supports_parallel_requests = true
def self.setup_parallel_manager(options = {})
EMParallelManager.new
end
class EMParallelManager
@lmarburger
lmarburger / Gemfile
Created May 26, 2011 21:16
Handling exceptions with thin, eventmachine, and em-http-request.
source :gemcutter
gem 'em-http-request', :git => 'https://github.com/igrigorik/em-http-request.git'
gem 'thin'
@d11wtq
d11wtq / deliver_email_job.rb
Created August 28, 2011 04:14
Customizing ActionMailer delivery methods
# Resque job to do the true outbound sending
class DeliverEmailJob
include ProjectName::Job::Logging
@queue = :mail_queue
def self.perform(args)
message = QueuedEmail.get!(args["message_id"])
logger.info("Delivering (%s) to %s" % [message.subject, message.formatted_recipient])
@webmat
webmat / dashboards.rb
Created February 22, 2012 20:46
First draft of an active_admin-based view for Delayed::Job
ActiveAdmin::Dashboards.build do
# Add this section in your dashboard...
section "Background Jobs" do
now = Time.now.getgm
ul do
li do
jobs = Delayed::Job.where('failed_at is not null').count(:id)
link_to "#{jobs} failing jobs", admin_jobs_path(q: {failed_at_is_not_null: true}), style: 'color: red'
end
@v-yarotsky
v-yarotsky / .tmux.conf
Created March 22, 2012 11:57
Mac OS X tmux config
### INSTALLATION NOTES ###
# 1. Install Homebrew (https://github.com/mxcl/homebrew)
# 2. brew install zsh
# 3. Install OhMyZsh (https://github.com/robbyrussell/oh-my-zsh)
# 4. brew install reattach-to-user-namespace --wrap-pbcopy-pbpaste && brew link reattach-to-user-namespace
# 5. Install iTerm2
# 6. In iTerm2 preferences for your profile set:
# Character Encoding: Unicode (UTF-8)
# Report Terminal Type: xterm-256color
# 7. Put itunesartist and itunestrack into PATH
@padde
padde / chained-comparison.rb
Created April 20, 2012 15:45
chained comparison in Ruby
# Chained comparisons in Ruby
# inspired by http://coffeescript.org/#comparisons
# as well as http://refactormycode.com/codes/1284
[:<, :>, :<=, :>=].each do |operator|
[Float, Fixnum, Rational, Comparable].each do |klass|
klass.class_eval do
alias_method "_#{operator}", operator
define_method operator do |rhs|
send("_#{operator}", rhs) && rhs
@isabanin
isabanin / CVE-2012-2694.rb
Created June 14, 2012 14:42
Monkey-patching CVE-2012-2694 and CVE-2012-2695 security vulnerabilities in Rails 2.3 series
#
# About the vulnerability:
#
# http://seclists.org/oss-sec/2012/q2/503
#
# This code is for Rails 2.3 series only. Tested on 2.3.14.
#
# Put this file into lib/rails_patches directory
# then include it in one of your config/initializers.
#
@AndrewKvalheim
AndrewKvalheim / monokai.sh
Created August 31, 2012 20:22
Monokai color scheme for mintty
#!/bin/bash
# Applies the Monokai color scheme to the current terminal session.
declare -A map0
map0=( [foreground ]='#F8F8F2' [background ]='#272822'
[cursor ]='#F8F8F0' [selection ]='#49483E'
[pink ]='#F92672' [green ]='#A6E22E'
[yellow ]='#E6DB74' [blue ]='#66D9EF'
[purple ]='#AE81FF' [orange ]='#FD971F'
[gray ]='#75715E' )
@tmm1
tmm1 / ruby19_date_marshal.rb
Created February 6, 2013 06:07
Fix marshal incompatibility between Date/DateTime on 1.8 and 1.9
require 'date'
class Date
if RUBY_VERSION < '1.9'
## accept 1.9 marshaled data on 1.8
## based on ext/date/date_core.c d_lite_marshal_dump_old
def marshal_load(data)
nth, jd, df, sf, of, @sg = data
real_jd =