Coming from experience, it is possible to code on the train. Given that, I was delighted to see that other people agree and organized an event around it:
http://hackatrain.com/
Unfortunately, I won't be able to go as it's the weekend after WWDC but if you're interested, be sure to check it out.