This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | |
# Actions: Hop through the [redacted] NAT box to SSH into [redacted] servers. | |
# Globals: None. | |
# Options: --key, -k, -i PRIVATE_KEY | |
# Use this key for authentication (default: standard SSH key | |
# locations [see man page ssh (1)] | |
# --debug, -d | |
# Run in debugger mode: set shell options -x and -v, and run | |
# ssh in verbose mode with -vvv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bash shell function that runs "docker inspect" and pipes the output through jq. | |
# Requires jq [https://stedolan.github.io/jq/] | |
# | |
# Usage: di CONTAINER|IMAGE | |
di() ( | |
error=1 | |
__obj=$1 | |
if [[ ! ${__obj} ]]; then | |
echo "${FUNCNAME}(): error: missing docker object argument" >&2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bash function for updating all packages installed with either `pip` or | |
# `conda` in the current Python virtualenv or conda environment. | |
pyupdate() { | |
# If we're in a conda environment, update all packages conda installed. | |
which conda 2>/dev/null && conda update -y --all | |
# After we're done with conda, if we have pip, update pip then update any | |
# packages installed with pip. | |
if which pip 2>/dev/null; then | |
pip install -U pip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
/* GNU utility `cat` as a JavaScript executable. | |
* | |
* This works mostly the same as `cat`, with one difference: an explicit | |
* argument of '-' (specifying stdin) is processed _after_ all filename | |
* arguments. | |
* | |
* USAGE: cat.js [<FILE> <FILE...> [-]] | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Extract and print network addresses from a file. | |
This was written for Python 3.x because Python 2.x is a decade old, and every | |
time you use it, Baby Guido cries. | |
If you have an older python, download the Miniconda Python installer at | |
http://conda.pydata.org/miniconda.html, run it, and load a new shell. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Open several browser tabs displaying information about an IP passed as a CLI arg. | |
(extremely quick, perversely dirty) | |
""" | |
from string import Template | |
import subprocess | |
import sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Package getpass reads passwords without echoing output. | |
// | |
// The current implementation is compatible with modern Windows and *nix systems | |
// that use cmd.exe, PowerShell, Bash, or Bourne shell environments. | |
package getpass | |
import ( | |
"fmt" | |
"os" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This reads a stream of random bytes from the system and drops input that isn’t | |
# a valid encoding for a letter or a number. It stops after 8 characters. | |
# | |
# Setting LC_CTYPE=C is important: Modern systems will (hopefully) be set to | |
# UTF-8, but that makes tr throw errors for illegal byte sequences. Usually, we | |
# want that kind of sane behavior — but here, we don’t. | |
LC_CTYPE=C tr -d -c '[:alnum:]' </dev/urandom | head -c 8 | |
# This saves a 15-character alphanumeric string in a variable: | |
random=$(LC_CTYPE=C tr -d -c '[:alnum:]' </dev/urandom | head -c 15) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | |
# Name: pre-commit | |
# Author: [email protected] | |
# Synopsis: Reject commits containing unencrypted Ansible Vault files. | |
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | |
set -e | |
vault_files=($(IFS=$'\n' find . -type f -name 'vault')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
"""Reject commits to Ansible projects that contain unencrypted vault files. | |
I realized pretty quick that a simple shell script could so the same thing (see | |
https://gist.github.com/princebot/2bd84b3b344168db22ce1259241f4a88) — but I | |
finished this anyway for funsies. | |
Also for funsies, I wanted to see what static classes in Python might look like. |
OlderNewer