Skip to content

Instantly share code, notes, and snippets.

View ggaona's full-sized avatar

Gerardo Gaona ggaona

  • Mexico city
View GitHub Profile
@ggaona
ggaona / mysql-backup.sh
Last active October 22, 2020 16:19
MySQL multiple databases backup script
#!/bin/bash
# Backup multiple MySQL databases (in same host) via `mysqldump`.
# By ggaona
#
# Requirements:
#
# + mysqldump
# + MySQL password provided in '.my.cnf' file; example file:
#
@ggaona
ggaona / pre-commit
Last active May 7, 2021 00:29
Rubocop pre-commit git hook
#!/bin/bash
# Execute Rubocop before committing; aborts commit if any offense is found.
# By ggaona
# Get files to be analyzed (all staged files with '.rb' or '.rake' extension;
# ignores 'schema.rb', migrations and deleted files)
STAGED_FILES=$(git diff --name-status --cached | grep -E '\.rb|\.rake' | grep -Ev 'D|schema.rb|migrate')
# Get total count of files to be analyzed
@ggaona
ggaona / rails_docker_dev.md
Last active December 22, 2020 01:08
Rails, Webpacker, Postgresql on Docker (DEV setup)

Rails, Webpacker, Postgresql on Docker (DEV setup)

Create Rails app with docker

$ docker run --rm -it -v ${PWD}:/usr/src -w /usr/src ruby:2.7 sh -c 'gem install rails:"~> 6.0.3" && rails new --database=postgresql <app_name>'

Create Docker files

  1. cd into project directory
@ggaona
ggaona / pre-push
Created May 7, 2021 00:24
Minitest & Brakeman pre-push git hook
#!/bin/bash
# Execute tests (Minitest, Brakeman) before committing; aborts push if any
# test fails.
# By ggaona
# Execute brakeman
echo "[Brakeman]"
bundle exec brakeman --color
# Docker alternative
@ggaona
ggaona / rails7_docker_dev.md
Last active February 15, 2023 00:41
Rails 7, PostgreSQL, Redis on Docker (DEV setup)

Rails 7, PostgreSQL, Redis on Docker (DEV setup)

Create Rails app with docker

docker run --rm -it -v ${PWD}:/usr/src -w /usr/src ruby:3.2.1 sh -c 'gem install rails:"~>7.0.4" && rails new --database=postgresql <app_name>'

Create Docker files

  1. cd into project directory