Skip to content

Instantly share code, notes, and snippets.

@craigforr
craigforr / world-date.sh
Created Mar 10, 2021
BASH Script to display dates and times for any world time zone
View world-date.sh
#!/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
search=$1
zoneinfo=/usr/share/zoneinfo/posix/
format='%a %F %T'
@craigforr
craigforr / tmux.conf
Created Feb 18, 2021 — forked from spicycode/tmux.conf
The best and greatest tmux.conf ever
View tmux.conf
# 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 / clean-up-boot-partition-ubuntu.md
Created Jan 23, 2021 — forked from ipbastola/clean-up-boot-partition-ubuntu.md
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64
View clean-up-boot-partition-ubuntu.md

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r 
@craigforr
craigforr / efs_targets.j2
Created Dec 15, 2020 — forked from halberom/efs_targets.j2
ansible - example of using lookup and a template to generate dynamic list entries for modules
View efs_targets.j2
#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 %}
View terraform_bash_completion.sh
# 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.
#
View tmux-default-bindings.txt
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 Sep 19, 2020
Installs or upgrades kubectl on Linux, including WSL2
View install_upgrade_kubectl.sh
#!/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 Jul 30, 2020
Finds the most recent files in the current directory tree
View findr.sh
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 Oct 15, 2019 — forked from trentmswanson/autopart.sh
Linux bash script to partition and format all data disks in azure
View autopart.sh
#!/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 / profiles.json
Created Aug 6, 2019
Profiles for Windows Terminals (Preview, v0.3.2171.0)
View profiles.json
{
"globals" :
{
"alwaysShowTabs" : true,
"defaultProfile" : "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"initialCols" : 120,
"initialRows" : 30,
"keybindings" :
[
{