A lot of this, is people with low self esteem, or personality disorders who camouflage their insecurities by projecting them on other people, so that they feel better about themselves.
Speaking from past experience, I think the best way to deal with this is don't let it show that they are upsetting you.
If they are pushing your buttons, and getting a reaction from you, they will continue. Your body language, and the energy you give off will let them know that they struck a cord.
The best way to cope with this is by working on yourself. Trust me, I know it's easier said than done, but if you go into work, with a positive attitude, taking pride in the work that you do, and ignoring the stupid remarks, they will stop. If you go into work dreading the day ahead, and feeling down, they will feed off this. It's like an invitation to inflict more emotional damage. The thing they hate most, is somebody that feels good about themselves, has a positive attitude, and takes their work seriously. Take pride in what you do, do it to the best of your abilities, and build on the small things to increase your self esteem. Laugh at their stupid remarks, and pity them for their insecurities.