I learnt that in a workplace, be replaceable. As ironic as it sounds, that will keep you the job (along with your other great qualities). For a developer, keep your code clean, organized, COMMENTED. Have documentation.
I recently left a position as a developer where I may have been considered irreplaceable by some. I had worked with some systems and websites for so long I became a fixture of this organization.
When opportunities and change were presented to me from higher-ups in my organization my direct supervisors took it upon themselves to do everything in their power to prevent it. It wasn't pretty, there was plenty of drama, guilt, and even some underhandedness. Needless to say I found a new position ASAP.
In my new position I'm replaceable. I believe that if I left today someone could take my place relatively easily. However, I'm much happier and it's refreshing to feel like I have mobility in my career again.
Being replaceable is obviously important for career advancement. If you can't be replaced at your current position, how can you be promoted to a higher position, to a more interesting project, ect?