Giving notice can be dangerous, even when you already have another job. It's conceivable an angry supervisor could fire you on the spot, forcing you to lose at least two weeks' pay. If you give too much notice you could end up getting fired as soon as you've wrapped up your work or your replacement is selected. The solution is to give the two weeks that have become customary, and to be prepared to deflect attempts to fire you. The best way to do that is to practice a subtle form of workplace extortion. Your obligation to conclude short‐term projects and prepare memos on your long‐term projects should be implicit with your being given two weeks to wrap things up. By the way, it makes sense to hold off actually preparing and presenting those memos for as long as possible, since they're your only leverage to ensure that you get your final paycheck.
This script can be modified to: