The moment when you've struggled with an annoying bug for hours just to find out that it is caused by your own stupid mistake. (It ALWAYS is. Sometimes just harder to find. Sometimes I haven't even found it *sigh*). Too bad I don't remember any examples of this happening to me.
Also the moment when you've struggled trying to make something work and it has been very complicated and always new problems are occurring. Then you go take a little break and come back just to notice that your 40 line code can be shortened to 10 lines. Happened to me many times. Usually it's some mathematics from which I can't figure out the easiest way and try to make it in a complicated way.. It's actually amazing when you suddenly find a perfect, short formula for calculating things.

Well, these both were more like of nice things which include pain than only painful things.
