Skip to content

Instantly share code, notes, and snippets.

@drench
Last active January 27, 2019 14:37
Show Gist options
  • Save drench/95eecafea8bb945f475692c5fa9ede66 to your computer and use it in GitHub Desktop.
Save drench/95eecafea8bb945f475692c5fa9ede66 to your computer and use it in GitHub Desktop.
Neo-Yow!
#!/bin/sh
yow_url=https://raw.githubusercontent.com/shlomif/fortune-mod/eeea80856c35f1e4487eed3e59829539eb12c07b/fortune-mod/datfiles/zippy
all_yows() {
test -e './yow.dat' || curl --silent $yow_url | sed -E 's#(.)%#\1\\%#g' > yow.dat
cat yow.dat
}
total_yow_count() {
all_yows | grep '^%$' | wc -l
}
yow_index=$(( ( RANDOM % $(total_yow_count) ) ))
all_yows | while read -d% yow; do
if [ $yow_index -eq 0 ]; then
echo $yow
break
else
(( yow_index-- ))
fi
done
@drench
Copy link
Author

drench commented Nov 11, 2018

Demo:

➜ drench@goo:~/Code
% curl --silent https://gist.githubusercontent.com/drench/95eecafea8bb945f475692c5fa9ede66/raw/721554d86466f2ece4c17a66cb7f4fdd1ea1fa46/neoyow.sh > neoyow.sh
➜ drench@goo:~/Code
% chmod +x neoyow.sh
➜ drench@goo:~/Code
% ./neoyow.sh
There's a little picture of ED MCMAHON doing BAD THINGS to JOAN RIVERS in a $200,000 MALIBU BEACH HOUSE!!
➜ drench@goo:~/Code
% ./neoyow.sh
Bo Derek ruined my life!
➜ drench@goo:~/Code
% ./neoyow.sh
Look into my eyes and try to forget that you have a Macy's charge card!
➜ drench@goo:~/Code
% ./neoyow.sh
Well, O.K. I'll compromise with my principles because of EXISTENTIAL DESPAIR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment