This file contains 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 sh | |
k rollout history deploy <deploy> -oyaml | | |
yq '{ | |
.metadata.annotations."deployment.kubernetes.io/revision": .spec.template.metadata.labels.pod-template-hash | |
} as $item ireduce ({}; . *+ $item)' | |
: ' | |
example outputs |
This file contains 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 | |
# ref. https://www.docker.com/blog/checking-your-current-docker-pull-rate-limits-and-status/ | |
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token) | |
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest 2>&1 | grep ratelimit |
This file contains 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
$ aws ec2 describe-instance-types | | |
jq '.InstanceTypes[] | | |
{ | |
"InstanceType": .InstanceType, | |
"MaximumIpv4Address": (.NetworkInfo.MaximumNetworkInterfaces * .NetworkInfo.Ipv4AddressesPerInterface - 3) | |
}' | | |
jq -s 'sort_by(.MaximumIpv4Address)' |
This file contains 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 | |
bucket=$1 | |
prefixs=( "${@:2}" ) | |
for prefix in "${prefixs[@]}" | |
do | |
size=$(aws s3api list-objects-v2 --bucket="${bucket}" --prefix="${prefix}" | jq '[.Contents[].Size] | add' | numfmt --to=si) | |
echo "${prefix}\t${size}" | |
done |
This file contains 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
FROM ubuntu:bionic | |
# Prerequisuite | |
RUN apt update && apt install -y ca-certificates lsb-release wget software-properties-common | |
# Libarrow | |
## ref. https://arrow.apache.org/install/ | |
RUN wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb | |
RUN apt install -y ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb && apt update |
This file contains 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 | |
# ref. https://stackoverflow.com/questions/43192556/using-jq-with-bash-to-run-command-for-each-object-in-array | |
bucket=$1 | |
aws s3api list-multipart-uploads --bucket "${bucket}" | \ | |
jq -r '.Uploads[] | [.UploadId, .Key] | @tsv' | \ | |
while IFS=$'\t' read -r upload_id key; do | |
AWS_PAGER="" aws s3api list-parts --bucket "${bucket}" --key "${key}" --upload-id "${upload_id}" | |
done | \ | |
jq 'select(has("Parts")) | .Parts[].Size' | \ |
This file contains 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 | |
bucket=$1 | |
prefixes=( "${@:2}" ) | |
for prefix in "${prefixes[@]}" | |
do | |
lm=$(aws s3api list-objects-v2 --bucket="${bucket}" --prefix="${prefix}" | jq '.Contents | map(.LastModified) | sort_by(.)[-1]') | |
echo "${prefix}\t${lm}" | |
done |
This file contains 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 | |
# Remaining prefix after the above prefix should be a format of '%Y/%m' | |
# ref. https://stackoverflow.com/questions/49382310/iterating-through-min-and-max-dates-in-bash-by-month | |
cur='2021-07-01' | |
endepoch=$(date '+%s') | |
bucket=$1 | |
prefix=$2 | |
while [[ $(date +%s -d "${cur}") -le "${endepoch}" ]]; do |
This file contains 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 | |
# Include infinite | |
echo 'lru_crawler metadump all' | nc 127.0.0.1 11211 | awk '{print $2}' | awk -F'=' '{if ($2==-1) {print "infinite"} else {system("date -d@"$2)}}' | |
# Exclue infinite | |
echo 'lru_crawler metadump all' | nc 127.0.0.1 11211 | awk '{print $2}' | awk -F'=' '$2 ~ !/-1/{system("date -d@"$2)}' |
This file contains 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
jq 'walk(if type=="object" then to_entries | sort_by(.key) | from_entries else . end)' |
NewerOlder