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 / 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 / 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 / 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 / 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.
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 / create-a-ca.md
Created June 1, 2016 17:52 — forked from gabrielfalcao/create-a-ca.md
How to create a CA to emit SSL certificates (transcription to markdown from https://www.phildev.net/ssl/creating_ca.html)

Creating a CA

Creating a Certificate Authority is easy. There are many scripts out there to do it for you. However, creating a CA that is easy to manage can be tricky. This should walk you through creating a CA and explain all the pieces.

Note: This page takes an extra step to make a fairly PKIX-compliant Certificate Authority. In pariticular, it ensures that the email address associated with your CA is in the SubjectAltName extension rather than in the DN. The former is the PKIX and X509v3 standard way of presenting an email address while the later is the old X509v1 way.

Initial Preparation

1. Create the directory your CA will live in

Command-line tools for managing Mac OS networking

Connect/Disconnect from WiFi

networksetup -setairportpower en0 off
networksetup -setairportpower en0 on

List all available WiFi's

@HelioCampos
HelioCampos / ssl.md
Last active June 1, 2016 18:05 — forked from gabrielfalcao/ssl.md
DER vs. CRT vs. CER vs. PEM Certificates and How To Convert Them Posted by Mike Harvey on 07 October 2011 09:38 PM Certificates and Encodings

At its core an X.509 certificate is a digital document that has been encoded and/or digitally signed according to RFC 5280.

In fact, the term X.509 certificate usually refers to the IETF’s PKIX Certificate and CRL Profile of the X.509 v3 certificate standard, as specified in RFC 5280, commonly referred to as PKIX for Public Key Infrastructure (X.509).

#X509 File Extensions

The first thing we have to understand is what each type of file extension is. There is a lot of confusion about what DER, PEM, CRT, and CER are and many have incorrectly said that they are all interchangeable. While in certain cases some can be interchanged the best practice is to identify how your certificate is encoded and then label it correctly. Correctly labeled certificates will be much easier to manipulat

#Encodings (also used as extensions)