Skip to content

Instantly share code, notes, and snippets.

View vdbsh's full-sized avatar
🐢
justified!

vdbsh

🐢
justified!
View GitHub Profile
@vdbsh
vdbsh / shebangarch.sh
Last active May 11, 2024 16:56
This is how you can set architecture of your shellscript runtime by using unconventional shebang, comes in handy for M1+ Macs where you can use both arm64 and x86_64 thru Rosetta 2
#!/usr/bin/env /usr/bin/arch -arm64 /bin/bash
# shebangarch.sh: This is how you can set architecture of your shellscript runtime by using unconventional shebang
# comes in handy for M1+ Macs where you can use both arm64 and x86_64 thru Rosetta 2
echo "I'm $(arch) 😊"
@vdbsh
vdbsh / natpmprfr.sh
Last active August 21, 2023 15:36
Maps network ports thru NAT-PMP and refreshes that mapping automatically
#!/usr/bin/env bash
# natpmprfr.sh: Maps network ports thru NAT-PMP and refreshes that mapping automatically
# (https://en.wikipedia.org/wiki/NAT_Port_Mapping_Protocol)
#
# Useful for applications with poor or without NAT-PMP implementation
# (http://miniupnp.free.fr/libnatpmp.html)
#
# Script can set UFW rules according to mapped/unmapped local ports
# (https://help.ubuntu.com/community/UFW)
@vdbsh
vdbsh / microsync.sh
Last active January 28, 2023 00:39
Syncing two directories by creating symlinks at destination
#!/usr/bin/env bash
# microsync.sh: Syncing two directories by creating symlinks at destination.
source="/Users/user/source"
destination="/Users/user/destination"
# Delete broken symlinks and empty directories if any
find "$destination" -type l ! -exec test -e {} \; -exec rm {} \;
find "$destination" -type d -empty -delete
@vdbsh
vdbsh / afterdark.sh
Last active July 28, 2022 21:42
Old-school screensaver functionality for GNOME/Wayland desktops
#!/usr/bin/env bash
# afterdark.sh: Old-school screensaver functionality for GNOME/Wayland desktops
# This script will launch arbitrary command after specified time period if there is no inhibiting applications running
# Started process will be terminated after the first sight of user activity
# You supposed to launch something like full-screen video or cmatrix :)
start_after=15 # minutes
cmd="mpv /home/test/Videos/after_dark.mp4 --fs --loop --no-osc"
lock_screen=false
@vdbsh
vdbsh / rpzgen.py
Last active July 9, 2022 02:18
HOSTS to RPZ rules converter for DNS firewalls (like in BIND 9)
#!/usr/bin/env python3
from urllib import request
rpz_file = 'rpz-filter.db'
hosts_file_url = 'https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts'
comment_char = '#'
local = ('127.0.0.1', '255.255.255.255', '::1', 'f')
default_route = '0.0.0.0'
@vdbsh
vdbsh / echolambda.py
Last active June 28, 2022 20:53
Checking host availability with Python's Low-level networking interface and AWS Lambda
from socket import socket, AF_INET, SOCK_STREAM
addresses = [
{'example.com': 80},
{'example.com': 443},
{'host-1234567890-notexist.example.com': 1234}]
def echo(addresses: list):
results = {}
@vdbsh
vdbsh / riprunner.bat
Last active June 28, 2022 20:43
This script will launch your executable and terminate it after its window will be closed. Useful for hunting down zombie processes.
@ECHO off
ECHO ++++++++++++++++++++
ECHO + riprunner 1.0 +
ECHO ++++++++++++++++++++
rem This script will launch your executable and terminate it after its window will be closed.
rem Useful for hunting down zombie processes.
rem
rem (i) Possible start priorities: LOW, NORMAL, HIGH, REALTIME, ABOVENORMAL, BELOWNORMAL.
rem (i) Timeout between checks are set in seconds.