Stan Lee is probably the modern equivalent, seen in many of the Marvel-inspired movies based on the comicbook superheroes he created. He's played everything from a security guard (alongside Ferrigno) to a hotdog vendor to a Hugh Hefner look-a-like. Sometimes it works, sometimes it doesn't. Often it brings a smile to fans' faces when they catch it, feeling like they're in on the joke. The worst is when it feels too forced, as if the director was ordered to put it in (which is likely the case), not matching the mood of the scenes around it and temporarily derailing the momentum of the plot.
Then we have the vanity cameos, when directors cast themselves in small, supporting roles. Maybe they dreamed of being actors in another life. Quentin Tarantino is quirky enough to be forgiven, since his roles are usually fun for their brief screen-time (e.g., Mr. Brown in Reservoir Dogs, Jimmie Dimmick in Pulp Fiction, Richard Gecko in From Dusk Till Dawn, etc.) On the other hand, someone such as M. Night Shyamalan, for example, is not as good a thespian, so he should just stick to his job behind the camera. His cameo as the stadium drug dealer in Unbreakable, for instance, completely made me suspend my disbelief and think, "Hey, that's the director!"
Samuel L. Jackson playing S.H.I.E.L.D. agent Nick Fury in multiple films was fine, because the character served a purpose to tie the movies together and his appearances actually served the storyline rather than pulled us out. Likewise, the brief appearances by Hugh Jackman as Wolverine and Rebecca Romijn as an older Mystique in X-Men: First Class, while definitely gimmick cameos, still had a point -- to link them in some continuity to the other other X-Men flicks.
What's your favorite gimmick or vanity cameo? Ann B. Davis as Shultzy the trucker in The Brady Bunch Movie? Danny Glover as a bank robber in Maverick? Stephen King in any of his 18 cameo appearances in adaptations of his novels? Someone else? Let me know.