Ask HN: How do you keep track of small pieces of useful code?
11–20 of 30 posts
Re: Ask HN: How do you keep track of small pieces of useful code?
#12Re: Ask HN: How do you keep track of small pieces of useful code?
#13I find the idea of a personal library of code snippets quite weird. The thought never crossed my mind and I know nobody who uses something like that.
Re: Ask HN: How do you keep track of small pieces of useful code?
#14For local weekend projects I'm not embarrassed to say that I sometimes just include the whole file. It saves me a lot of time and helps me work on the thing I intend to work on instead of searching the net or wasting time on thinking what implementation is the best.
Re: Ask HN: How do you keep track of small pieces of useful code?
#15Private Github gists. But I also have a dropbox for bad code I find in projects.
Re: Ask HN: How do you keep track of small pieces of useful code?
#16Re: Ask HN: How do you keep track of small pieces of useful code?
#17I have created two files everything.js and everything.php. Any time I find a useful function I just add it to those files with a comment and example (if php inside a !defined_fn block). For local weekend projects I'm not embarrassed to say that I sometimes just include the whole file. It saves me a lot of time and helps me work on the thing I intend to work on instead of searching the net or wasting time on thinking…
I might try the "everything.php" or "everything.js" file, scrolling through a single page makes a lot of sense for me as well. But I find I just reference the actual repository in github for backend things, so I can see the context of the use case.
Do you dump "everything.js" and "everything.php" in its own repo in dropbox? Would save the hassle of needing to commit it everytime, pull it from seperate PC's, etc.
I'm still looking for a golden unicorn solution where I just look in one place while still offering micro-testing environments (like codepen). I've tried way too many code snippet solutions it just adds more friction to development
Common snippets I have it all binded by macros.
My goal is to have everything searchable in 3 steps max, one keyboard click, one file navigation button press, and grokking it to find the snippet.
Re: Ask HN: How do you keep track of small pieces of useful code?
#18Interesting question. I never have. I just search for it if I need it. Usually on the web, but sometimes in the codebase. I find the idea of a personal library of code snippets quite weird. The thought never crossed my mind and I know nobody who uses something like that.
Re: Ask HN: How do you keep track of small pieces of useful code?
#19Re: Ask HN: How do you keep track of small pieces of useful code?
#20I'd love to be able to reorganize that into three subfolders: one for .linq linq queries, one for .cs files instead of .linq files, and another for the mock data. Would be great if I could have all of my c# snippets in .cs files and play with them in VS Code, but I can only run the files in VS Code if I'm working with .NET Core.
I've got a similar but far smaller collection for python snippets and experiments (i.e., playing with an API).