Skip to content

Instantly share code, notes, and snippets.

View johnbianchi's full-sized avatar

John Bianchi johnbianchi

View GitHub Profile
@johnbianchi
johnbianchi / VagrantFile
Created February 21, 2021 06:07 — forked from shadyvb/VagrantFile
VagrantFile hack to auto-create ssh-config entries for vagrant machines
Vagrant.configure("2") do |config|
config.trigger.after :up,
name: "Caching vagrant ssh-config for '#{CONF['hosts'].join('\' and \'')}'",
ruby: proc{|env,machine| puts `mkdir ~/.ssh/config.d &>/dev/null; vagrant ssh-config | sed 's/Host default/Host #{CONF['hosts'].join(" ")}/' | tee ~/.ssh/config.d/vagrant-#{CONF['hosts'][0]} >/dev/null; bash -c "if ! grep -q 'Include ~/.ssh/config.d/*' ~/.ssh/config; then echo '> Please add the following line to your ~/.ssh/config file: Include ~/.ssh/config.d/*'; fi"`}
end
@johnbianchi
johnbianchi / ansible-dynamic-inventory-converter.py
Created August 24, 2020 17:30 — forked from DavidWittman/ansible-dynamic-inventory-converter.py
Script for converting Ansible dynamic inventory to static files. It's not perfect, but it'll get you 90% of the way there.
#!/usr/bin/env python
# Converts Ansible dynamic inventory sources to static files
# Input is received via stdin from the dynamic inventory file
# ex:
# ec2.py --list | ansible-dynamic-inventory-converter.py
import json
import os
import sys
@johnbianchi
johnbianchi / get_latest_release.sh
Created March 4, 2019 20:44 — forked from lukechilds/get_latest_release.sh
Shell - Get latest release from GitHub
get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
# Usage
# $ get_latest_release "creationix/nvm"
# v0.31.4
@johnbianchi
johnbianchi / sed cheatsheet
Created February 18, 2019 17:22 — forked from un33k/sed cheatsheet
magic of sed -- find and replace "text" in a string or a file
FILE SPACING:
# double space a file
sed G
# double space a file which already has blank lines in it. Output file
# should contain no more than one blank line between lines of text.
sed '/^$/d;G'
@johnbianchi
johnbianchi / gist:7cf161edc0959c39f43ba7ab17575d4f
Created December 1, 2018 19:15 — forked from guilherme/gist:9604324
Git pre-commit hook that detects if the developer forget to remove all the javascript console.log before commit.
#!/bin/sh
# Redirect output to stderr.
exec 1>&2
# enable user input
exec < /dev/tty
consoleregexp='console.log'
# CHECK
if test $(git diff --cached | grep $consoleregexp | wc -l) != 0
then
@johnbianchi
johnbianchi / svn_short_log
Last active September 15, 2018 20:49 — forked from trevershick/svn_short_log
svn log, one line per commit
#!/usr/bin/awk -f
#
# Convert the "svn log" output into a one liner format, which is easier to grep
# or use in scripts. Pipe "svn log" into this script
#
# forked from: https://gist.github.com/trevershick/91df1e0df8731a7d706b
#
# optional vars passed to this script:
# -v table="type" a pre-defined output table: csv, tab, jira/conf, align, default
# -v description="text" prepend a description field (usually used for repo/path/etc.)
@johnbianchi
johnbianchi / pfctl-cheatsheet.txt
Last active November 29, 2023 22:10
pfctl cheat sheet
#### General PFCTL Commands ####
$ pfctl -d disable # packet-filtering
$ pfctl -e enable # packet-filtering
$ pfctl -q # run quiet
$ pfctl -v -v # run even more verbose
#### Loading PF Rules ####
$ pfctl -f /etc/pf.conf # load /etc/pf.conf
$ pfctl -n -f /etc/pf.conf # parse /etc/pf.conf, but dont load it
$ pfctl -R -f /etc/pf.conf # load only the FILTER rules
$ pfctl -N -f /etc/pf.conf # load only the NAT rules
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Run with: vagrant up --provider=docker
# to get a dns entry for the docker machines use DNSGUARD
# docker run -d -v /var/run/docker.sock:/var/run/docker.sock --restart always --name dnsdockmain -p 172.17.42.1:53:53/udp tonistiigi/dnsdock -domain=".local.com" -nameserver="192.168.50.20:53"
#
# common usage: vagrant --name=magento up --provider=docker
require 'getoptlong'
@johnbianchi
johnbianchi / ansible-summary.md
Created September 27, 2017 18:57 — forked from andreicristianpetcu/ansible-summary.md
This is an ANSIBLE Cheat Sheet from Jon Warbrick

An Ansible summary

Jon Warbrick, July 2014, V3.2 (for Ansible 1.7)

Configuration file

intro_configuration.html

First one found from of