Such events are a good reason to lug about a notebook in which you can quickly jot down notions before they evaporate.
OTOH, there is more to be said for the Person from Porlock that that account may make it appear. Odd and unusual things perturb your thoughts and feed your muse with possibilities. Can break deadlocks when you are unaware of how what you just did managed to produce that piece of inspiration. And even when you do know, it can be astounding.
I had an idea for over a decade about a wizard using Egyptian magic and could not write it -- could not even outline it. Then I read a book on Victorian travelers, and a character I thought was a man living in the ancient world, a recluse in the wilderness, filthy and unkempt, metamorphosed in a proper young Victorian Englishwoman. I wrote it soon after.
Random reading in the library or on the Internet, random conversations, random visits to strange locations -- all is grist.