nix

configuration files that power my machines
Log | Files | Refs | README | LICENSE

commit df11ee2805e27844f58c6f137b113f181d0f3dfb
parent 4ec9b9b8ba497722fa50b8c231b6f16c48a199ff
Author: mtmn <miro@haravara.org>
Date:   Tue, 16 Jun 2026 13:59:03 +0200

bin: add scripts

Diffstat:
Mhosts/void/default.nix | 2++
Amodules/mixins/dotfiles/bin/iperf-ovh | 69+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amodules/mixins/dotfiles/bin/recup-keep-format | 14++++++++++++++
Amodules/mixins/dotfiles/bin/recup-tiny | 15+++++++++++++++
4 files changed, 100 insertions(+), 0 deletions(-)

diff --git a/hosts/void/default.nix b/hosts/void/default.nix @@ -36,6 +36,8 @@ lowdown miktex ghostscript + gnuplot + ministat ]; vcs = [ diff --git a/modules/mixins/dotfiles/bin/iperf-ovh b/modules/mixins/dotfiles/bin/iperf-ovh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +set -euo pipefail + +SERVER=proof.ovh.net +PORT="" DURATION=10 STREAMS=1 ALL=0 LOGFILE="" + +usage() { + cat <<EOF +Usage: $0 [-p PORT] [-t SECONDS] [-P STREAMS] [-a] [-l FILE] [-h] + +iperf3 upload/download test against ${SERVER} (ports 5201-5210). + +Options: + -p PORT test a specific port (default: try 5201-5210 until one works) + -t SECONDS test duration in seconds (default: ${DURATION}) + -P STREAMS number of parallel streams (default: ${STREAMS}) + -a test all ports 5201-5210 + -l FILE pass --logfile FILE to iperf3 (appends iperf3 output to FILE) + -h show this help and exit +EOF +} + +[ $# -eq 0 ] && { + usage + exit 0 +} + +while getopts "p:t:P:al:h" o; do case "$o" in + p) PORT=$OPTARG ;; + t) DURATION=$OPTARG ;; + P) STREAMS=$OPTARG ;; + a) ALL=1 ;; + l) LOGFILE=$OPTARG ;; + h) + usage + exit 0 + ;; + *) + usage >&2 + exit 1 + ;; + esac done + +command -v iperf3 >/dev/null || { + echo "iperf3 not installed" >&2 + exit 1 +} + +LOG=() +[ -n "$LOGFILE" ] && LOG=(--logfile "$LOGFILE") + +test_port() { + echo "=== ${SERVER}:$1 (${DURATION}s, ${STREAMS} stream) ===" + iperf3 -c "$SERVER" -p "$1" -t "$DURATION" -P "$STREAMS" "${LOG[@]}" -R || return 1 + iperf3 -c "$SERVER" -p "$1" -t "$DURATION" -P "$STREAMS" "${LOG[@]}" +} + +if [ "$ALL" = 1 ]; then + for p in $(seq 5201 5210); do test_port "$p" || true; done +elif [ -n "$PORT" ]; then + test_port "$PORT" +else + for p in $(seq 5201 5210); do + test_port "$p" && exit 0 + echo "port $p busy, trying next..." >&2 + done + echo "all ports busy/unreachable" >&2 + exit 1 +fi diff --git a/modules/mixins/dotfiles/bin/recup-keep-format b/modules/mixins/dotfiles/bin/recup-keep-format @@ -0,0 +1,14 @@ +#!/bin/sh + +recdir="$HOME/misc/recordings" + +mkdir -p "$recdir" + +PICKED=$(eza --oneline --reverse --sort=created "$recdir" | fzf --reverse \ + --preview="ffmpeg -i $recdir/{} -vf 'select=eq(n\,0)' -frames:v 1 -f image2pipe -vcodec png - 2>/dev/null | chafa --format=sixels --size=\${FZF_PREVIEW_COLUMNS}x\${FZF_PREVIEW_LINES} - 2>/dev/null || stat $recdir/{}") + +if [ -n "$PICKED" ]; then + aws s3 cp "$recdir/$PICKED" "s3://recordings/$PICKED" + + shirt "$(aws s3 presign "s3://recordings/$PICKED" --expires-in 604800 | tr -d '\n')" +fi diff --git a/modules/mixins/dotfiles/bin/recup-tiny b/modules/mixins/dotfiles/bin/recup-tiny @@ -0,0 +1,15 @@ +#!/bin/sh + +recdir="$HOME/misc/recordings" + +mkdir -p "$recdir" + +PICKED=$(eza --oneline --reverse --sort=created "$recdir" | fzf --reverse \ + --preview="ffmpeg -i $recdir/{} -vf 'select=eq(n\,0)' -frames:v 1 -f image2pipe -vcodec png - 2>/dev/null | chafa --format=sixels --size=\${FZF_PREVIEW_COLUMNS}x\${FZF_PREVIEW_LINES} - 2>/dev/null || stat $recdir/{}") + +if [ -n "$PICKED" ]; then + ffmpeg -i "$recdir/$PICKED" -vf "scale=-2:720" -c:v libvpx-vp9 -deadline realtime -cpu-used 8 -crf 40 -b:v 0 -c:a libopus -b:a 64k -f webm - | + aws s3 cp - "s3://recordings/${PICKED%.*}.webm" --content-type video/webm + + shirt "$(aws s3 presign "s3://recordings/${PICKED%.*}.webm" --expires-in 604800 | tr -d '\n')" +fi