You can't miss random days for no real reason. "I worked until 2am" isn't really a good reason... you're paid to come into work. Not to fuck about at home.
Nothing is ever that simple. There are perfectly valid reasons for some companies to be unhappy with a contractor unilaterally deciding to work until 2am, and then not turning up for work the next day.
Falling asleep after your manager texts you to see why you haven't turned up for work today is unprofessional, whether you were staying up late night to code or to binge watch Netflix.
Please note that I am talking about this specific situation here. If you are working on your own products or in a team where people view this as expected behaviour, staying up late to take advantage of as many 'in the zone hours' as possible seems like an effective use of a programmer's time.