Skip to content

Instantly share code, notes, and snippets.

View vdbsh's full-sized avatar
🐢
justified!

vdbsh

🐢
justified!
View GitHub Profile
@vdbsh
vdbsh / wd40.sh
Created October 22, 2025 19:54
Sprays away the Rust coreutils and sudo‑rs from Ubuntu 25.10+, restoring trusty GNU tools
#!/usr/bin/env bash
#
# wd40.sh – “spray away” the Rust coreutils and sudo‑rs from Ubuntu 25.10+, restoring trusty GNU tools
#
# --------------------------------------------------------------
set -euo pipefail
# ---------- Helper functions ----------
log() { echo -e "\e[1;34m[INFO]\e[0m $*"; }
@vdbsh
vdbsh / hugo-post-template.py
Created August 11, 2024 03:32
Generating hugo posts with Python
#!/usr/bin/env python3
from datetime import datetime, timezone
from platform import system
from subprocess import call
from sys import argv
from os import path
hugo_posts_dir = '/home/user/blog/content/posts'
@vdbsh
vdbsh / hugo-post-vscode-snippet.jsonc
Last active August 11, 2024 02:50
Hugo post template for VSCode
{
// Setup your timezone after ${CURRENT_SECOND}, default: "Z" (UTC)
"Hugo Post": {
"prefix": ["hugo"],
"scope": "markdown",
"body": [
"+++",
"date = \"${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE}T${CURRENT_HOUR}:${CURRENT_MINUTE}:${CURRENT_SECOND}Z\"",
"title = \"$1\"",
@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 22, 2024 21:43
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)
#
# 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 December 5, 2025 06:58
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 run arbitrary command after specified time period, if there is no inhibiting applications detected
# Started process will be terminated at 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 October 27, 2024 11:58
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.