DEV Community

Zack
Zack

Posted on

A Better Explaination

Hello, again!

Since my previous post on Snippet was vague, I decided to make a new one, describing what it is for and what possibilities it could have.

A Description of Snippet

(Issue Link) So, you found Snippet. What can you use it for?

It's like Github's Gist, but it's completely offline unless you are updating the library.

  • It's updated every day to make sure everything is working!

It has a variety of "snippets" in multiple programming languages, see Supported Languages

Example Real-World Usage

Let's say you are looking for an example of, (for this example) how to write a string in C.

(There probably are multiple tutorials for this online!) You can't find anything online, but you heard of a Node.JS package called "Snippet". It has code examples in multiple programming languages such as Javascript, Java, C (C# and C++ as well), Python and more.
You check it out, in the snippets folder, you see a folder called c, open it and boom; you found a certain hello_world_c.c script.

It's exactly what you are looking for! Now you can cherish this simple piece of code in your heart, or you can use it.

Installation

Check out this post or use the command:

npm install @matrixoc/snippet

Or get it from GitHub, if you don't want to use the download feature, use the commands:

git remote add origin https://github.com/opensource-matrix/snippet.git
git pull

Supported Languages

AS OF THIS POST

  • C
  • C#
  • C++
  • JavaScript/Node
  • Ruby
  • Crystal
  • Python
  • HTML
  • Batch
  • Shell
  • Java

It's super easy to add a language, let's look into it here!

Creating A Language

  1. Create a new folder in snippets with the name of the programming language.
  2. Run the command `node addLanguage [language name] [language file extensions (separated by spaces]

So for example, to add Objective-C, we could do:

node addLanguage objective-c .objc .m

Conclusion

If you have any questions at all, create an issue, or check out this issue, and that's about it, thanks for reading!

If you want to contribute, go to the GitHub repository, linked here, thanks to the contributors who helped!

Top comments (0)