Skip to content

Instantly share code, notes, and snippets.

@gregjhogan
gregjhogan / kubernetes-sdk-python-get-secret-using-client-from-cli-credentials.py
Created November 29, 2018 03:07
kubernetes sdk python get secret using client from cli credentials
from base64 import b64decode
from kubernetes import client, config
config.load_kube_config()
v1 = client.CoreV1Api()
secret = v1.read_namespaced_secret('<secret-name>', 'default')
value = b64decode(secret.data["<property-name>"])
print(value)
@gregjhogan
gregjhogan / pssh-example.sh
Created December 1, 2018 01:55
pssh example
pssh -h </path/to/file> -l root -t 0 -i 'echo hello world!'
@gregjhogan
gregjhogan / lkqonline-2018-accord-eps-query.sh
Created December 8, 2018 06:40
lkqonline 2018 accord EPS query
curl 'https://lkqonline.com/b2cportal/api/Part/GetParts' -H 'Origin: https://lkqonline.com' -H 'Content-Type: application/json;charset=UTF-8' -H 'Accept: application/json, text/plain, */*' --data-binary '{"Years":[2018,2019],"Makes":["HONDA"],"Models":["ACCORD"],"Categories":["B2CPortal|Suspension|Steering Parts|Power Steering Pump/Motor"],"AftermarketExcludedPLines":[],"LinesOfBusinessIds":[2],"Take":12,"Skip":0,"IsNationalSearch":true,"Sort":[{"SortProperty":"salvagegeo","SortDirection":"asc"},{"SortProperty":"aftermarketsequence","SortDirection":"asc"}],"IsPartSearch":true,"DoPricingAndAvailability":true,"IsFacetOnly":false,"isPartSearch":true,"ObjectSizeType":0}'
@gregjhogan
gregjhogan / mysql-dump-query-to-file.sh
Created January 9, 2019 22:44
mysql dump query to file
mysql -h <hostname> -u <username> -p -sN -e "select json_object('key1', 1, 'key2', 2);" <database> > <filename>
@gregjhogan
gregjhogan / find-and-delete-empty-dirs.sh
Created January 15, 2019 05:41
find and delete empty directories
find /<path>/<to>/<base> -type d -empty -print | xargs -I '{}' rmdir '{}'
@gregjhogan
gregjhogan / generate-random-password.sh
Created January 20, 2019 03:11
Generate Random Password
openssl rand -base64 30
date +%s | sha256sum | base64 | head -c 32 ; echo
@gregjhogan
gregjhogan / dstat.sh
Last active February 14, 2019 05:07
dstat with most useful flags
dstat -v --disk-util -rn
@gregjhogan
gregjhogan / bash-log-to-file-if-not-interactive.sh
Created January 23, 2019 20:15
bash log to file if not running interactively
#!/usr/bin/env bash
set -e
# log to file if not running interactively
if [[ ! -t 1 ]]; then
exec >> >(tee /var/log/$(basename ${0%.*}).log) 2>&1
fi
echo "hello world!"
@gregjhogan
gregjhogan / docker-remove-all-stopped-containers.sh
Created January 24, 2019 20:17
docker remove all stopped containers
docker rm $(docker ps -q --filter "status=exited")
@gregjhogan
gregjhogan / add-ssh-known-host.sh
Created March 11, 2019 22:58
add list of ssh hosts to known_hosts
HOSTS=(
host1
host2
host3
)
for HOST in "${HOSTS[@]}"; do ssh-keyscan $HOST >> $HOME/.ssh/known_hosts; done