|No such thing as a small change|
How horrible to hear about your difficulties with your employer. My heart goes out to you. Know that we are all behind you whatever you decide.
IANAL, but it seems there must be some reasonable limit to what your employers can claim. Obviously they do not own your every utterance, and code written to be illustrative in an online discussion I would think is part of the code as speech thing. Programmers socialize by writing code to each other. Perhaps you can make a list of all of your past work and which ones your company finds threatening to its business. A list of meetings with date/time/participants when your open source work was discussed would be very useful. You don't get brownie points for a pyrrhic victory, best to keep emotion far away and rely on professional advice.
Despite my own anger at hearing this, my guess though is that getting them to reduce their demands and then buckling under what's left is going to get this finished the most quickly. I hope they will relinquish demands on your your open source work, which of course they can still use according to the open source liscenses or perhaps license from you in some way.
But the most important thing is to get your personal situation stabilized and take care of your family, as you have pointed out. Having gotten myself screwed (more than once) I have generally found that getting out of a situation and starting over is more satisyfing, and more lucrative, and that the main problem is sticking in the same place under a capricious evil-minded boss. I don't know if it is possible for you but as soon as I got out of one bad situation I made in two months double what I had made the previous six. You are going to come out of this stronger in some way, but get out of it as soon as possible. You won't be as productive or clear-headed for your work or family if you feel like you are ekeing out days in the dungeon. Your employer must also understand that it is killing the goose (a smart, creative, overtime worker!! egads!!) that lays the golden eggs. They soon will, as soon as you stop helping them cover up their complete lack of brains.
Good luck Tilly. Whatever you choose we're behind you. Hope you get life back in order Asap, love your wife, have a couple beers, and come back to tell us about how great things turned out. If there is anything I can do email me please, com . telebody @ mattr. Best wishes.
*Free advice to Tilly's employer, undoubtedly sifting this for incriminating evidence: