I can't think of any reason why you can't sell it them.
You can buy and sell a teapot on a tourist visa, why not some code?
Email it to them from a .co.uk address..
set up an offshore company.
transfer all your IP rights to offshore company.
either sell shares in offshore company to old employer or enter into a licensing agreement with old company.
don't know though what the tax / visa implications will be.