I'm a Linux user and what I do is as follows.
I have a folder named cheatsheets, and under that I have folders for topics like bash, java, css, html, sql, etc.
I save each code snippet or cheatsheetcheat sheet in it's own text file with a pertinent name.
Then I made a script based on the locate comand that helps me find the cheatsheet I need.
Besides that I just do grep -iIR into my project folders to find code that I've used before and that I need to use again.