Created
May 25, 2020 18:34
-
-
Save rlespinasse/efe72603de59d7a56b0544b130921189 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
purp='\x1b[38;5;171m' | |
# shellcheck disable=SC2086 | |
has?() { hash $1 2>/dev/null; } | |
quit() { echo -e "\x1b[2J \x1b[0H ${purp}<3 \x1b[?25h \x1b[u \x1b[m"; } | |
trap "quit" EXIT | |
# shellcheck disable=SC2211 | |
getdata() { | |
if has? curl; then curl -s "$1" | |
elif has? wget; then wget -q -O - "$1" | |
else echo "Can't retrieve Need internet connection. :(" && exit | |
fi | |
} | |
echo -en '\x1b[s' | |
echo -en "\x1b[?25l \x1b[2J \x1b[H" | |
python <(cat <<EOF | |
import sys | |
import time | |
fps = 25; time_per_frame = 1.0 / fps | |
buf = ''; frame = 0; next_frame = 0 | |
begin = time.time() | |
try: | |
for i, line in enumerate(sys.stdin): | |
if i % 32 == 0: | |
frame += 1 | |
sys.stdout.write(buf); buf = '' | |
elapsed = time.time() - begin | |
repose = (frame * time_per_frame) - elapsed | |
if repose > 0.0: | |
time.sleep(repose) | |
next_frame = elapsed / time_per_frame | |
if frame >= next_frame: | |
buf += line | |
except KeyboardInterrupt: | |
pass | |
EOF | |
) < <(getdata "https://keroserene.net/lol/astley80.full.bz2" | bunzip2 -q 2> /dev/null) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment