Skip to content

Instantly share code, notes, and snippets.

View sergeiwaigant's full-sized avatar
🤙

Sergei Waigant sergeiwaigant

🤙
View GitHub Profile

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@sergeiwaigant
sergeiwaigant / bash_strict_mode.md
Created January 17, 2024 21:51 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation
@sergeiwaigant
sergeiwaigant / iptables.sh
Created January 16, 2024 13:13 — forked from danibram/iptables.sh
Redirect 443,80 to 8443,8080 on ubuntu with persistence
sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 8443
sudo sh -c "iptables-save > /etc/iptables.rules"
sudo apt-get install iptables-persistent
#allows localhost traffic to connect to 443 from 8443
sudo iptables -t nat -A OUTPUT -o lo -p tcp --dport 443 -j REDIRECT --to-port 8443
@sergeiwaigant
sergeiwaigant / openssl_commands.md
Created January 15, 2024 21:09 — forked from Hakky54/openssl_commands.md
Some list of openssl commands for check and verify your keys

OpenSSL 🔐

Install

Install the OpenSSL on Debian based systems

sudo apt-get install openssl
@sergeiwaigant
sergeiwaigant / url_encode_string_with_linux_tools.md
Last active August 13, 2024 03:07
Simply URL encode string with Linux/Bash/Shell tools

Reference https://stackoverflow.com/a/34407620/13287790

$ printf %s 'encode this'|jq -sRr @uri
encode%20this
$ jq -rn --arg x 'encode this' '$x|@uri'
encode%20this
-r (--raw-output) outputs the raw contents of strings instead of JSON string literals. -n (--null-input) doesn't read input from STDIN.

-R (--raw-input) treats input lines as strings instead of parsing them as JSON, and -sR (--slurp --raw-input) reads the input into a single string. You can replace -sRr with -Rr if your input only contains a single line, or if you don't want to replace linefeeds with %0A:
# Sometimes after a sprint, all the remaining branches are just taking up space.
# Here's a small snippet to remove all your local branches in one go.
git branch | grep -v "master" | xargs git branch -D
function bashLogger() {
local logLevel="INFO"
local logMessage=""
[[ $# -ge 1 ]] && { logMessage=$1;shift;}
[[ $# -ge 1 ]] && { logLevel=${logMessage}; logMessage=$1; shift;}
local additionalMessages="$@"
local timestamp=$(TZ=UTC-1 date +'%Y-%m-%d %H:%M:%S,%3N')
# Remove all untagged images
docker rmi $(docker images | grep "^<none>" | awk '{print $3}')
#
docker container prune
# clean up all "Exited" containers
docker rm $(docker ps -a | grep Exited | awk '{ print $1 }')
# Lists one line per Java environment installed (and known to the /usr/bin/java command).
# You can still have e.g. Zulu installations which are not registered
/usr/libexec/java_home -V