Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / azure-sdk-python-key-vault-get-secret-using-client-from-cli-credentials.py
Created November 29, 2018 01:04
azure sdk python key vault get secret using client from cli credentials
from azure.common.credentials import get_azure_cli_credentials
credentials, subscription_id = get_azure_cli_credentials(resource="https://vault.azure.net")
kv_client = KeyVaultClient(credentials=credentials)
kv_secret = kv_client.get_secret("https://<vault-name>.vault.azure.net/", "<secret-name>", "")
print(kv_secret.value)
@gregjhogan
gregjhogan / rsync-copy-mirror-directory.sh
Last active February 13, 2019 06:55
rsync directory mirror copy
rsync -aHAXz --checksum --partial --delete --progress /<path>/<to>/<dir> <target-server>:/<path>/<to>/<dir>/
# preserves source directory structure on target
sudo xfsdump -l0 -s <relative>/<path> - /<device> | ssh <target-server> xfsrestore - /<device>
@gregjhogan
gregjhogan / ssh-tar-backup-restore.sh
Created November 7, 2018 23:11
tar backup/restore over SSH
# preserves source directory structure on target
tar cf - /<path>/<to>/<dir> | ssh <target-server> tar xf -
@gregjhogan
gregjhogan / docker-cloudstor-azure-file-share-volume.sh
Created October 31, 2018 20:11
docker cloudstor azure file share volume
# ONLY WORKS FROM INSIDE AZURE !!! (cloudstor can't mount CIFS v3 volumes - required when connecting over internet)
STORAGE_ACCOUNT=<account>
STORAGE_KEY=<key>
STORAGE_SHARE=<share>
# configure
docker plugin install --alias cloudstor:${STORAGE_ACCOUNT} --grant-all-permissions docker4x/cloudstor:18.06.1-ce-azure2 CLOUD_PLATFORM=AZURE AZURE_STORAGE_ACCOUNT_KEY="${STORAGE_KEY}" AZURE_STORAGE_ACCOUNT="${STORAGE_ACCOUNT}" AZURE_STORAGE_ENDPOINT="core.windows.net" DEBUG=1
# create
docker volume create --driver=cloudstor:${STORAGE_ACCOUNT} --opt=share=${STORAGE_SHARE} ${STORAGE_SHARE}
# test
docker run --rm -v ${STORAGE_SHARE}:/data --cap-add SYS_ADMIN --cap-add DAC_READ_SEARCH -it busybox
@gregjhogan
gregjhogan / azure-vm-extract-tag-value.sh
Last active October 29, 2018 21:34
Azure VM extract tag value
$TAG_NAME=???
curl -s -H 'Metadata:true' 'http://169.254.169.254/metadata/instance?api-version=2017-08-01' | jq '.compute.tags' | sed -e 's/"/;/g' | sed -e "s/.*;${TAG_NAME}:\(.*\);.*/\1/"
@gregjhogan
gregjhogan / git-convert-to-shallow.sh
Created October 19, 2018 01:15
convert git repo to shallow clone
git pull --depth=1
git gc --prune=all