Skip to content

Instantly share code, notes, and snippets.

@abstractcoder
abstractcoder / dokku
Created January 14, 2015 20:53
Shell script for executing remote Dokku commands using Heroku like syntax (e.g. dokku run rake db:migrate, dokku logs -t). Replace example.com with your hostname, and www with your Dokku app name.
#!/bin/bash
ssh -t dokku@example.com $1 www ${*:2}
@abstractcoder
abstractcoder / confirm.js
Created November 19, 2014 17:57
Custom Rails confirmation dialog with SweetAlert
jQuery(function() {
// Override rails confirm function
$.rails.confirm = function(msg) { return true; }
// Unbind any click handlers (optional), create custom handler
$('[data-confirm]').unbind('click').click(function(evt){
// Get the target
var $target = $(this);
// Check if the action has already been confirmed
if ($target.data('confirmed') == true) {
@abstractcoder
abstractcoder / import.rake
Last active December 18, 2016 12:35
Rails Rake task for restoring your latest Heroku database locally. Add this to a new or existing .rake file under lib/tasks and run it from command line using rake db:restore
namespace :db do
desc "Restore latest Heroku db backup locally"
task restore: :environment do
# Get the current db config
config = Rails.configuration.database_configuration[Rails.env]
# Get around an issue with the Heroku Toolbelt https://github.com/sstephenson/rbenv/issues/400#issuecomment-18742700
Bundler.with_clean_env do
# Download the latest backup to a file called latest.dump in tmp folder
`curl -o tmp/latest.dump \`heroku pg:backups public-url -q --remote production\``
# Restore the backup to the current database