Skip to content

Instantly share code, notes, and snippets.

View VSharapov's full-sized avatar
☁️
Tiny webapps on free tier - https://news.ycombinator.com/item?id=26242844

Vasiliy Sharapov VSharapov

☁️
Tiny webapps on free tier - https://news.ycombinator.com/item?id=26242844
  • rotor.ai
  • Boston, MA
  • 23:20 (UTC -04:00)
View GitHub Profile
@VSharapov
VSharapov / set-dhcp-hostname-on-secondary-interface.sh
Created July 2, 2026 18:20
Give same-subnet secondary NICs a distinct DHCP hostname so the bare name tracks the primary
#!/usr/bin/env bash
set -Eeuo pipefail
primary-line() { ip -o route show default | awk '{m=0;for(i=1;i<=NF;i++)if($i=="metric")m=$(i+1);print m"\t"$0}' | sort -n | head -1 | cut -f2-; }
primary-iface() { primary-line | grep -oP 'dev \K\S+'; }
default-gateway() { primary-line | grep -oP 'via \K\S+'; }
iface-subnet() { ip -o -4 route show dev "$1" scope link proto kernel | awk '{print $1; exit}'; }
primary-subnet() { iface-subnet "$(primary-iface)"; }
secondary-ifaces() {
@VSharapov
VSharapov / README.md
Created October 9, 2025 19:37
Sample ed25519 keypair - do not use

ed25519 keypair

It's on the public web. Anyone can get access to the private key. Do not use this for anything.

...I'm just testing stuff and it's an easy little hack.

@VSharapov
VSharapov / sanity-test-docker-cp.sh
Last active September 16, 2025 15:20
Will docker cp overwrite stuff on the destination as expected?
#!/usr/bin/env bash
for test in "bare file" "directory"; do
prefix=""
container_path="/foo"
if [ "$test" = "directory" ]; then
mkdir -p "/tmp/foodir"
prefix="/foodir"
container_path="/foodir"
fi
#!/usr/bin/env bash
x=$(mktemp --suffix=.py)
curl -L https://github.com/9001/copyparty/releases/latest/download/copyparty-sfx.py -o "$x"
python "$x"
rm -i "$x"
@VSharapov
VSharapov / password_change_manually.sh
Created June 6, 2025 21:42
If there's no `passwd` or `chpasswd` try this jank
#!/bin/sh
set -eu
# DEBUG=true
DEBUG=false
if $DEBUG; then
trap 'echo "# $BASH_COMMAND";read' DEBUG
fi
@VSharapov
VSharapov / gitlabRunnerGracefullExit.sh
Created May 28, 2025 15:40
Send gitlab-runner main PID a SIGQUIT and wait for jobs to finish
#!/usr/bin/env bash
sudo kill -SIGQUIT $(systemctl show gitlab-runner.service -p MainPID | cut -d= -f2) && \
while systemctl is-active gitlab-runner.service ; do sleep 2; done
@VSharapov
VSharapov / gitsplz.sh
Last active June 6, 2025 19:19
Pick a gist and run it
#!/bin/sh
set -eu
tmp_file=$(mktemp) && echo -e '#!/bin/sh\nexit 0' > "$tmp_file" && chmod +x "$tmp_file" && "$tmp_file" || tmp_file=$(mktemp -p "$HOME") || exit 1
gists=$(curl -s https://api.github.com/users/VSharapov/gists | jq -r '.[].files[].raw_url')
[ -z "$gists" ] && exit 1
selected_gist=$(echo "$gists" | fzf) || select selected_gist in $gists; do break; done
curl -s "$selected_gist" -o "$tmp_file" && chmod +x "$tmp_file" && "$tmp_file" "@"
rm -i "$tmp_file"
@VSharapov
VSharapov / inhibitLidOnce.sh
Created February 18, 2025 23:19
Inhibit lid switch until reboot
#!/usr/bin/env bash
sudo systemd-inhibit --what=handle-lid-switch --mode=block sleep 9999d & disown
@VSharapov
VSharapov / make_sudo_passwordless.sh
Created February 18, 2025 22:50
Make sudo passwordless for current user
#!/usr/bin/env bash
echo "$USER ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/$USER > /dev/null
@VSharapov
VSharapov / listAccessibleMachines.sh
Created November 6, 2024 18:42
Try a set of credentials on all machines in a set of subnets
#!/usr/bin/env bash
### recommended usage is something like:
### export PARAM_SUBNETS="10.69.0.0/16 192.168.1.0/24"; export PARAM_USERNAME=ubuntu; [ -z "$PARAM_PASSWORD" ] && { read -s ; export PARAM_PASSWORD="$REPLY" ; } ; ./listAccessibleMachines.sh
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)