Skip to content

Instantly share code, notes, and snippets.

View HelioCampos's full-sized avatar

Helio Campos Mello de Andrade HelioCampos

View GitHub Profile
0 = Success
1 = Operation not permitted
2 = No such file or directory
3 = No such process
4 = Interrupted system call
5 = Input/output error
6 = No such device or address
7 = Argument list too long
8 = Exec format error
@HelioCampos
HelioCampos / openvpn.md
Created May 5, 2016 14:54 — forked from Morley93/openvpn.md
This is how you can take an openvpn .ovpn config file and extract the certificates/key required to import the profile into NetworkManager.

OpenVPN .ovpn manipulation.

This is how you can take an OpenVPN .ovpn config file and extract the certificates/keys required to import the profile into NetworkManager.

  • Download the .ovpn file. Save it somewhere you can store it permanently (I use ~/.vpn).
  • Copy from between <ca> tags into ca.crt, remove <ca> tags.
  • Copy from between <cert> tags into client.crt, remove <cert> tags.
  • Copy from between <key> tags into client.key, remove <key> tags.
  • Copy from between <tls-auth> tags into ta.key, remove <tls-auth> tags.
  • Remove the line "key-direction 1"
  • Above "# -----BEGIN RSA SIGNATURE-----" insert the following lines.
@HelioCampos
HelioCampos / backup-github.sh
Created April 11, 2016 21:34 — forked from rodw/backup-github.sh
A simple script to backup an organization's GitHub repositories, wikis and issues.
#!/bin/bash
# A simple script to backup an organization's GitHub repositories.
# NOTE: if you have more than 100 repositories, you'll need to step thru the list of repos
# returned by GitHub one page at a time, as described at https://gist.github.com/darktim/5582423
GHBU_BACKUP_DIR=${GHBU_BACKUP_DIR-"github-backups"} # where to place the backup files
GHBU_ORG=${GHBU_ORG-"<CHANGE-ME>"} # the GitHub organization whose repos will be backed up
# (if you're backing up a user's repos instead, this should be your GitHub username)
GHBU_UNAME=${GHBU_UNAME-"<CHANGE-ME>"} # the username of a GitHub account (to use with the GitHub API)
@HelioCampos
HelioCampos / patch_generator.sh
Last active April 1, 2016 19:40
Generare or apply patches
#!/bin/bash
if [ #$ -ne 3 ]; then
echo "You need to pass, respectively, the operation (patch|apply), the old and the new versions of the file."
exit
fi
OPERATION=$1
OLD=$2
NEW=$3
@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);

@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 / 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 / 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