This file contains hidden or 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
#!/bin/bash | |
procname="$1" | |
if [[ -z "$procname" ]]; then | |
echo "Usage: $0 <procname> [sleeptime] [timeout]" | |
exit 1 | |
fi | |
sleeptime="${2:-1}" | |
if [[ "$sleeptime" -lt 1 ]] || [[ "$sleeptime" -gt 60 ]]; then | |
echo "sleeptime must be an integer between 1-60" |
This file contains hidden or 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 -*- | |
try: | |
from collections import ChainMap | |
except ImportError: | |
from chainmap import ChainMap | |
uservars = {"layer": 1, "layer1": True} | |
defaults = {"layer": 2, "layer2": True} |
This file contains hidden or 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
SHELL=/bin/bash | |
# to see all colors, run | |
# bash -c 'for c in {0..255}; do tput setaf $c; tput setaf $c | cat -v; echo =$c; done' | |
# the first 15 entries are the 8-bit colors | |
# define standard colors | |
ifneq (,$(findstring xterm,${TERM})) | |
BLACK := $(shell tput -Txterm setaf 0) | |
RED := $(shell tput -Txterm setaf 1) |
This file contains hidden or 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 -*- | |
import sys | |
from datetime import datetime | |
filetime = int(sys.argv[1]) | |
seconds_till_epoch = 11644473600 | |
epoch = filetime / 10000000 - seconds_till_epoch |
This file contains hidden or 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
#!/bin/bash | |
function header() { | |
local name="$1" | |
echo "" | |
printf '= %-.100s %.s\n' "$name $(printf '%.1s' ={1..100})" | |
} | |
header "my header" |
This file contains hidden or 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
#!/bin/bash | |
# sort by created | |
jq -s -c 'sort_by(.CreatedAt)[]' <(docker images --format '{{json .}}') | jq . | |
# returns json array of image repositories | |
function list_image_repos() { | |
jq -c --slurp --raw-input 'split("\n")[:-1]' <(docker images --format '{{.Repository}}' | sort | uniq) | |
} |
This file contains hidden or 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
# Find files that have been modified on your system in the past 60 minutes | |
find / -mmin 60 -type f | |
# Find all files larger than 20M | |
find / -type f -size +20M | |
# Find duplicate files (based on MD5 hash) | |
find -type f -exec md5sum '{}' ';' | sort | uniq --all-repeated=separate -w 33 | |
# Change permission only for files |
This file contains hidden or 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
# Track child process | |
strace -f -p $(pidof glusterfsd) | |
# Track process after 30 seconds | |
timeout 30 strace $(< /var/run/zabbix/zabbix_agentd.pid) | |
# Track child process and redirect output to a file | |
ps auxw | grep 'sbin/[a]pache' | awk '{print " -p " $2}' | xargs strace -o /tmp/strace-apache-proc.out | |
# Track the open request of a network port |
This file contains hidden or 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
# Compare two directory trees | |
diff <(cd directory1 && find | sort) <(cd directory2 && find | sort) |
This file contains hidden or 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
# Testing connection to remote host | |
echo | openssl s_client -connect google.com:443 -showcerts | |
# Testing connection to remote host (with SNI support) | |
echo | openssl s_client -showcerts -servername google.com -connect google.com:443 | |
# Testing connection to remote host with specific ssl version | |
openssl s_client -tls1_2 -connect google.com:443 | |
# Testing connection to remote host with specific ssl cipher |