After pushing the limits of my knowledge (and a lot of practicing), when I write code that does exactly what I expect it to right off the bat - that boosts my confidence. Or, if it doesn't quite do what it's supposed to, and I'm able to quickly find out why and fix it - that also boosts my confidence.

I also found that, for me, any code I write that has practical value helps increase my confidence. Writing a program to calculate the Fibonacci sequence is good practice, but the program itself has little practical value to most people. However, writing code to produce custom pulse sequences that can be used to test products (something I recently did at work as a "pet project") was a rewarding experience for me, and helped improve my confidence in my abilities.

I've never joined an open source project (for the same reason as you, and also because my time is currently limited). But I imagine some of those projects have little tasks that need to be done, to sort of "get your feet wet". Jumping into it might be the best approach. Obviously, you wouldn't be writing the backbone structure of the projects at the start - perhaps find a project with a list of bugs to be addressed, and see if you can fix any of them yourself.