Skip to content

Instantly share code, notes, and snippets.

View darrenterhune's full-sized avatar

Darren Terhune darrenterhune

  • Canada
View GitHub Profile
@rlmattax
rlmattax / gist:3962926
Created October 27, 2012 04:20
Active Admin User Impersonation
ActiveAdmin.register User do
menu :parent => "Users"
member_action :impersonate, :method => :get do
user = User.find(params[:id])
flash[:notice] = "Successfully logged in as : #{user.email} #{view_context.link_to('Be careful!', root_path)}".html_safe
begin
warden.set_user(resource,{:scope=>:user,:run_callbacks=>false})
rescue
flash[:error] = "Unable to log you in. Poop."
# an example Monit configuration file for delayed_job
#
# To use:
# 1. copy to /var/www/apps/{app_name}/shared/delayed_job.monitrc
# 2. replace {app_name} and {environment} as appropriate
# 3. add this to your /etc/monit/monitrc
#
# include /var/www/apps/{app_name}/shared/delayed_job.monitrc
check process delayed_job with pidfile /var/www/apps/{app_name}/shared/pids/delayed_job.pid
@tedgrubb
tedgrubb / ttransparency.rb
Last active May 4, 2017 17:33
Paperclip Processor that finds the background color and replaces it with a transparent background. Also simulates anti-aliasing using '-fuzz' to get rid of pixelated artifacts.
# lib/paperclip_processors/transparency.rb
module Paperclip
class Transparency < Thumbnail
# Find the background and replace with transparency.
# -fuzz 20% simulates antialiasing
CONVERT_OPTIONS = [
'-alpha', 'set',
'-fill', 'white',
'-draw', "'color 0,0 replace'",
@Amitesh
Amitesh / gist:1160428
Created August 21, 2011 10:10
Paperclip file name cleanup or rename
#http://blog.wyeworks.com/2009/7/13/paperclip-file-rename
Paperclip.interpolates :default_image_type do |attachment, style|
attachment.instance.get_user_default_profile_image
end
Paperclip.interpolates :normalized_avatar_file_name do |attachment, style|
attachment.instance.normalized_avatar_file_name
end
@MicahChalmer
MicahChalmer / .htaccess
Last active May 1, 2016 16:49
Scripts to set up Ruby 1.9.3 on a DreamHost shared hosting account via rbenv and ruby-build, and run a Rack app with it via FastCGI.
<IfModule mod_fastcgi.c>
AddHandler fastcgi-script .fcgi
</IfModule>
<IfModule mod_fcgid.c>
AddHandler fcgid-script .fcgi
</IfModule>
Options +FollowSymLinks +ExecCGI
RewriteEngine On
@xaviershay
xaviershay / build_frontend.sh
Last active December 24, 2015 20:49
SASS + Coffee + Concatenation in prod
#!/bin/bash
set -exo pipefail
BUILD_ENV=$1
if [ `uname` == 'Darwin' ]; then
OSX=1
JSCOMPRESSOR="yuicompressor --type js"
else
OSX=
@ryanb
ryanb / spec_helper.rb
Created September 12, 2011 21:29
Focus on specific specs in RSpec
# add this to your spec helper
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.filter_run :focus => true
config.run_all_when_everything_filtered = true
end
# and then use the :focus tag in your specs
it "does something awesome", :focus do
@jgarber
jgarber / gist:1993171
Created March 7, 2012 13:38
Remove default field sizes in Rails 3.2.2
class ActionView::Helpers::InstanceTag
DEFAULT_FIELD_OPTIONS.delete("size")
DEFAULT_TEXT_AREA_OPTIONS.delete("rows")
DEFAULT_TEXT_AREA_OPTIONS.delete("cols")
end