How the hell did you not crash after the second one? I’m pretty sure I begin having auditory hallucinations after just one all-nighter!
I've done 96 hours before and I could only do borderline mindless tasks at 20% efficiency, let alone programming.
It's possible to get a few hours each night, work literally every waking hour and be productive for weeks on end (at great peril of course), but for most developers I'd wager productivity is drastically reduced after 48 hours, and almost completely gone by 72.
Recent science says sleep deprivation actually incurs brain damage, so it's definitely never a good idea except for emergencies.
I did get about 6 hours a sleep, just didn't see my pregnant wife, or do anything besides eat, sleep, code. It led to a lot of burnout, and I later quit tech to run a cafe.
1. A project for a client that needed to be done "yesterday". It was a 3 day 1 night project that we charged double for because of the timeline.
2. A multi-million 1 month project that we spent the final week working 100 hours/week. Project management got me a massage chair to sleep in at the office, bought and delivered whatever food I wanted.
3. When my daughter was less than 1 year old and I was freelancing. Days were distracting so I worked nights.
4. Bootstrapping my startup, regularly doing 100 hour weeks for a year. I was burnt out for a year after selling the startup.
In summary, I only recommend it for urgent projects. It's productive for the first 5 nights but after that, productivity drops drastically. Sleep debt is even worse than technical debt.