How to deal with sporadic WiFi
Couldn't you decide to do the simplest thing that can be done?!
Just go to Settings -> Wi-Fi -> Advanced and tick the "Avoid poor Internet connection" voice...
This way your device will stop using weak WiFi connections ;)