Skip to content

Instantly share code, notes, and snippets.

--color
--format documentation
@pvcarrera
pvcarrera / .rubocop.yml
Last active August 29, 2015 14:07
Rubocop conf
Documentation:
Enabled: false
Style/LineLength:
Max: 110
AllCops:
Exclude:
- 'db/**/*'
- 'config/**/*'
- 'script/**/*'
- 'spec/spec_helper.rb'
@pvcarrera
pvcarrera / heroku.rake
Last active August 29, 2015 14:21
Heroku Rake tasks
namespace :heroku do
DEFAULT_APP = 'my_app'
desc 'Create database backup'
task :backup, :app do |task, args|
args.with_defaults(app: DEFAULT_APP)
Bundler.with_clean_env do
`heroku pg:backups capture --app #{args[:app]}`
end
@pvcarrera
pvcarrera / sample_data.rake
Last active October 11, 2023 00:56
Load Rails fixtures ignoring PostgreSQL constraints
namespace :db do
desc 'Reset and populate sample data'
task populate_sample_data: [:reset, :drop_constraints, 'fixtures:load', :create_constraints] do
puts 'Fixtures loaded in the database'
end
desc 'Remove all database constraints'
task drop_constraints: [:environment, :create_constraints_script, :drop_constraints_script] do
ActiveRecord::Base.connection.execute(IO.read('tmp/drop_constraints.sql'))
puts 'Constraints dropped'
#!/bin/sh
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'
NC='\033[0m'
# Get only the staged files
FILES="$(git diff --cached --name-only --diff-filter=AMC | grep "\.rb$" | tr '\n' ' ')"
#!/bin/bash
HOOKS="pre-commit-rspec pre-commit-rubocop"
for hook in $HOOKS; do
if [ -f "$PWD/.git/hooks/$hook" ]; then
"$PWD/.git/hooks/$hook"
if [ $? != 0 ]; then
exit 1
fi
else

Keybase proof

I hereby claim:

  • I am pvcarrera on github.
  • I am pvcarrera (https://keybase.io/pvcarrera) on keybase.
  • I have a public key whose fingerprint is 2814 1698 E300 ACF4 21EB 3230 6AC4 A68A 9C82 0938

To claim this, I am signing this object: