Lars wrote in and asked if we've ever done an episode of the podcast discussing impostor syndrome and overcoming self doubt.
Short answer: we did a whole show about it, early in the show: 24: I Am a Total Fraud. You may also like Chris Svec's first visit to the show: 78: Happy Cows. (Actually, I think we talked to Micah Scott about it as well but I'm not sure which episode it was in.)
Long answer: What you are feeling is incredibly common. And it can get a lot worse if you don't take care of it. I have some strategies for dealing with these same feelings (which I have pretty much all the time).
1. Track your progress. We tend to remember the six weeks of feeling stupid and working hard to fix a bug but forget that we fixed the impossible bug because it turned out to be obvious (once you spent six weeks on it). Write down the successes. Keep track of the wins.
2. Create a slide deck of ~10 slides that would impress the hell out of someone else. Whether it is acing the killer class in school, knowing how to sword fight, or solving some problem that only you ever understood, the goal here is to have something to look at when the imposter feelings get too strong. I use it when going into an interview I think I'll fail or for convincing myself that I can do this because (with enough effort and time) I managed to do that. It isn't for other people, just for showing yourself.
3. Treat yourself as an employee. (This is sort of a mental game and is good practice for management.) When you feel especially stupid, stupid-you goes to manager-you and asks what to do. Manager-you will say "try one more thing" or "take a walk" or "you've been at this for 20 hours straight, go home and sleep". Manager-you doesn't have to solve things, manager-you is in charge of making engineer-you more productive (and happy) which sometimes means taking a break or giving encouragement. Another way to look at this is "what would trusted-mentor-friend tell me to do right now?"
4. Learn something else. Take a class in an area that is interesting to you but not your job (gardening, game development, samba dancing, etc.). Success in other areas transfers and no knowledge is ever truly wasted. (And if you hear about me studying calculus for no reason, you'll know why.)
5. Teach other people. If it takes you three days to teach someone else how to setup your dev environment or use a radio spectrum data sniffer, it may help you realize that what you are doing is not as easy or trivial as you feel like it is.
None of these makes the faking-it feeling go away entirely. But they tend to help alleviate my crushing "I should just give up, I've clearly wasted everyone's time by being here" feelings.