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
REPO=$1 | |
KEEP_IMAGES=$2 # number of images you want to remain | |
aws ecr describe-images --repository-name $REPO --query 'imageDetails[]' \ | |
| jq --raw-output 'sort_by(.imagePushedAt) | reverse | .[].imageDigest' \ | |
| awk "NR > ${KEEP_IMAGES}" \ | |
| xargs -I{} aws ecr batch-delete-image --repository-name $REPO --image-ids imageDigest={} |
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
kafka-configs --alter --bootstrap-server localhost:9092 --entity-type topics --entity-name my-input-topic --add-config retention.ms=5000 |
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
// kills long running ops in MongoDB (taking seconds as an arg to define "long") | |
// attempts to be a bit safer than killing all by excluding replication related operations | |
// and only targeting queries as opposed to commands etc. | |
killLongRunningOps = function(maxSecsRunning) { | |
currOp = db.currentOp(); | |
for (oper in currOp.inprog) { | |
op = currOp.inprog[oper-0]; | |
if (op.secs_running > maxSecsRunning && op.op == "query" && !op.ns.startsWith("local")) { | |
print("Killing opId: " + op.opid |
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
# filter lines by arbitrary value and sorts desc, lines ending with XXXms | |
grep 'T18:4' /var/log/some/some.log | grep 'ms' | awk '{if($NF-0>500){print $NF-0,$0}}' | sort -rg -k 1 | head -10 | |
# grep text between strings | |
grep 'T11' /var/log/some/some.log | grep 'someText' | grep -o -P '(?<=TEXT_A).*(?=TEXT_B)' | sort | uniq -c | sort -r | head -50 |
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
# Set | |
rabbitmqctl eval 'application:set_env(rabbit, heartbeat, 1800).' | |
# Get | |
rabbitmqctl eval 'application:get_env(rabbit, heartbeat).' |
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
awk '{printf("%s ",$1); system("dig -t mx +short " $0)}' somefile.csv |
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 | |
JAILS=`fail2ban-client status | grep "Jail list" | sed -E 's/^[^:]+:[ \t]+//' | sed 's/,//g'` | |
for JAIL in $JAILS | |
do | |
fail2ban-client status $JAIL | |
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
#!/usr/bin/env bash | |
## | |
# Source this in your .bashrc | |
## | |
set -o pipefail | |
kafka_avro_schema_id() { | |
if [ $# -ne 2 ]; then | |
echo "Usage $0 <bootstrap-server> <topic[:part:[:offset]]>" |
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
awk '/company_id/ {search_string=$0} /empty_before_import": true/ {print search_string FILENAME " " NR}' error_queue.*.log |
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
find . -type f -name '.jpeg' -o -name '.jpg' -exec jpegoptim --strip-all --max=83 -p {} \; |
NewerOlder