How can I prevent OS X from resetting/disconnecting from wifi when left idle?
Goto System Preferences -> Energy Saver -> Check "Prevent computer from sleeping automatically when the display is off"

The options may be slightly different depending on what generation macbook you have, but this should help point you to the right place. :)