I have a rule, though: I never add code, unless I understand it 100%, and I often make tweaks to adjust it to my immediate needs.
One of my best thefts was a simple FIFO queue, from this book: https://www.objc.io/books/advanced-swift/
This is my adaptation: https://github.com/RiftValleySoftware/RVS_Generic_Swift_Tool...
I really had to do almost nothing to improve it. I think I just extended its utility a bit.
Of course, these weren't your usual SO "academic sample" dudes.