Organize Your Snippets
For years, I have stored any code I have a hard time remembering into a text file. This just always seemed the most convenient, sure it takes a little bit of time to jot down the snippet you want - but how would one stay organized with different language snippets, and be able to filter / find the code you are looking for without a series of “ctrl+f” searches?
About a year ago, I discovered Snippet Store, a dead simple and lightweight snippet manager for folks with this need. Finally, snippet storage satisfaction.
Syncing Your Scripts Between Devices
I work on a few different machines, so it was a priority to get this data synced - nothing is worse than more data-entry than absolutely necessary. My favorite feature included is the fact that all of the snippets you’ve entered are compiled into one JSON object. This makes it significantly simpler to sync or transfer your snippets via manual or scripted file transfer.
Remote File Streaming
You may host your JSON snippet data file on github, gitlab, dropbox or anywhere other hosting for that matter - though bare in mind your update process, you may need to take additional steps to commit / write changes to the remote file (such as pulling/pushing your snippet file with a github repo).
Google Drive Method
This is what I use to stay synced between devices. If you have a GSuite package, you can set up Google File Stream to store your JSON file on Google Drive. Note - Drive G: is mapped to Google Drive, not a local disk. Then add your snippets and install Snippet Store to your other machine, change the path to match your remote host, and watch your snippets pour in. :)
One of the reasons I love using Google Drive for this because version control is already built in without the need to pull or push from a Repo. If you accidentally wipe your file, just hop into Google Drive for web and track the changes.
Sharing Your Snippets
Since Jekyll supports file-based Data loading for things like content, navigation, settings, etc,I’ve recently recently decided to try to set up a JSON-based snippet feed which stays up-to-date with a github version of my snippets JSON file - I didn’t want to use GDrive for this because it would require some Google API setup and authorization to access the JSON file raw, unlike Github.
You can check it out here.
If you are interested in how this was done...
I will probably do a write-up and a dedicated Github project in the future, when I have worked in a few more features and styled this nicer.
All it really took was installing a gem
and linking the JSON file
The rest is handled in liquid templating.