Skip to content

Instantly share code, notes, and snippets.

@fcalderan
Last active February 25, 2016 10:32
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 fcalderan/673f3d83fb3754b73684 to your computer and use it in GitHub Desktop.
Save fcalderan/673f3d83fb3754b73684 to your computer and use it in GitHub Desktop.
From the Front Early Bird Detector
#!/bin/sh
# set last 2 digits of the current year
year=16
# set terminal title
echo "\033]0;FTF Early Bird Checker\007";
# try to guess the ticket platform
declare -a FTFGuessPlatform=(
"https://getinvited.to/fromthefront/"
"https://ti.to/fromthefront/"
)
# try to guess the slug
declare -a FTFGuessSlug=(
"from-the-front-20$year/"
"fromthefront-20$year/"
"fromthefront20$year/"
"from-the-front-$year/"
"fromthefront-$year/"
"fromthefront$year/"
"ftf-20$year/"
"ftf-$year/"
"ftf20$year/"
"ftf$year/"
"ftf/"
"20$year/"
"$year/"
)
# initialize seconds and wait (don't modify)
seconds=-1
wait=1
while [ true ]
do
# increase seconds
((seconds++))
# clear output on terminal
printf '\r '
if [ $((seconds%wait)) -eq 0 ]; then
# set a random delay to emulate real requests
wait=$(jot -r 1 180 250)
printf '\rChecking Early Bird\n'
guess="`date +%Y-%m-%d` `date +%H:%M:%S`"
guess="\n$guess\n+----------------------------------------------------------------+"
for p in "${FTFGuessPlatform[@]}"
do
for u in "${FTFGuessSlug[@]}"
do
s=$(curl -o /dev/null --silent --head --write-out '%{http_code}\n' $p$u)
if [[ $s -eq 301 || $s -eq 302 || $s -eq 304 || $s -eq 200 ]]; then
echo "+------------------------------------------------------"
echo "| FTF$year Early Bird!"
echo "| $p$u"
echo "+------------------------------------------------------"
# show notification
osascript -e 'display notification "Avalaible now!" with title "FTF'$year' Early Bird!"'
# show window dialog
osascript -e 'tell app "Finder" to display dialog "FTF'$year' Early Bird!\n\nTickets available on '$p$u'"'
# Well done.
exit 1
fi
if [[ $s -eq 0 || $s -eq 404 ]]; then
guess="$guess \n[$s] - $p$u"
fi
done
done
guess="$guess \n\n"
echo $guess
fi
# show remaining time before next check
dots=$( printf "%$(($seconds % 10))s" );
printf '\r%s %d %s' "Check for early bird in" "$(($wait - $seconds % $wait))" "seconds${dots// /.}"
# a one-second delay
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment