This is what I do:
20 or 30 minutes before lunch I eat an apple. There was a study a few years ago that showed you can crowd out unhealthy food by eating an apple or pear before every meal.
I bring in frozen vegetables from home and I have to eat them before I eat any of the office snacks.
Never drink soda.
Making clear rules makes it easier to follow compared to having to use willpower and thinking about each situation.