From 67cce55b6ebca007131b65164465e90c0aab0f44 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Wed, 26 Jun 2024 23:35:21 -0700 Subject: changes --- home/fuwn/meta/scripts/scripts/.gitignore | 6 +- home/fuwn/meta/scripts/scripts/altserver | 3 + home/fuwn/meta/scripts/scripts/anidub | 2 + home/fuwn/meta/scripts/scripts/anime | 2 + home/fuwn/meta/scripts/scripts/apod | 2 + home/fuwn/meta/scripts/scripts/catboy | 2 + home/fuwn/meta/scripts/scripts/chan2 | 2 + home/fuwn/meta/scripts/scripts/fim | 6 ++ home/fuwn/meta/scripts/scripts/gmiwatch | 24 +++++++ home/fuwn/meta/scripts/scripts/hon | 2 + home/fuwn/meta/scripts/scripts/locs | 102 ++++++++++++++++++++++++++++++ home/fuwn/meta/scripts/scripts/reco | 2 + home/fuwn/meta/scripts/scripts/shiori | 2 + home/fuwn/meta/scripts/scripts/skyla | 2 + home/fuwn/meta/scripts/scripts/start-vm | 3 +- home/fuwn/meta/scripts/scripts/wal_mako | 2 + home/fuwn/meta/scripts/scripts/worlds | 15 +++++ 17 files changed, 177 insertions(+), 2 deletions(-) create mode 100755 home/fuwn/meta/scripts/scripts/fim create mode 100755 home/fuwn/meta/scripts/scripts/gmiwatch create mode 100755 home/fuwn/meta/scripts/scripts/locs create mode 100755 home/fuwn/meta/scripts/scripts/worlds diff --git a/home/fuwn/meta/scripts/scripts/.gitignore b/home/fuwn/meta/scripts/scripts/.gitignore index bc90cf1..2ea4e67 100644 --- a/home/fuwn/meta/scripts/scripts/.gitignore +++ b/home/fuwn/meta/scripts/scripts/.gitignore @@ -1,4 +1,8 @@ know hime mirrors -pok \ No newline at end of file +pok +bt +counter +rinny +suzuri \ No newline at end of file diff --git a/home/fuwn/meta/scripts/scripts/altserver b/home/fuwn/meta/scripts/scripts/altserver index 732a973..0a0d5f9 100755 --- a/home/fuwn/meta/scripts/scripts/altserver +++ b/home/fuwn/meta/scripts/scripts/altserver @@ -1,3 +1,5 @@ +# Wrapper around AltServer for usage on *nix + # doas usbmuxd & # export USBMUXD_SOCKET_ADDRESS=127.0.0.1:27015 @@ -6,4 +8,5 @@ docker run -d -v lib_cache:/opt/lib/ --restart=always -p 6969:6969 --name anisette dadoum/anisette-server:latest +# Not very Nix .... ALTSERVER_ANISETTE_SERVER=http://127.0.0.1:6969 python3 ~/.local/src/AltServer-Linux/main.py diff --git a/home/fuwn/meta/scripts/scripts/anidub b/home/fuwn/meta/scripts/scripts/anidub index 7a581b1..aacf84f 100755 --- a/home/fuwn/meta/scripts/scripts/anidub +++ b/home/fuwn/meta/scripts/scripts/anidub @@ -1 +1,3 @@ +# Wrapper around ani-cli (dubbed) for Rofi + ANI_CLI_PLAYER=clapper ani-cli --dub --rofi "${1}" diff --git a/home/fuwn/meta/scripts/scripts/anime b/home/fuwn/meta/scripts/scripts/anime index 73e9f4f..60b143b 100755 --- a/home/fuwn/meta/scripts/scripts/anime +++ b/home/fuwn/meta/scripts/scripts/anime @@ -1 +1,3 @@ +# Wrapper around ani-cli for Rofi + ANI_CLI_PLAYER=mpv ani-cli --rofi "${1}" diff --git a/home/fuwn/meta/scripts/scripts/apod b/home/fuwn/meta/scripts/scripts/apod index f0f38cd..a8814a9 100755 --- a/home/fuwn/meta/scripts/scripts/apod +++ b/home/fuwn/meta/scripts/scripts/apod @@ -1,3 +1,5 @@ +# Get today's Astronomy Picture of the Day (APOD) from NASA + printf \ "https://apod.nasa.gov/apod/%s\\n" \ "$(curl --silent "https://apod.nasa.gov/apod/" | diff --git a/home/fuwn/meta/scripts/scripts/catboy b/home/fuwn/meta/scripts/scripts/catboy index d94c233..cc75e52 100755 --- a/home/fuwn/meta/scripts/scripts/catboy +++ b/home/fuwn/meta/scripts/scripts/catboy @@ -1,3 +1,5 @@ +# VPN wrapper around catgirl + vpn_ip="$(piactl get vpnip)" BIND_INTERFACE=wgpia0 \ diff --git a/home/fuwn/meta/scripts/scripts/chan2 b/home/fuwn/meta/scripts/scripts/chan2 index 9145fd8..525d5f1 100755 --- a/home/fuwn/meta/scripts/scripts/chan2 +++ b/home/fuwn/meta/scripts/scripts/chan2 @@ -1 +1,3 @@ +# Tiny wrapper around chan-downloader + chan-downloader -c 10 --thread "${1}" -o "${2}" diff --git a/home/fuwn/meta/scripts/scripts/fim b/home/fuwn/meta/scripts/scripts/fim new file mode 100755 index 0000000..ad21cd4 --- /dev/null +++ b/home/fuwn/meta/scripts/scripts/fim @@ -0,0 +1,6 @@ +# Finger "blog" updater + +HOST="sina" +PROFILE="/var/lib/docker/volumes/gigi-data/_data/${1:-fuwn}" + +ssh -t "${HOST}" "vim -c 'autocmd BufWritePost * !fmt -w 80 % > %.tmp && mv %.tmp %' '${PROFILE}'" diff --git a/home/fuwn/meta/scripts/scripts/gmiwatch b/home/fuwn/meta/scripts/scripts/gmiwatch new file mode 100755 index 0000000..cf3e52a --- /dev/null +++ b/home/fuwn/meta/scripts/scripts/gmiwatch @@ -0,0 +1,24 @@ +# Gemini capsule watcher, used for development + +usage() { + echo "usage: ${0} [-n interval] " + + exit 1 +} + +while getopts "n:" opt; do + case ${opt} in + n) + interval=${OPTARG} + + shift 2 + ;; + *) usage ;; + esac +done + +if [ -z "${1}" ]; then + usage +fi + +watch -n "${interval:-5}" -t gmni -j always "gemini://${1}" diff --git a/home/fuwn/meta/scripts/scripts/hon b/home/fuwn/meta/scripts/scripts/hon index d0bd2ad..b4436ec 100755 --- a/home/fuwn/meta/scripts/scripts/hon +++ b/home/fuwn/meta/scripts/scripts/hon @@ -1,3 +1,5 @@ +# Personal manga feed wrapper around Suzuri + SUZURI_MINIMAL=1 \ SUZURI_REVERSE=1 \ suzuri \ diff --git a/home/fuwn/meta/scripts/scripts/locs b/home/fuwn/meta/scripts/scripts/locs new file mode 100755 index 0000000..7b0ea19 --- /dev/null +++ b/home/fuwn/meta/scripts/scripts/locs @@ -0,0 +1,102 @@ +# Silly lines-of-code counter + +DEFAULT_COMMENT_STYLES='(//|#|/\*|\*|)' +FILE_MAX_LENGTH=5 + +count_non_empty_lines() { + local file="${1}" + grep -cve '^\s*$' "${file}" +} + +process_files() { + for file in "$@"; do + if [ -f "${file}" ]; then + if [ ${#file} -gt "${longest_filename}" ]; then + longest_filename=${#file} + fi + fi + done + + for file in "$@"; do + if [ -f "${file}" ]; then + lines=$(count_non_empty_lines "${file}") + total_lines=$((total_lines + lines)) + + case "${file}" in + *.gleam) COMMENT_STYLE='(//)' ;; + *.cc | *.hh | *.cpp | *.hpp | *.c | *.h) COMMENT_STYLE='(//|/\*)' ;; + *) COMMENT_STYLE=${DEFAULT_COMMENT_STYLES} ;; + esac + + comments=$(grep -E "^\s*${COMMENT_STYLE}\s*.*\s*$" "${file}" | grep -v '^\s*$' | wc -l) + total_comments=$((total_comments + comments)) + + printf "%-${longest_filename}s %-${FILE_MAX_LENGTH}s %s\n" "${file}" "$((lines - comments))" "${comments}" + + if [ "${LOCS_PRINT_COMMENTS:-0}" = 1 ]; then + grep -n -E "^\s*${COMMENT_STYLE}\s*.*\s*$" "${file}" | grep -v '^\s*$' | sed 's/^/ /' | sed 's/\s*\/\///' | sed 's/\([0-9]\+\): /\1 | /' + + if [ "${comments}" -gt 0 ]; then + echo + fi + fi + fi + done +} + +main() { + local total_lines=0 + local total_comments=0 + local longest_filename=0 + + if [ -z "$1" ]; then + cat < + +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢲⢄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠄⠂⢉⠤⠐⠋⠈⠡⡈⠉⠐⠠⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⢀⡀⢠⣤⠔⠁⢀⠀⠀⠀⠀⠀⠀⠀⠈⢢⠀⠀⠈⠱⡤⣤⠄⣀⠀⠀⠀⠀⠀ +⠀⠀⠰⠁⠀⣰⣿⠃⠀⢠⠃⢸⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠈⢞⣦⡀⠈⡇⠀⠀⠀ +⠀⠀⠀⢇⣠⡿⠁⠀⢀⡃⠀⣈⠀⠀⠀⠀⢰⡀⠀⠀⠀⠀⢢⠰⠀⠀⢺⣧⢰⠀⠀⠀⠀ +⠀⠀⠀⠈⣿⠁⡘⠀⡌⡇⠀⡿⠸⠀⠀⠀⠈⡕⡄⠀⠐⡀⠈⠀⢃⠀⠀⠾⠇⠀⠀⠀⠀ +⠀⠀⠀⠀⠇⡇⠃⢠⠀⠶⡀⡇⢃⠡⡀⠀⠀⠡⠈⢂⡀⢁⠀⡁⠸⠀⡆⠘⡀⠀⠀⠀⠀ +⠀⠀⠀⠸⠀⢸⠀⠘⡜⠀⣑⢴⣀⠑⠯⡂⠄⣀⣣⢀⣈⢺⡜⢣⠀⡆⡇⠀⢣⠀⠀⠀⠀ +⠀⠀⠀⠇⠀⢸⠀⡗⣰⡿⡻⠿⡳⡅⠀⠀⠀⠀⠈⡵⠿⠿⡻⣷⡡⡇⡇⠀⢸⣇⠀⠀⠀ +⠀⠀⢰⠀⠀⡆⡄⣧⡏⠸⢠⢲⢸⠁⠀⠀⠀⠀⠐⢙⢰⠂⢡⠘⣇⡇⠃⠀⠀⢹⡄⠀⠀ +⠀⠀⠟⠀⠀⢰⢁⡇⠇⠰⣀⢁⡜⠀⠀⠀⠀⠀⠀⠘⣀⣁⠌⠀⠃⠰⠀⠀⠀⠈⠰⠀⠀ +⠀⡘⠀⠀⠀⠀⢊⣤⠀⠀⠤⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠤⠄⠀⢸⠃⠀⠀⠀⠀⠀⠃⠀ +⢠⠁⢀⠀⠀⠀⠈⢿⡀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⠀⠀⢀⠏⠀⠀⠀⠀⠀⠀⠸⠀ +⠘⠸⠘⡀⠀⠀⠀⠀⢣⠀⠀⠀⠀⠀⠀⠁⠀⠃⠀⠀⠀⠀⢀⠎⠀⠀⠀⠀⠀⢠⠀⠀⡇ +⠀⠇⢆⢃⠀⠀⠀⠀⠀⡏⢲⢤⢀⡀⠀⠀⠀⠀⠀⢀⣠⠄⡚⠀⠀⠀⠀⠀⠀⣾⠀⠀⠀ +⢰⠈⢌⢎⢆⠀⠀⠀⠀⠁⣌⠆⡰⡁⠉⠉⠀⠉⠁⡱⡘⡼⠇⠀⠀⠀⠀⢀⢬⠃⢠⠀⡆ +⠀⢢⠀⠑⢵⣧⡀⠀⠀⡿⠳⠂⠉⠀⠀⠀⠀⠀⠀⠀⠁⢺⡀⠀⠀⢀⢠⣮⠃⢀⠆⡰⠀ +⠀⠀⠑⠄⣀⠙⡭⠢⢀⡀⠀⠁⠄⣀⣀⠀⢀⣀⣀⣀⡠⠂⢃⡀⠔⠱⡞⢁⠄⣁⠔⠁⠀ +⠀⠀⠀⠀⠀⢠⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⠉⠁⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀ + +EOF + + exit 1 + fi + + local files + + files=$(find "${@}" -type f) + + process_files ${files} >/tmp/lines + + if [ "${LOCS_HEADER:-1}" = 1 ]; then + printf "%-${longest_filename}s %-${FILE_MAX_LENGTH}s %s\n" "filename" "lines" "comments" + fi + + if [ "${LOCS_PRINT_COMMENTS:-0}" = 1 ] || [ "${LOCS_SORT:-1}" = 0 ]; then + cat /tmp/lines + else + sort -k2nr