This is just another example of how employment laws in the US are skewed incredibly towards the employer
Er, the laws vary and can be changed by contract. More over in many states it is likely that if you can do a reasonably good job of showing that you worked on code on your own time using your own resources and your employment contract doesn't explicitly claim non-work activities it is yours.
I don't see any problem with laws that say "if the employee agrees anything they own belongs to the company". It is quite unfair if that happens when you don't agree. I think for the most part companies try for "all your work belong to us" so if you really do something on their time and claim you did it on your time it won't matter because they will still own it. As others have said you can frequently alter the contract before you sign (well you can always alter it, they frequently accept the changes).