Skip to content

Instantly share code, notes, and snippets.

@soxofaan
Created September 23, 2013 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soxofaan/6670810 to your computer and use it in GitHub Desktop.
Save soxofaan/6670810 to your computer and use it in GitHub Desktop.
Git pre-receive hook to entertain the pusher with a random fact
#!/bin/sh
# Echo a random fun fact for the pusher's pleasure.
rand=$(( $RANDOM % 5 ))
case "$rand" in
0)
echo "--- Did you know? randomfunfacts.com says: -----------------------------------"
wget --timeout=1 randomfunfacts.com/ -O - 2>/dev/null | grep \<strong\> | sed "s;^.*<i>\(.*\)</i>.*$;\1;"
echo "------------------------------------------------------------------------------"
;;
1)
echo "--- Did you know? http://numbersapi.com/random/trivia says: ------------------"
curl --max-time 1 http://numbersapi.com/random/trivia 2>/dev/null
echo
echo "------------------------------------------------------------------------------"
;;
2)
echo "--- Did you know? http://numbersapi.com/random/math says: --------------------"
curl --max-time 1 http://numbersapi.com/random/math 2>/dev/null
echo
echo "------------------------------------------------------------------------------"
;;
3)
echo "--- Did you know? http://randomfactgenerator.net says: -----------------------"
curl --max-time 1 --silent http://randomfactgenerator.net/ 2>/dev/null | ruby -e "puts (/<div id='z'>(.*?)<br/.match(\$stdin.read)[1])"
echo "------------------------------------------------------------------------------"
;;
4)
url=$( date +http://numbersapi.com/%m/%d/date )
echo "--- Did you know? $url says: ---------------------"
curl --max-time 1 --silent $url 2>/dev/null
echo
echo "------------------------------------------------------------------------------"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment