Created
April 5, 2016 10:03
-
-
Save erkiesken/412dc16f1947812ecde75bb9fe2344ee to your computer and use it in GitHub Desktop.
Counting default vs custom Gravatars
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/bash | |
set -euo pipefail | |
mkdir -p out | |
while read -r hash; do | |
if [ ! -f "out/$hash" ]; then | |
curl -I -s -o "out/$hash" "http://www.gravatar.com/avatar/$hash" | |
echo "Fetched: $hash" | |
else | |
echo "Skipped: $hash" | |
fi | |
done <email_hash_list.txt |
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/bash | |
set -euo pipefail | |
TOTAL_COUNT=$(find out | wc -l | xargs) | |
echo "Total Gravatar files:" | |
echo " $TOTAL_COUNT" | |
# Two known different default avatars with lengths of 2669 and 2637 bytes. | |
# Can check with: ack -h "Content-Length" out/* | sort | uniq -c | |
DEFAULT_COUNT=$(ack -l "Content-Length: (2669|2637)" out/ | wc -l | xargs) | |
echo "Default Gravatars found:" | |
echo " $DEFAULT_COUNT" | |
echo "Percentage custom Gravatar set vs default Gravatar:" | |
echo " $(echo "scale=3; (1 - $DEFAULT_COUNT / $TOTAL_COUNT) * 100" | bc -l) (custom)" | |
echo " $(echo "scale=3; $DEFAULT_COUNT / $TOTAL_COUNT * 100" | bc -l) (default)" |
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
$ ./check-gravatar.sh | |
... | |
$ ./count-gravatar.sh | |
Total Gravatar files: | |
10565 | |
Default Gravatars found: | |
8351 | |
Percentage custom Gravatar set vs default Gravatar: | |
21.000 (custom) | |
79.000 (default) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment