Windows not tested.
Requirements : iTunes 9.1, iPhone OS 4.0 Beta.
How to Do.
1. Edit your hosts file. (/etc/hosts) and add below.
2. Open iTunes with iPhone connected, Option+Click "Update Check", and choose 4.0 firmware.
Of course, after you finish all your works, remove the line and save it.