Snippets

For the purposes of the CodeSnippet gem, a snippet is simply a text file with a piece of code you would like easy access to in it.

For the snippet gem to index and display them properly they should be kept in a location that is set in the SNIPPET_DIR environment variable. This could be in a git repository for version control.

You can file them in any way that makes sense to you, for example:

 - $SNIPPET_DIR
 | - golang
 | - | - for_loop.go
 | - | - switch.go
 | - | - testing/
 | - | - | - table_test.go
 | - | - | - test_http_request.go
 | - ruby
 | - | - switch.rb

The only other requirement (to make them easier to find later) is that the file extension be set as if it were in your application (for example: .rb for ruby files, .go for golang files etc.).

You can put snippets of any kind in the snippets folder so long as it’s text.

Recommendations

As much as possible, try to name files uniquely as it will make it easier to find in the future.