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 / 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

Retry HTTP requests in .NET with Polly

Polly is a powerful library for .NET that helps you handle transient faults and improve the resilience of your applications.

Setup

using Polly;
using System.Net;
@MirzaLeka
MirzaLeka / AppLogger.cs
Created December 23, 2025 08:09
Custom logger in global exception handler
public class AppLogger<T> : IAppLogger<T> where T : class
{
private readonly ILogger<T> _logger;
public AppLogger(ILogger<T> logger)
{
_logger = logger;
}
@MirzaLeka
MirzaLeka / Program.cs
Last active September 7, 2025 23:33
Dummy integration tests c#
using TestingPractice.Services;
namespace TestingPractice
{
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
using APIDocsRider.DB;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
namespace APIDocsRider.BL;
public class WorkerService(ILogger<WorkerService> logger, IServiceProvider serviceProvider) : BackgroundService
{
private readonly IServiceProvider _serviceProvider = serviceProvider;
private readonly ILogger<WorkerService> _logger = logger;