Add useful idiotbox technology. - annna - Annna the nice friendly bot. HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/ DIR Log DIR Files DIR Refs DIR Tags DIR README --- DIR commit 1e01eb48430a06a8e2ec480a2e6d8d62e024bb95 DIR parent 2818dd96ec191a68f1266734ff7107b9acb1bb71 HTML Author: eidolon <?> Date: Thu, 24 Oct 2024 13:10:07 -0400 Add useful idiotbox technology. Signed-off-by: Annna Robert-Houdin <annna@bitreich.org> Diffstat: M idiotbox-roulette | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) --- DIR diff --git a/idiotbox-roulette b/idiotbox-roulette @@ -4,17 +4,9 @@ # Thanks! spin() { - awk -F "\t" ' - BEGIN { srand() } - function randomidiot(n) { - return int(rand() * n) - } - /^h/ && !/^hAtom/ { out[i++] = $1" "$2 } - END { - s = out[randomidiot(length(out))] - sub(/URL:/, "url: ", s) - print substr(s, 2) - }' + awk 'BEGIN { FS = "\t"; srand() } + /^h/ && !/^hAtom/ { if (rand() < 1 / ++n) out = $0 } + END { sub(/URL:/, "url: ", out); print substr(out, 2) }' } [ -z "$1" ] && exit 1