Adding the script here since I couldn't figure out how to fork from gist.