My trick is to get outside my comfort zone when coding, but only just enough that's it's tolerable and not overwhelming. Most of the time, even as a seasoned coder, I should feel inadequate, yet still up to the task at hand. That's what flow is for me: pushing myself, but not too far that I end up falling off the proverbial cliff.