Skip to content

Instantly share code, notes, and snippets.

@nickpegg
Last active September 6, 2017 01:29
Show Gist options
  • Save nickpegg/0618b9e2d34ed04699ff595023f66380 to your computer and use it in GitHub Desktop.
Save nickpegg/0618b9e2d34ed04699ff595023f66380 to your computer and use it in GitHub Desktop.
#!/bin/bash
# requires that imagemagick and wkhtmltopdf are installed
mkdir -p progress
git checkout master
mkhtmltoimage --crop-w 1920 --crop-h 1080 https://nickpegg.com progress/0000.png
count=0
commits=$(git log | grep commit | grep -v initial | awk '{print $2}' | tac)
for commit in $(echo $commits | xargs); do
git checkout "$commit"
i=$((++count))
wkhtmltoimage --crop-w 1920 --crop-h 1080 index.html "progress/$(printf "%04d" "$count").png"
done
# Magical one-liner to remove duplicates
md5sum progress/* | \
sort | \
awk 'BEGIN{lasthash = ""} $1 == lasthash {print $2} {lasthash = $1}' | \
xargs rm
# Add an artificial pause by copying the last file a few times
for i in $(seq $((count+1)) $((count+5))); do
cp progress/$(printf "%04d" "$count").png progress/$(printf "%04d" "$i").png
done
convert -delay 100 progress/*png progress.gif
git checkout master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment