nitrc:User Guide - Code Snippets
From NITRC Wiki
The Code Snippet Library can be accessed by clicking the Download Code Snippets sub-menu link below the "Tools & Resources" main menu link. The Snippet Library function of NITRC allows users to collect all types of knowledge and information about incomplete fragments of code that are usually difficult to organize and share. Examples include sophisticated shell commands, javascript functions, perl one-liners, SQL expressions that perform special queries, algorithms, etc. Only registered users can add new snippets and create snippet packages.
Contents |
Adding a New Snippet
You can add a new snippet by clicking the Submit New Snippet link at the top of the snippet library pages. A form is displayed, where the following information must be entered:
Required Fields—indicated by a red asterisk (*)
- Title: Enter the title of the snippet. This will be displayed in the list of the snippets.
- Description: Enter the description of the snippet.
- Type: Select the type of the snippet: function, full script, sample code (HOWTO), README, class.
- Language: Select the language of the snippet (if it is language dependent).
- Category: Classify your snippet in the category tree.
- Version: You must enter here the version of the snippet. For a new snippet, enter 1.0.
- Code: Paste the code of the snippet.
Optional Fields
- License: Select the license you want to use for your snippet.
Modifying a Snippet
You cannot modify an existing snippet, but you can add a new version of the snippet by clicking the "Submit a new version" link toward the bottom of the detail page for that snippet. Adding a new version does not delete the old version; all previous versions will be available. If you do wish to delete a version, you may click on the trash can under the Delete column for that snippet version on the detail page.
Creating a Package
You can add a new snippet package by clicking the Create Snippet Package link at the top of the snippet library pages. A form is displayed, where the following information must be entered:
Required Fields—indicated by a red asterisk (*)
- Title: Enter the title of the package. This will be displayed in the list of the snippets.
- Description: Enter the description of the package.
- Language: Select the language of the package (if it is language dependent).
- Category: Classify your package in the category tree.
- Version: You must enter here the version of the package. For a new package, enter 1.0.
After the package has been successfully submitted, you will need to add the snippets to the package. Click the "Add Snippets to Package" link. Select the snippet from the drop down list, and click the "Submit" button. Continue doing this until all desired snippets are included in the package.
Modifying a Package
You cannot remove snippets from a package, but you can add more snippets to an existing package by clicking on the pencil under the Edit/Del column for that package on the detail page. The Add Snippets to Package page is displayed for you to select and submit the snippets to include with the package. You can also submit a new version of the package by clicking the "Submit a new version" link toward the bottom of the detail page for that package. Adding a new version does not delete the old version; all previous versions will be available. If you do wish to delete a package, you may click on the trash can under the Edit/Del column for that package on the detail page.








