I have this portfolio website containing some personal projects/algorithm implementations. I want to get attribution if and when other people use my code or snippets of it. I initially thought of using Creative Commons but, as CC itself points out, CC doesn't fit well with software/code distributions. I would've used CC0 but CC0 does not enforce attribution.
So, is there a way for me to enforce attribution on my code ala CC? Including a copy of a FOSS license with every code distribution I have seems overkill---the license itself might be longer than some of my codes. Will copyright claims on top of source codes work if I say there that attribution is required?