Skip to content

Instantly share code, notes, and snippets.

@craigforr
craigforr / create-azure-service-principal-contrib.sh
Last active December 14, 2021 15:37
Bash script to create an Azure AD service principal with Contributor role using Azure CLI
#!/usr/bin/env bash
SCRIPT_NAME='create-azure-service-principal-contrib.sh'
SCRIPT_DESCRIPTION='Creates an Azure AD service principal with Contributor rights'
SCRIPT_VERSION='1.2.2'
# Related documentation:
# - https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli
function display_usage() {
@craigforr
craigforr / world-date.sh
Last active August 31, 2021 15:55
BASH Script to display dates and times for any world time zone
#!/bin/sh
# Show date and time in other time zones
# Source: python - command-line world clock? - Stack Overflow
# https://stackoverflow.com/questions/370075/command-line-world-clock
function world_date(){
if [ "$1"x != 'x' ]; then
search=$1
else
@craigforr
craigforr / tmux.conf
Created February 18, 2021 17:03 — forked from spicycode/tmux.conf
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
@craigforr
craigforr / efs_targets.j2
Created December 15, 2020 01:45 — forked from halberom/efs_targets.j2
ansible - example of using lookup and a template to generate dynamic list entries for modules
#jinja2:trim_blocks: True, lstrip_blocks: True
targets:
{% for privnet in all_private_subnets %}
- subnet_id: "{{ privnet }}"
security_groups: [ "{{ sg.group_id }}" ]
{% endfor %}
{% for pubnet in all_public_subnets %}
- subnet_id: "{{ pubnet }}"
security_groups: [ "{{ sg.group_id }}" ]
{% endfor %}
@craigforr
craigforr / terraform_bash_completion.sh
Created November 5, 2020 21:31 — forked from zish/terraform_bash_completion.sh
Better Terraform Bash Completion
# Bash Terraform completion
# Originally adapted from: https://gist.github.com/cornfeedhobo/8bc08747ec3add1fc5adb2edb7cd68d3
#
# Author: Jeremy Melanson
#
# Features of this update:
# - Use built-in bash routines for text processing, instead of external tools (awk, sed, grep, ...).
# - fixes the retrieval of options from the Terraform executble.
# - Optional _init_terraform_completion function, which can enable command-completion for multiple Terraform executables.
#
bind-key C-b send-prefix
bind-key C-o rotate-window
bind-key C-z suspend-client
bind-key Space next-layout
bind-key ! break-pane
bind-key " split-window
bind-key # list-buffers
bind-key $ command-prompt -I #S "rename-session '%%'"
bind-key % split-window -h
bind-key & confirm-before -p "kill-window #W? (y/n)" kill-window
@craigforr
craigforr / install_upgrade_kubectl.sh
Last active September 19, 2020 22:48
Installs or upgrades kubectl on Linux, including WSL2
#!/usr/bin/env bash
# Installs or upgrades kubectl on Linux
# Chuck for root privileges
if [[ "$EUID" != "0" ]] ; then
echo "Please execute script with sudo or as root."
exit 1
fi
# Check Dependencies
@craigforr
craigforr / findr.sh
Last active July 30, 2020 23:02
Finds the most recent files in the current directory tree
function findr() {
# Find recently modified files in the current directory tree
SEARCH_PATH='./*'
NUMBER_OF_RESULTS=20
while [[ $# -gt 0 ]]; do
case "$1" in
-h|--help)
DISPLAY_USAGE=TRUE
shift
;;
@craigforr
craigforr / autopart.sh
Created October 15, 2019 15:40 — forked from trentmswanson/autopart.sh
Linux bash script to partition and format all data disks in azure
#!/bin/bash
# An set of disks to ignore from partitioning and formatting
BLACKLIST="/dev/sda|/dev/sdb"
# Base directory to hold the data* files
DATA_BASE="/media"
usage() {
echo "Usage: $(basename $0) <new disk>"
}
@craigforr
craigforr / vimium-keybindings.vim
Last active August 6, 2019 20:44
Custom key mappings for the Vimium extension for Google Chrome
map t createTab http://www.google.com
" Go one tab left (previousTab)
map K previousTab
" Go one tab right (nextTab)
map J nextTab
" Close tabs to the right (closeTabsOnLeft)
map gc closeTabsOnLeft
" Close tabs to the right (closeTabsOnRight)
map gC closeTabsOnRight
" Close all other tabs (closeOtherTabs)