Because loading gems can take longer than you think
Now available as a gem - get it here
license: unlicense |
# 1. Extend Chosen with custom method or owerwrite existing methods | |
class CustomChosen extends Chosen | |
show_search_field_default: -> | |
# ... | |
# original method updated | |
# ... | |
some_new_method: -> | |
# ... | |
# config/deploy.rb | |
namespace :upstart do | |
desc 'Generate and upload Upstard configs for daemons needed by the app' | |
task :update_configs, except: {no_release: true} do | |
upstart_config_files = File.expand_path('../upstart/*.conf.erb', __FILE__) | |
upstart_root = '/etc/init' | |
Dir[upstart_config_files].each do |upstart_config_file| | |
config = ERB.new(IO.read(upstart_config_file)).result(binding) |
# http://stackoverflow.com/questions/14972253/simpleform-default-input-class | |
# https://github.com/plataformatec/simple_form/issues/316 | |
inputs = %w[ | |
CollectionSelectInput | |
DateTimeInput | |
FileInput | |
GroupedCollectionSelectInput | |
NumericInput | |
PasswordInput |
#!/bin/bash | |
# sidekiq Init script for Sidekiq | |
# chkconfig: 345 100 75 | |
# | |
# Description: Starts and Stops Sidekiq message processor for Stratus application. | |
# | |
# User-specified exit parameters used in this script: | |
# | |
# Exit Code 5 - Incorrect User ID | |
# Exit Code 6 - Directory not found |
Because loading gems can take longer than you think
Now available as a gem - get it here
This Presentation was built to be viewed with GistDeck
Rails.application.config.compass.line_comments = false | |
sass_compiler = Compass::Compiler.new(Rails.root, Compass.configuration.sass_path, Compass.configuration.css_path, sass: Compass.sass_engine_options) | |
engine = sass_compiler.engine(sass_filepath, File.join(Compass.configuration.css_path, "dummy.css")) | |
css_string = engine.render |
module Retriable | |
# This will catch any exception and retry twice (three tries total): | |
# with_retries { ... } | |
# | |
# This will catch any exception and retry four times (five tries total): | |
# with_retries(:limit => 5) { ... } | |
# | |
# This will catch a specific exception and retry once (two tries total): | |
# with_retries(Some::Error, :limit => 2) { ... } | |
# |
num_processes = 2 | |
batch_size = 1000 | |
threads_per_process = 10 | |
Parallel.map(0...num_processes, :in_processes => num_processes) do |i|· | |
User.connection.reconnect! | |
User.find_in_batches(:batch_size => batch_size,· | |
:start => (User.count/num_processes) * i,· | |
:conditions => ["id <= ?", (User.count/num_processes)*(i+1)]) do |batch|· | |
Parallel.map(batch, :in_threads => threads_per_process) do |record| |