Skip to content

Instantly share code, notes, and snippets.

@buren
buren / rails_web_console_param.rb
Last active February 13, 2016 18:16
Attach a rails web console to any page by adding ?web_console=
# config/initializers/web_console.rb
WebConsoleBeforeAction = ->(controller) do
controller.console if controller.params[:web_console]
end
ApplicationController.before_action(WebConsoleBeforeAction) if defined?(WebConsole) && Rails.env.development?
# NOTE:
# For security reasons only do this in development.
@wrburgess
wrburgess / gist:5528649
Last active November 24, 2022 15:29
Backup Heroku Postgres database and restore to local database

Grab new backup of database

Command: heroku pgbackups:capture --remote production

Response: >>> HEROKU_POSTGRESQL_COLOR_URL (DATABASE_URL) ----backup---> a712

Get url of backup download

Command: heroku pgbackups:url [db_key] --remote production

@kristopherjohnson
kristopherjohnson / gravatar.sh
Created August 13, 2012 20:21
Download Gravatar image for an email address
curl "http://gravatar.com/avatar/$(md5 -q -s myemail@example.com)" > avatar.png
@NARKOZ
NARKOZ / whitespace.rake
Created August 30, 2011 01:31
Whitespaaaaaaaace! WHITESPAAAAAAAACE!
# requires BSD sed
namespace :whitespace do
desc 'Removes trailing whitespace'
task :cleanup do
sh %{for f in `find . -type f | grep -v .git | grep -v ./vendor | grep -v ./tmp | egrep ".(rb|js|haml|html|css|sass)"`;
do sed -i '' 's/ *$//g' "$f";
done}, {:verbose => false}
puts "Task cleanup done"
end