Skip to content

Instantly share code, notes, and snippets.

@wbotelhos
wbotelhos / clear-sidekiq-jobs.sh
Last active April 2, 2024 10:04
Clear Sidekiq Jobs
require 'sidekiq/api'
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear
@jacobpatton
jacobpatton / mrr.rb
Last active July 10, 2016 18:08
For a SAAS business, monthly recurring revenue (MRR) is their bread and butter. This small class fetches subscription records from Stripe to calculate the MRR.
require 'stripe'
# Find the MRR for a given Stripe account.
#
# (To do this it simply finds the total amount for all active
# subscriptions (in cents). For most SAAS accounts, this is
# enough, though modification is necessary to account for
# things like trials, discounts, pro-rated cancellations, etc.)
#
# {stripe_id: YOUR_STRIPE_SECRET_KEY} - A hash with the key "stripe_id" and the correct secret key
@jwo
jwo / remove-this-sf_bs3_inputs.rb
Created August 15, 2013 15:50
Simple Form 3 & Bootstrap 3
#config/initializers/remove-this-sf_bs3_inputs.rb
#Credit: https://github.com/rafaelfranca/simple_form-bootstrap/issues/26#issuecomment-22435894
inputs = %w[
CollectionSelectInput
DateTimeInput
FileInput
GroupedCollectionSelectInput
NumericInput
@wrburgess
wrburgess / gist:3778949
Created September 24, 2012 22:54
Setup wicked_pdf and wkhtmltopdf with Rails 3 and Heroku
@karmi
karmi / geo_distance_filter_in_tire.rb
Created June 28, 2011 14:13
Geo Distance Filter Support in Tire/ElasticSearch
require 'tire'
require 'active_support/core_ext/numeric'
require 'active_support/core_ext/time/zones'
# Tire.configure { logger STDERR, level: 'debug' }
class Time; DATE_FORMATS.update lucene: "%Y-%m-%dT%H:%M"; end
Tire.index 'venues' do
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')