Skip to content

Instantly share code, notes, and snippets.

View stn1slv's full-sized avatar

Stanislav Deviatov stn1slv

View GitHub Profile
@stn1slv
stn1slv / git-update-all.sh
Created September 30, 2025 09:36
Updating a set of git repositories
#!/bin/bash
#
# Updates all git repositories in the current directory's subfolders.
# Optionally filters folders by a name prefix.
#
# --- Script Logic ---
# Use the first command-line argument as a filter, otherwise match all folders.
@stn1slv
stn1slv / GetValueFromCurlJSON.sh
Created April 21, 2023 19:25
BASH: Get value from remote URL which returns JSON
#!/bin/bash
URL=http://host.docker.internal:8080/auth/realms/master/protocol/openid-connect/token
DATA="username=admin&password=admin&grant_type=password&client_id=admin-cli&client_secret=7f2fc8e5-f01c-471b-b981-ef7534041790"
ATTR_NAME="access_token"
# Get JWT token
TOKEN=$(curl -ss -d "$DATA" -H "Content-Type: application/x-www-form-urlencoded" -X POST $URL | grep -o "\"$ATTR_NAME\":\"[^\"]*\"" | cut -d'"' -f4)
echo $TOKEN
@stn1slv
stn1slv / WaitUntilHTTP200.sh
Created April 21, 2023 19:24
BASH: Wait until remote URL return HTTP 200
#!/bin/bash
URL="http://host.docker.internal:8080/auth/realms/master/.well-known/openid-configuration"
# Waiting until HTTP 200
until [ "$(curl -sL -w "%{http_code}\\n" $URL -o /dev/null)" == "200" ]
do
echo "$(date) - still trying to connect to $URL"
sleep 5
done
@stn1slv
stn1slv / CheckEnvParamAndSetDefaultValue.sh
Created April 21, 2023 19:23
BASH: Verify the existence environment parameter and set default value
#!/bin/bash
# Check parameter value and set defaults
if [ -z "$ENV_VARIABLE" ]; then
export ENV_VARIABLE=qwe123
fi
@stn1slv
stn1slv / callRestConstantlyWithRandomTime.cmd
Created April 21, 2023 19:20
CMD: call REST endpoint with random time
echo off
set max_timeout=7
set url=http://localhost:4000/api/bookTrip
set JWT=eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ0aFlOSURidTU4RFVUMF9hRzRoOHVCQTBuQnhUd0ExQzFBcExWYU1JNExFIn0.eyJqdGkiOiI4YjkzNjljYi0zZDVlLTRiZjgtODRjZi1hNTE4NmRkNTIzYTEiLCJleHAiOjE1MzIwMTQzOTUsIm5iZiI6MCwiaWF0IjoxNTMyMDExMzk1LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjgwODAvYXV0aC9yZWFsbXMvVGVzdFJlYWxtIiwiYXVkIjoiZGVtbzItYXBwIiwic3ViIjoiNzI0ZDAwMzctZGVhYi00MDU4LWFlMWUtNzc1ZWE1Y2RkZTk3IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiZGVtbzItYXBwIiwiYXV0aF90aW1lIjowLCJzZXNzaW9uX3N0YXRlIjoiNzliMTI4NzQtOWM2ZS00MTBjLTgzZDYtMGFjYjcxMGMzYTM2IiwiYWNyIjoiMSIsImFsbG93ZWQtb3JpZ2lucyI6WyIqIl0sInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJ1bWFfYXV0aG9yaXphdGlvbiIsInVzZXIiXX0sInJlc291cmNlX2FjY2VzcyI6eyJkZW1vLWFwcCI6eyJyb2xlcyI6WyJ1bWFfcHJvdGVjdGlvbiJdfSwiYnJva2VyIjp7InJvbGVzIjpbInJlYWQtdG9rZW4iXX0sImFjY291bnQiOnsicm9sZXMiOlsibWFuYWdlLWFjY291bnQiLCJtYW5hZ2UtYWNjb3VudC1saW5rcyIsInZpZXctcHJvZmlsZSJdfX0sIm5hbWUiOiJVc2VyMSBmaXJzdCBuYW1lIFVzZXIyIGxhc3QgbmFtZSIsInByZWZlcnJlZF91c2VybmFtZS
@stn1slv
stn1slv / nix-commands.md
Last active April 18, 2023 17:29
Useful *nix commands
Name RHEL/OEL Solaris AIX HP-UX
OS Version cat /etc/*-release uname -r oslevel -r uname -r
Processor Architecture arch arch uname -p uname -m
Number of Processors cat /proc/cpuinfo psrinfo -pv lsdev -C -c processor ioscan -kf | grep processor | wc -l
Free Space on Filesystems df -h df -h df -k (in kilobytes) bdf (in kilobytes)
Swap Size free -m swap -s lsps -a swapinfo
RAM Size free -m prtconf | grep Memory bootinfo -r machinfo | grep Memory
List of Running Processes top prstat -a topas top
List of Network Interfaces ifconfig -a ifconfig -a ifconfig -a netstat -in