I've been having a few wifi drops and then the pi doesn't reconnect until I reboot it manually. This script solves that.
First, add a new sudo cron
sudo crontab -e
Then adapt and paste the following, change the IP to that of your router or something you expect to be always up
*/5 * * * * /bin/ping -q -c10 192.168.8.1 > /dev/null 2>&1 || (ip link set dev wlan0 down ;ip link set dev wlan0 up ;/usr/bin/logger wifi on wlan0 restarted via crontab)
That's all :)