It's all self-discipline. Like a diet, you could eat cake an ice cream every meal, but you'd become fat. You need the self-discipline to limit yourself on the Internet to remain productive.
Another way to lOok at it, depending on what motivates you ... Think in terms of "is mark zuckerberg wasting hours on these stupid forums every day?"
When you're actually wasted and don't get anything done because of it, staying up late and trying to get work done will not fix it.
In those cases, it's pretty much the opposite. Stop procrastinating and get a nap or some real sleep. Of course, most places reward busywork more than napping, but if you can determine it yourself, you should value productivity over looking productive.
One positive effect of the stay-up-late-until-you-get-it-done part is that it will make you not care and implement the simple solution that you thought wouldn't work. (In many cases, it actually does).
or you will remember your grandfather (or something like that) who woke up everyday extremely early to go to work at the fields, do the same and get things done.
Another way to lOok at it, depending on what motivates you ... Think in terms of "is mark zuckerberg wasting hours on these stupid forums every day?"