Skip to content

Instantly share code, notes, and snippets.

View jagira's full-sized avatar
🙃

Jigar Patel jagira

🙃
View GitHub Profile
@jagira
jagira / pg_backup_and_restore.sh
Created February 6, 2018 05:21
Commands to take backup and restore a PostgreSQL database
# Take backup
pg_dump -F c -v DATABASE_NAME -f FILENAME.sql
# Restore from backup
pg_restore --verbose --clean --no-owner --no-acl --dbname DATABASE_NAME FILENAME.sql
@jagira
jagira / db.rake
Created July 13, 2017 11:53 — forked from hopsoft/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
@eparreno
eparreno / RSpec - ActionMailer
Created July 7, 2010 05:54
RSpec ActionMailer test
# config/environments/test.rb
ActionMailer::Base.delivery_method = :test
# spec/models/mailer_spec.rb
describe Mailer do
before(:each) do
ActionMailer::Base.deliveries = []
end
it 'should send some random email' do