Is it OK to ask your company that you worked for to provide you with some code, that you did? Because how am I supposed to show my previous work to potential employers?
You can certainly ask. However, when you write code for an organization, they own any and all code that you write. They will most likely say no for the following reasons:
You could be taking the code to a competitor so they have a more in-depth view into their competitions processes and thus give them a business edge.
You could be taking the code for yourself to start your own company that will compete with your previous one.
General trade secrets that could affect market value. If your company is publicly traded, let's just say Apple in this example, and you give them code that reveals a new feature in the next iPhone, that could affect stock prices for a company. I trust you're not that dumb, but who knows.
Any intelligent company would say no to this request, but it doesn't hurt to ask. This is generally why you should contribute to open source projects or have your own projects to showcase code.
Good luck with that
It doesn't hurt to ask, but I would be very surprised if they gave you any code.
However, your situation is common in the industry. Just be prepared to talk about what you did, what you know, how long you've been doing this, and so on.
As an interviewer, looking at 50 lines of code isn't likely to tell me much. (Yes, there are exceptions to that statement for truly terrible code)
I agree with other answers saying it is highly unlikely they will do so. However, you may have a chance if:
- You have coded something with neither confidential information nor mechanisms which are considered strategical by the company
- You manage to convince them to release this code under an open-source license
I give you an example: a company I worked with built a tool to replay packets, such as tcpreplay, but with additional features. It was an internal solution, and they don't even sell software. The manager of this project persuaded the company to release the tool under an open-source license.
As you are not in the company anymore, I would think it is going to be even more difficult though.