Skip to content

Instantly share code, notes, and snippets.

View MirzaLeka's full-sized avatar
:octocat:

Mirza Leka MirzaLeka

:octocat:
View GitHub Profile
@MirzaLeka
MirzaLeka / installation.md
Created October 16, 2026 10:44
Install NPM dependency for your current project version

Installation problem

Attempting to install a package on outdated Angular version (21)

> npm install ngx-markdown

Output:

npm ERR! code ERESOLVE
@MirzaLeka
MirzaLeka / 0-error-handling-tuple.md
Created October 16, 2026 08:31
Error handling with Tuples in C#

Error handling with Tuples

What is a Tuple?

A tuple is a type that allows for wrapping many different types, e.g,: (string, int, bool), without neededing to create a class.

Service contract

The method contract returns:

  • bool - succesful status check
  • integer - status code
  • Blog - Entity
@MirzaLeka
MirzaLeka / ErrorCore.cs
Last active October 10, 2026 15:08
ASP .NET Core API error-handling using the Result (Reply) pattern
namespace ExceptionHandling.Error
{
internal sealed record ErrorCore : IError
{
public string Title { get; }
public string Message { get; }
public int StatusCode { get; }
public object? Payload { get; }
private ErrorCore(string title, string message, int statusCode, object? payload)
@MirzaLeka
MirzaLeka / result-devto.md
Last active October 10, 2026 18:24
API Error Handling Strategies

Implement blogging:

	public class BlogService : IBlogService 
	{
		private readonly List<Blog> _repository = [];
	
	}
@MirzaLeka
MirzaLeka / cli.md
Last active July 27, 2026 05:16
Kafka survival guide

Get committed offets on Kafka consumer

The guide explains how to inspect consumer using Kafka CLI.

Find running Kafka container:

> docker ps | grep kafka

Enter your Kafka (docker) container:

@MirzaLeka
MirzaLeka / main.md
Created July 25, 2026 09:03
Encapsulation, Abstraction, Inheritance, Immutability, Factory

Applying the Reply (Result) pattern into existing error-handling solution

The project uses the Error class to create new error response objects:

public class Error
{
		public int StatusCode { get; set; }
		public string Message { get; set; }

		public Error(int status, string msg)
@MirzaLeka
MirzaLeka / main.md
Last active July 7, 2026 21:19
Extract data from appsettings using Options pattern

IOptions in ASP .NET Core

Suppose you have some data in appsettings.json and you want to pull out the VapidConfig:

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
@MirzaLeka
MirzaLeka / main.md
Last active July 7, 2026 19:08
AddOrUpdate - C# Concurrent Dictionary

Add Or Update in C# Concurrent Dictionary

Suppose you've created a concurrent dictionary to store key-value pair data.

		private static readonly ConcurrentDictionary<string, PushSubscription> _subscriptions = new();

Then you create a method that inserts data into this dictionary:

@MirzaLeka
MirzaLeka / ExcelResponse.cs
Last active May 30, 2026 09:13
How to build a reusable Excel export service in ASP.NET Core
namespace DotNet8Starter.DL.Models
{
public class ExcelResponse
{
public string Name { get; set; }
public byte[] Data { get; set; }
public static ExcelResponse ToResponse(string name, byte[] data)
{
return new ExcelResponse()
@MirzaLeka
MirzaLeka / create-game-mode.md
Last active May 10, 2026 22:07
Mermaid.js diagram as code

Code analyzed by Claude. Output is a sequence diagram for Mermaid.js.

POST /api/games/NewGameMode — Create

sequenceDiagram
    participant Client
    participant GamesController
    participant GamesService
    participant GamesContext