views:

556

answers:

6

I've read the several discussions about storing code snippets but I did't find the info that I'm looking for, so let's define it:

  • At home, I have several side projects, most of them quite small, one large, and numerous little examples that demonstrate a specific language feature (for example, some template trick in C++).
  • Since I think that these examples will be useful to be available when I'm at work for a reference instead of trying to remember the exact details of this or that particular snippet that was tried and worked at home, I want to have it available for example on a USB flash drive.
  • The problem is that most of the snippets/small programs/examples are organized, written, compiled and tested in Visual Studio, it will be duplication if I have to put them in some code snippet organizer application. I can copy to the flash drive the source of the Visual Studio solution with all the examples, but it is not so convenient for searching compared with a dedicated snippet repository organizer. Or maybe I can change this if I write better comments and description of the examples, and that will do the job.

Any ideas, best practices, solutions, and experience with similar stuff are appreciated.

+2  A: 

I find a Wiki is the perfect tool for keeping bits of info and code snippets.

Hates_
A: 

Not so much for snippets, but for common libraries that I've either collected or developed myself, I keep a folder called "_lib". Whenever I need something from that folder (eg: jquery.js, a CSS reset), I just symlink that directory into my working folder and hey presto! Alternatively, I just use svn:externals to bring it in to other projects.

nickf
+5  A: 

http://codekeep.net

sontek
awesome link!! +100
hasen j
+3  A: 

I store my code within an online source repository - code.google.com, and use the web front-end to browse for the interesting bits.

Since it's on google, it's easy to search too..

All you'd need to do is organise the code into folders for each language, area, etc, and have them all within the same repository.

The only downside is that if you want to keep your snippets secret, then this won't work. Obviously, you'll need to be online to access this way, but you can easily do an SVN update intermittently to refresh any local offline copies you may need.

Ben Laan
A: 

I work in Visual Studio at home and at work.

I basically have all my code snippets in a folder that is synced to my Live Mesh. I then have each folder added to VS to enable it to auto-detect new snippets. Works like a charm for me :)

So, I create a snippet in Snippy, save it to my synced folder. Boom, works in VS with no additional configuration at all :)

Rob Cooper
A: 

I keep everything in a source control repository, indexed by language. As I learn new languages, I translate some of my old useful stuff into the new language to learn how to do things in the new language.

James Thompson