A repository of code snippets and ideas that I can use as a quick way to look up solutions I have developed to various projects.
This repository serves as a personal knowledge base of code snippets, solutions, and best practices collected from various projects. It's organized by language, technology, and problem domain for quick reference and reuse.
snippets/
├── csharp/ # C# code snippets
├── python/ # Python code snippets
├── javascript/ # JavaScript/TypeScript snippets
├── sql/ # SQL queries and database solutions
├── bash/ # Bash scripts and commands
├── powershell/ # PowerShell scripts
├── algorithms/ # Algorithm implementations
├── design-patterns/ # Design pattern examples
├── web/ # Web development snippets (HTML, CSS, etc.)
├── docker/ # Docker configurations and snippets
├── git/ # Git commands and workflows
└── utilities/ # General utility scripts and tools
C# language snippets including LINQ queries, async/await patterns, extension methods, and .NET-specific solutions.
Python scripts and code snippets for data processing, automation, APIs, and common patterns.
JavaScript and TypeScript snippets for web development, Node.js, and modern ES6+ patterns.
SQL queries, stored procedures, optimization techniques, and database-specific solutions.
Bash scripts, one-liners, and shell commands for automation and system administration.
PowerShell scripts and cmdlets for Windows automation and administration.
Common algorithm implementations including sorting, searching, and data structure operations.
Examples of software design patterns with practical implementations.
HTML, CSS, and web development snippets including responsive design and accessibility patterns.
Dockerfile examples, docker-compose configurations, and container management snippets.
Git commands, workflows, and useful aliases for version control.
Cross-platform utility scripts and general-purpose tools.
- Browse the category folders in the
snippets/directory - Check the readme.md in each category for an index of available snippets
- Use GitHub's search functionality to find specific keywords
Each snippet includes:
- Description: What the snippet does
- Code: The actual implementation
- Usage Example: How to use the snippet
- Notes: Any important considerations or dependencies
# String Helper - Truncate with Ellipsis
**Description**: Truncates a string to a specified length and adds ellipsis if needed.
**Code**:
```csharp
public static string Truncate(string value, int maxLength)
{
if (string.IsNullOrEmpty(value)) return value;
return value.Length <= maxLength ? value : value.Substring(0, maxLength) + "...";
}Usage:
string result = StringHelper.Truncate("This is a long text", 10);
// Output: "This is a..."Notes: Works with .NET Framework 4.5+ and .NET Core
This is a personal repository, but feel free to fork and adapt the structure for your own use.
- Choose the appropriate category folder
- Create a new
.mdfile with a descriptive name - Follow the snippet template format
- Update the category's readme.md index
- Commit with a clear message
Use this template when adding new snippets:
# [Snippet Title]
**Description**: [Brief description of what this snippet does]
**Language/Technology**: [e.g., C#, Python, SQL]
**Code**:
```[language]
[Your code here]Usage:
[Usage example]
Notes:
- [Any dependencies]
- [Platform requirements]
- [Performance considerations]
- [Related snippets or alternatives]
This is a personal repository for internal use.
Last Updated: 2025-10-31