Honestly, it's really simple: two weeks and that's it. Been there 2 years and haven't gotten a raise/promotion? 2 weeks. Been there 10 years and are bored/didn't get what you want? 2 weeks. Don't fall over yourself helping the company. Chances are they are going to forget you in 3 months anyway.
Bad advice. I hate generalities. Last time I left a firm, there was 12 months notice (and the decision was mutual). That was the right choice for both sides. The organization I'm working at right now, it's not uncommon to give years of notice, mostly heading for retirement. Most tech companies are definitely two weeks, but that's far from the universe.
Unless there’s a contract or an extreme circumstance that demands otherwise, 2 weeks is a courtesy and an employer should be ready for 0 days notice.