I've never taken code from a previous job into a job interview. If I have access to that code, I'd be betraying trust by copying it and giving it to someone else. If I don't have access to that code, I can't anyway.
I have had a job application where a programming challenge was emailed to me with a three day deadline for completion, and sent back well structured working code, compilation instructions, a build script and working unit tests. I got called straight in for interview.
That seems reasonable to me; the programming challenge was a specific scenario so you couldn't search stack overflow for code examples (although this was in the days before stack overflow anyway), it let me demonstrate that I could program to a professional level, and it didn't require to me share any code that may belong to someone else.
Indeed. I hire people, and I am looking for way more than 50 lines. At least 500 lines. It should be a non-trivial complete program that does something interesting
I couldn't have done that. My professional work was in a team environment, where my code was part of a greater whole and a 500-1000 line excerpt might do an awful lot but certainly didn't compile and run standalone.
Shit, even my hobby code has that characteristic. Ask Linus for 500 line of his code and see if you get a complete fucking program back.