Skip to content

Instantly share code, notes, and snippets.

@gka
Last active May 8, 2017 02:39
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gka/6e49f4a47fe9ded9f6337377e9b37776 to your computer and use it in GitHub Desktop.
Save gka/6e49f4a47fe9ded9f6337377e9b37776 to your computer and use it in GitHub Desktop.
#!/bin/bash
cd $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
blue=$(tput setaf 4)
green=$(tput setaf 2)
normal=$(tput sgr0)
while ./update.sh
do
printf "\n${blue}>>> sleeping a little bit before running again... ${normal}\n"
string='•••••••••••••••••••••••'
while [ -n "$string" ]
do
# printf "\r\e[41m%s\e[0m " "$string"
printf " 😴 ${green}$string ${normal} \r"
sleep 2
string=${string#?}
done
printf "\r 🙂 \n"
done
#!/bin/bash
cd $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
blue=$(tput setaf 4)
normal=$(tput sgr0)
export ROUND=2
export LIVE=1
# export PLAYBACK=20170423-220101
printf "\n${blue}>>> round is set to $ROUND...${normal}\n"
printf "\n${blue}>>> downloading index...${normal}\n"
./download-index.sh
printf "\n${blue}>>> parsing index...${normal}\n"
python parse-index.py
printf "\n${blue}>>> downloading results...${normal}\n"
./download.sh
printf "\n${blue}>>> parsing results...${normal}\n"
python parse-results.py
printf "\n${blue}>>> results json to csv...${normal}\n"
node json2csv.js
if [ "x$PLAYBACK" != 'x' ]; then
printf "\n${blue}>>> using round 1 playback data from $PLAYBACK ${normal}\n"
cp ../playback/$PLAYBACK.json.csv ../out/round$ROUND/csv/results-communes.csv
fi
printf "\n${blue}>>> computing vote totals...${normal}\n"
sleep 2
Rscript summarise.R
node update-timestamp.js
node results-html-table.js
printf "\n${blue}>>> rendering maps...${normal}\n"
node make-maps.js
printf "\n${blue}>>> resizing maps for mobile... ${normal}\n"
cd ../out/round$ROUND/jpg
for img in map-*.jpg
do
convert $img -resize 1000x1000 "mobile-$(basename $img)"
done
cd ..
printf "\n${blue}>>> upload maps and json to S3... ${normal}\n"
if [ "x$LIVE" == 'x1' ]; then
MAXAGE=60 # one minute
aws s3 --profile newsgraphics cp --cache-control max-age=$MAXAGE --recursive --acl public-read jpg/ s3://int.nyt.com/newsgraphics/2017/05/french-election/
aws s3 --profile newsgraphics cp --cache-control max-age=$MAXAGE --acl public-read json/departments.json s3://int.nyt.com/newsgraphics/2017/05/french-election/
aws s3 --profile newsgraphics cp --cache-control max-age=$MAXAGE --acl public-read json/total.json s3://int.nyt.com/newsgraphics/2017/05/french-election/
aws s3 --profile newsgraphics cp --cache-control max-age=$MAXAGE --acl public-read csv/results-communes.csv s3://int.nyt.com/newsgraphics/2017/05/french-election/
else
printf 'not publishing yet\n'
fi
printf "\n${blue}>>> all done!${normal}\n"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment