Runnable code snippets for common programming tasks.
content/
├── general/ # Common operations (arrays, strings, math)
├── utilities/ # Encoding, formatting, parsing, validation
├── algorithms/ # Sorting, searching, math algorithms
└── boilerplates/ # Patterns and templates
- Create
{name}-{language}.mdin the appropriate folder - Add frontmatter and code block
- Run
./snippets.sh validate
Snippets are stored in Markdown files to include additional context, metadata and information.
---
title: "Sum Array"
slug: "sum-array-javascript"
description: "Sum all numbers in an array"
language: "javascript"
topic: "arrays"
parameters:
- name: "arr"
type: "array"
default: [1, 2, 3, 4, 5]
description: "Numbers to sum"
exampleOutputs:
- input: { "arr": [1, 2, 3] }
output: "6"
---
```javascript
arr.reduce((sum, n) => sum + n, 0)
```
Additional rich content description for the snippet| Type | Example |
|---|---|
string |
"hello" |
number |
42 |
boolean |
true |
array |
[1, 2, 3] |
object |
{"key": "value"} |
| Language | Output Method |
|---|---|
| JavaScript | Last expression returned |
| Python | Last expression returned |
| Ruby | Last expression returned |
| PHP | echo or last expression |
| Bash | echo |
See SCHEMA.md for the complete specification.
./snippets.sh count # Show snippet counts
./snippets.sh topics # List all topics
./snippets.sh validate # Validate snippets