Code is like a living resume. You are constantly changing and learning, or at least I hope you are. If you’re a developer, you may never know when you might be out of a job, so just like it’s a great idea to keep your resume up to date, I highly recommend keeping some sample code around.
I don’t know how many times I get asked by a recruiter every time I go looking for a job if I have any samples. The answer is always no, and often I get passed up for the guy who does have code and contributes to open source.
But I don’t have time?– I used to think that, but after a couple of coding interviews, I took their ideas, things like a color picker and composed my own github repo containing samples I’d be proud to put my name on.