Created
September 23, 2013 14:02
-
-
Save soxofaan/6670810 to your computer and use it in GitHub Desktop.
Git pre-receive hook to entertain the pusher with a random fact
This file contains hidden or 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
#!/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