Skip to content

Instantly share code, notes, and snippets.

View HelioCampos's full-sized avatar

Helio Campos Mello de Andrade HelioCampos

View GitHub Profile
@HelioCampos
HelioCampos / vim_commands.vim
Last active May 4, 2020 07:06
vim_commands
# VIM COMMANDS
## SUBSTITUTIONS
### Substitute [:<WORD>] by ['<WORD>'] on chef recipes
:1,$ s/[[]:\([^]]\+\)[]]/['\1']/gc
### Substitute pattern in mutiple lines to another thing
:1,$ s/local_action:\n module: \([^\n]\+\)/\1:/gc
### Substitute WORD => , to :WORD => node[\'fm_redis\'][\'confs\'][\'general\'][\'WORD\'], on lines 18 to 42
@HelioCampos
HelioCampos / gitflow.md
Last active November 10, 2022 22:41
Manual de git flow

GIT FLOW

Instalando

MAC OS X:

brew install git-flow

UBUNTU/LINUX:

sudo apt-get install git-flow

Inicializando

@HelioCampos
HelioCampos / gist:e789edbf2d7a79a17889
Last active April 5, 2016 13:57 — forked from jcmartins/Docker utils
Cleanup Docker Images
Delete all containers
docker rm $(docker ps -a -q)
Delete all images
docker rmi $(docker images -q)
Removes all containers running under Docker, so use with caution.
docker ps -a | awk '{print $1}' | xargs docker kill
Removing all Containers that are not running:
@HelioCampos
HelioCampos / remove_user.sh
Last active December 17, 2015 16:17
Remove user from several machines in parallel
#!/bin/bash
user=$1
regions="us sa"
sshOptions="-o BatchMode=yes -o ConnectTimeout=1 -o ConnectionAttempts=1 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=quiet"
ips=""
for region in $regions; do
ips="$ips $(tws instance list --region ${region}-east-1 | grep running | egrep -o '10\.[0-9]\.[0-9]{1,3}\.[0-9]{1,3}')"
@HelioCampos
HelioCampos / pre-commit
Created January 10, 2016 11:17 — forked from textarcana/pre-commit
Pre-commit hook that prevents debugging code and merge artifacts from being committed.
#!/bin/bash
# Pre-commit hook that prevents debugging code and merge artifacts from being committed.
FILES_PATTERN='\.(php|ctp|ctpm|css|rb|erb|haml|js|coffee)(\..+)?$'
FORBIDDEN=( "binding\.pry" "save_and_open_page" "debugger" "it\.only" "describe\.only" ">>>>>>" "<<<<<<" "======" )
# the exit code from `grep -E $FILES_PATTERN` gets swallowed unless the pipefail option is set
set -o pipefail
@HelioCampos
HelioCampos / pre-push.sh
Created January 10, 2016 11:19 — forked from textarcana/pre-push.sh
Git Hook PrePush protection for force pushing
#!/bin/sh
# Called by "git push" after it has checked the remote status,
# but before anything has been pushed.
#
# If this script exits with a non-zero status nothing will be pushed.
#
# Steps to install, from the root directory of your repo...
# 1. git config --global init.templatedir '~/.git-templates'
# 2. mkdir -p ~/.git-templates/hooks
@HelioCampos
HelioCampos / ExtractTableFromHtml.sh
Last active January 13, 2016 16:33
Extract table from HTML file
#!/bin/bash
cat $1 | sed -r -e 's/<\/tr>/<\/tr>\n/g' -e 's/<table /\n<table/g' -e 's/<\/table>/\n<\/table>/g' -e 's/[<][^>]+[>]/ /g' -e 's/&nbsp;//g'
@HelioCampos
HelioCampos / Expand ext4 inside EBS without LVM.md
Last active January 4, 2018 13:22
Expand ext4 inside EBS without LVM
  1. Careful to stop Autoscaling procedures if necessary otherwise you may loose the machine and the disk;
  2. Stop the server;
  3. Umount the disk;
  4. Create a snapshot;
  5. Create a new volume with the wanted size using the snapshot;
  6. Mount the volume in a running machine;

Using fdisk

a. Execute: fdisk /dev/xvd? according to the name you gave in (5);