Instantly share code, notes, and snippets.

View jquery.waituntilexists.js
;(function ($, window) {
var intervals = {};
var removeListener = function(selector) {
if (intervals[selector]) {
window.clearInterval(intervals[selector]);
intervals[selector] = null;
}
View gist:946ec092a7f9d11e2ff9
jid = 'ff07b7f9897d2472e1a4536c'
score = Time.parse('2014-05-29 11:00:00').to_f
scheduled_job = Sidekiq::ScheduledSet.new.fetch(score, jid).first
failed_job = Sidekiq::Failures::FailureSet.new.fetch(score, jid).first
View formtastic-mongoid.rb
# blog post:
require 'formtastic/version'
# Formtastic sets default input types for ActiveRecord column types. This does
# the same for Mongoid field types.
module Mongoid::Document
FORMTASTIC_2_2 = Formtastic::VERSION[/\A2\.2\.\d\z/]
# Map Mongoid field types to either ActiveRecord column types (which
View Git Configs
# Git preferences
git config push.default current
# Some useful git aliases
## Basics
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
View uniq_value_counts.rb
#
# Returns a hash of all unique values for a given field and the number of objects
# in the array which have that value.
# ex:
# Post.all.uniq_value_counts(:status)
# => {
# "published" => 10,
# "draft" => 13,
# "archived" => 34
# }
View gist:4569326
LOCAL_MARKET_DISTRIBUTION = [
[4.5, 5.0],
[6, 4.5],
[8, 4.0],
[10.5, 3.5],
[13, 3.0],
[16, 2.5],
[21, 2.0],
[17, 1.5],
[4, 1.0],
View acceptance.rake
if defined?(RSpec)
namespace :spec do
desc 'Run the acceptance specs in spec/acceptance'
task :acceptance => :environment do
exec 'rspec spec --tag acceptance'
end
end
end
View gist:2932908
<html><body style=\"width: 653px; font-family: Arial; font-size: 12px; background-color: #cccccc;\" bgcolor=\"#cccccc\">\n \n \n <OpenTracking />\n \n <table style=\"font-family: Arial; width: 653px; background-color: #ffffff; border: 1px solid #999;\" bgcolor=\"#ffffff\">\n <tr>\n <td style=\"width: 653px;\">\n <a href=\"http://www.dealradar.com/deals/chicago?src=email&utm_source=custom_digest&utm_medium=email&utm_term=header&utm_campaign=chicago\" style=\"color: #027986; text-decoration: none;\"><img alt=\"\" src=\"http://s3.amazonaws.com/dealradar_assets/email_assets/email_header.png\" style=\"border: none;\" border=\"0\" /></a>\n <h1 style=\"margin-top: 15px; margin-left: 20px; margin-bottom: 0px; font-size: 15px; font-family: Arial; color: #027986;\">Local Deals in Chicago - Thursday June 14, 2012</h1>\n <p style=\"font-family: Arial; margin-top: 5px; padding-top: 0px; font-size: 12px; margin-left: 20px; padding-bottom: