I'm 54 and have been working in Silicon Valley/SF since '96.
Ageism: One way to combat it is to have a good network. Of the 7 jobs I've had in the last 20 years, 6 of them were from personal reference (schoolmate, co-worker, friend). You don't need to be a badass, just dependable.
Work around your limitations: I'm not as sharp as I was in my forties, and this is especially apparent when I pair-program with someone half my age. Younger developers have an astounding short-term memory (or, as my brother likes to phrase it, "they have a much larger register set"). As a simple example, we have 3 environments at work, and at any given moment they're being used for different purposes. I write their purposes down on a scrap of paper to keep it straight, but my twenty-six-year-old pair keeps it in his head.
Stay fresh: I know a 69-year-old developer/contractor say to me, "2000 was pretty good but after that the work dried up — I guess they didn't need COBOL programmers anymore". He had never bothered to stay current.
Make no mistake: picking up new skills can be hard. I remember in '86 when a developer in his 50's turned to me and said, "Brian, I'm tired of learning new things." He really liked to bartend though, so I hope that career worked out for him.
And some developers aren't interested in working anymore (I think this can strike at any age). I remember five years ago pair-programming with a developer my age who wanted to reminisce ("Remember when 640kB was a lot of memory?") and show pictures of his grandkids. I felt bad when they let him go, but it was hard getting work done while I was pairing with him.