Skip to content

Instantly share code, notes, and snippets.

View netikras's full-sized avatar

Darius Juodokas netikras

  • Lithuania, Vilnius
View GitHub Profile
@netikras
netikras / do_until.sh
Last active June 2, 2022 07:11
A shell function that repeats an action until either some condition is met or timeout occurs. NOTE: blocking actions/condition checks will block the function
## USAGE:
## do_until true "ls -l /var/run/dockerd.sock"
## do_until true "ls -l /var/run/dockerd.sock 10 1"
## a=5; do_until 'a=$((a+1))' 'echo "a=${a}"; [ ${a} -ge 10 ]' 7 1
do_until() {
local task=${1:?Task missing};
local condition=${2:?Condition missing};
local timeout=${3:-60};
local pause=${4:-5};
@netikras
netikras / pw.py
Created November 15, 2021 09:33
a digital version of https://twitter.com/nixcraft/status/1441029704463503368 python pw generator
#!/usr/bin/python
import random
lower ="absdefghijklmnopqrstuvwxyz"
upper ="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
numbers="0123456789"
symbols= "[]{}()*;/,_-"
all = lower + upper + numbers+ symbols
@netikras
netikras / requestor.awk
Last active October 27, 2022 15:11 — forked from sinegar/requestor.awk
Combine tcpdump packets into requests and response times.
#!/usr/bin/awk -f
# #
#
# Inspired by http://www.percona.com/doc/percona-toolkit/2.1/pt-tcp-model.html
#
# Example usage:
# $ tcpdump -i any -s 0 -nnq -tt 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
# 1349692787.492311 IP X.X.X.X.XXXX > X.X.X.X.XXXX: tcp 1448
# $ ./requestor.awk dump.file