Hey everyone! I'm often struggling to find code snippets from past projects since they're scattered across old files and messy folders. I've tried using GitHub Gists, but they lack good searchability and organization. I'm looking for better methods to manage my reusable code. What workflows or tools do you all currently use to keep your personal code library well-organized and easy to search? Any best practices you could share? Thanks!
5 Answers
I like to paste my snippets into OneNote and organize them by topics, which keeps everything neatly categorized and easy to find.
I keep all my reusable code in a private Git repository on GitHub, which I find really handy. To search through my snippets, I use a tool called ripgrep. I keep my file names basic, like 'py01' or 'db01', but make sure to add a clear comment at the top of each file to help jog my memory later on.
I usually commit my most useful snippets to the project repository, sometimes in an 'experimental' folder or as part of a script to make them easier for others to use. I avoid hoarding snippets unless I genuinely think they’ll be useful later on.
For me, if a code snippet is truly reusable, I integrate it into a formal library, depending on the programming language. Honestly, I don’t find snippets to be that fantastic anymore since modern IDEs and tools like copilots take care of a lot of that for us.
I keep a local copy of everything and find that using grep and awk is super helpful. If I need to find things by filename, I use locate. I also have a directory for text notes where I store essential pieces of code and tips on how to accomplish tasks. I sync my scripts and tools across my machines, so I can access what I need from anywhere.
Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically