I'm 49! I've been working since I'm 17 as a developer -- I think the KEY thing is to be valuable, and be able to change quickly BUT not as quickly as the snowflakes.
Ignore the fad tech, get a good, serious, bulletproof base in actual computer science -- I mean, LOW LEVEL stuff--, that will help you learn ANYTHING computer related quickly, and continue surfing that wave with whatever tech you fancy might actually be useful to make you sellable in the future...
And don't hesitate to drop stuff you invested a lot in. If it's no longer trendy/selling, just drop it like an old sock and spend time updating yourself. I'm a frigging EXPERT in dozens of stuff that would make people smile now (those who are old enough ;-))
And, if you're that old, you should be GOOD. Not just nerdy and opinionated, you should be able to demonstrate being curious, capacity to change, to work with younger guys as a 1:1 basis -- and use that tons of experience of yours in new fields.
I'm lucky, I manage to 'channel' that stuff because I'm probably still more passionate about my job most people will ever be, despite the pile of years, but I've never been 'age discriminated' before. Apart from when I was 18 and winging it a bit ;-)