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 / 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;
@MirzaLeka
MirzaLeka / IOrderService.cs
Last active July 17, 2025 15:01
ASP .NET Worker Service for Apache ActiveMQ
namespace AMQSubscriberWorker.Services
{
public interface IOrderService
{
PizzaOrder? DeserializeOrder(string pizzaOrder);
}
}
@MirzaLeka
MirzaLeka / app-structure.md
Last active April 27, 2025 13:05
HTML & JS Push Notifications

Project Info

This example demonstrates how to handle browser push notifications using vanilla HTML & JavaScript via Web Push API. WebPush API sends messages from the server (backend) to the client (browser/mobile phone). The API uses HTTP2 protocol which requires HTTPS connection (unless you're in localhost) The server sends messages to the client's browser via Firebase Cloud Messaging API (or FCM for short).

Prerequisites

  • You need to obtain the public VAPID key to be able to connect to the server. Look up generate-VAPID-key.md file.
  • Make sure Backend server uses the same VAPID keys.
@MirzaLeka
MirzaLeka / main.md
Last active April 23, 2025 19:39
.NET to Node.js Rabbit MQ Example

.NET to Node.js via Rabbit MQ

  • Sender: .NET 8
  • Receiver: Node.js
  • Protocol: AMQPS (secured AMQP)
  • RabbitMQ Host:: AWS (AMQ)

Package Versions

.NET

@MirzaLeka
MirzaLeka / 0-init.md
Created October 11, 2024 13:52
Angular Reactive Form with Async Validations

Angular Reactive Forms with Validations & Async Validations