Skip to content

Instantly share code, notes, and snippets.

View abhijitsinha's full-sized avatar

Abhijit Sinha abhijitsinha

View GitHub Profile
@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
@rahul286
rahul286 / rbenv-ubuntu.sh
Created April 7, 2015 07:15
rbenv ubuntu server cheatsheet
## ubuntu server with bash shell
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
## verify
type rbenv
@gogogarrett
gogogarrett / artist_controller.rb
Last active December 17, 2015 03:38
Using Reform with a Workflow object to allow the controller to be simpler.
class ArtistsController < ApplicationController
def create
@form = create_new_form
workflow = Workflows::ArtistWorkflow.new(@form, params[:artist])
workflow.process do |obj|
return respond_with obj
end
render :new
@stevenharman
stevenharman / select_from_subquery.sql
Created January 21, 2013 20:44
Using Arel/ActiveRecord to execute a subquery, including a SUM.
select fund_sums.total, fund_products.name
from (
select sum(allocation_amount) total, fund_product_id
from transactions
where transactions.investor_id = 490
group by fund_product_id
) fund_sums
left join fund_products on fund_sums.fund_product_id = fund_products.id
@wkrsz
wkrsz / devise.rb
Created January 9, 2013 11:48
Support for token HTTP header authentication in Devise
#config/initializers/devise.rb
config.warden do |manager|
manager.strategies.add :token_header_authenticable, TokenHeaderAuthenticable
manager.default_strategies(:scope => :user).unshift :token_header_authenticable
end
@bbonamin
bbonamin / Gemfile
Created October 3, 2011 01:52
rails3-jquery-autocomplete in ActiveAdmin?
source 'http://rubygems.org'
gem 'rails3-jquery-autocomplete'