We all sometimes come around something we don't know how to or we think someone might have done it better somewhere. But searching and adapting code can be longer than coding in the first place.
My trick :
My search must be 4 words long. No more. Not less.
I'll start from the best solution on front page.
If you start digging to much. You'll spend too much time surfing, not enough coding.
And adapting a solution is the best way to learn !