I give employers/customers a copy of all my pre-existing open-source or private work on a DVD and have them sign a document stating "This code/IP existed before our work agreement and have no claim to any of it, now or in the future, including derivative works." They sign it before I sign any contract of theirs.
This can be hard to demand from larger droid-run companies. The more entrepreneurial businesses understand: they want solutions to immediate problems, and don't care about collecting vague legal hammers that are only useful in the future.