I'm fighting the midnight munchies too. It's starting to be routine for me not to eat after 6 and the urge to eat out of boredom is starting to fade away for me.
What I do when I really want to eat at night is get myself into doing a task. For me it is usually doing some physics problems or playing a video game. The last few hours before bed are the hardest for me and I need something to fill in the time.
Things that might help would be doing a puzzle, playing some games, doing logic oriented things or anything that occupies your mind. I'm not sure that you can fight off the urge to eat effectively, but you can make it so that it isn't a priority in your mind.
It will be routine eventually. Just make sure you got enough calories before then.