Skip to content

Instantly share code, notes, and snippets.

View keybase.md

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:

View pre-commit-hub
#!/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
View pre-commit-rubocop
#!/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' ' ')"
@pvcarrera
pvcarrera / sample_data.rake
Last active Feb 22, 2020
Load Rails fixtures ignoring PostgreSQL constraints
View sample_data.rake
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'
@pvcarrera
pvcarrera / heroku.rake
Last active Aug 29, 2015
Heroku Rake tasks
View heroku.rake
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
View .rubocop.yml
Documentation:
Enabled: false
Style/LineLength:
Max: 110
AllCops:
Exclude:
- 'db/**/*'
- 'config/**/*'
- 'script/**/*'
- 'spec/spec_helper.rb'
View .rspec
--color
--format documentation