Save all of your code.
Yes, even those weird goofy projects. It's fun to go back and read it all again. I still have code I've written in high school and university, including a game that a friend and I implemented almost entirely inside a single C++ function.
I also now regularly use old code as a kind of mental bookmark about things I've implemented previously. When I'm working on a solution to something I'll sometimes have deja-vu, and I'm glad I still have the old code.