Skip to content

Instantly share code, notes, and snippets.

Avatar
need coffee

Sean Jain Ellis bandarji

need coffee
View GitHub Profile
@bandarji
bandarji / .local.bash
Created Jan 23, 2019
Local Bash functions
View .local.bash
function py37a() {
docker run --rm -v $(pwd):/work -it py37a ${@}
}
function py37() {
docker run --rm -v $(pwd):/work -it py37 ${@}
}
function py27() {
docker run --rm -v $(pwd):/work -it py27 ${@}
View tmux.conf
set -g default-terminal "screen-256color"
# change prefix command to C-z
set -g prefix C-z
unbind C-b
bind C-z last-window
bind z send-prefix
# Turn on mouse support
setw -g mouse on
@bandarji
bandarji / pkkid_funcs.py
Created Nov 7, 2018
Some Python functions from /u/pkkid
View pkkid_funcs.py
class Bunch(dict):
""" Works like a dict, but lets you use dot.notation to get or set values rather
than the regular['notation']. Simply stylistic convenience when you are dealing
with a lot of dicts.
Example:
foo = Bunch()
foo['bar'] = 123
foo.baz = 456
print(foo.bar)
print(foo['baz'])
@bandarji
bandarji / max_tries.sh
Created Jul 23, 2017
Try a command a certain number of times before continuing on
View max_tries.sh
#!/bin/bash
# Attempt a command ten times before continuing on
# written up for Carter and the gang
max_tries=10
attempt=0
while [[ ${attempt} -lt ${max_tries} ]]; do
attempt=$((attempt+1))
grep -q ^root /etc/passwd && break
View sublime_text_prefs.txt
{
"always_prompt_for_file_reload": false,
"always_show_minimap_viewport": false,
"animation_enabled": true,
"atomic_save": false,
"auto_close_tags": true,
"auto_complete": true,
"auto_complete_commit_on_tab": false,
"auto_complete_cycle": false,
"auto_complete_delay": 50,
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
View pagerduty_hacks.txt
# Reached maximum user count and want to add a read-only user?
# Unfortunately, the "add user" button disappeared.
# Simply visit this link to invite a read-only user.
# https://<acct>.pagerduty.com/users#invite
#
@bandarji
bandarji / borderimg.sh
Last active Oct 4, 2016
Place a border around an image with ImageMagick
View borderimg.sh
# Bash function to place a border around an image with ImageMagick
function borderimg() {
if [ -z ${3} ]; then
echo "Usage: borderimg <imageFile> <whiteBorderSize> <blackBorderSize>"
else
identify ${1}
mogrify -border ${2}x${2} -bordercolor white ${1}
mogrify -border ${3}x${3} -bordercolor black ${1}
identify ${1}
fi
@bandarji
bandarji / ipsort.sh
Created Oct 4, 2016
Alias to sort IPv4 addresses
View ipsort.sh
alias ipsort='sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4'
@bandarji
bandarji / nato.sh
Last active Jun 20, 2018
NATO Phonetic Alphabet (Bash)
View nato.sh
# List NATO phonetic alphabet
# Type 'nato' in your shell to get the International Radiotelephony Spelling
# Alphabet displayed on your screen.
function nato() {
natostring="Alpha Bravo Charlie Delta Echo Foxtrot Golf Hotel India Juliett Kilo Lima Mike November Oscar Papa Quebec Romeo Sierra Tango Uniform Victor Whiskey X-ray Yankee Zulu"
clear
for letter in ${natostring} ; do
printf "%-5s %s\n" ${letter:0:1} ${letter}
done
}