Skip to content

Instantly share code, notes, and snippets.

View ismkdc's full-sized avatar
🏠
Working from home

İsmail Kundakcı ismkdc

🏠
Working from home
View GitHub Profile
public abstract class BaseConsumer(IRedisClient redisClient) : BackgroundService
{
private readonly string _consumerName = Guid.NewGuid().ToString();
private readonly IDatabase _database = redisClient.GetDefaultDatabase().Database;
protected abstract int ReadMaxCount { get; }
protected abstract string StreamName { get; }
protected abstract string GroupName { get; }
protected async Task Consume
(
@ismkdc
ismkdc / php
Created December 13, 2023 21:01
servephp
<?php
// Function to fetch data from MySQL database
function fetchDataFromDatabase() {
// Replace these with your MySQL database credentials
$servername = "your_mysql_host";
$username = "your_mysql_username";
$password = "your_mysql_password";
$dbname = "your_mysql_database";
using BenchmarkDotNet.Attributes;
namespace HashSetDemo;
public class Benchmarks
{
private static readonly HashSet<foo1> hashset1 = new HashSet<foo1>();
private static readonly HashSet<foo2> hashset2 = new HashSet<foo2>();
[GlobalSetup]
using BenchmarkDotNet.Attributes;
namespace HashSetDemo;
public class Benchmarks
{
private static readonly HashSet<foo1> hashset1 = new HashSet<foo1>();
private static readonly HashSet<foo2> hashset2 = new HashSet<foo2>();
[GlobalSetup]
@ismkdc
ismkdc / fcc.cs
Last active September 5, 2023 17:55
fcc
using System.ComponentModel;
using System.Globalization;
using AutoMapper;
using FastExpressionCompiler;
using Mapster;
using Nelibur.ObjectMapper;
using RunTimeMapping.Models;
using RunTimeMapping.Models.MapperlyMappers;
using System.Linq;
using FastExpressionCompiler;
using Mapster;
namespace foobar;
public static class MappingConfiguration
{
public static TypeAdapterConfig Generate()
{
public static class EFQueryExtensions
{
public static async Task<T[]> ToArrayAsyncWithCache<T>(this IQueryable<T> query,
IRedisClient cache, string key, TimeSpan expire = default)
{
var cachedData = await cache.Db0.GetAsync<T[]>(key, CommandFlags.PreferReplica);
if (cachedData != null) return cachedData;
var data = await query.ToArrayAsync();
public class CustomException : Exception
{
public CustomException(CustomError customError)
{
CustomError = customError;
}
public CustomError CustomError { get; set; }
}
public class CustomErrors
{
public static CustomError E_100 = new(nameof(E_100), "Beklenmedik bir sistem hatası oluştu!");
public static CustomError E_200 = new(nameof(E_200), "Kullanıcı adı veya parola hatalı!");
public static CustomError E_201 = new(nameof(E_201), "Eposta zaten kayıtlı!");
public static CustomError E_202 = new(nameof(E_202), "Bütün alanları doldurunuz!");
public class ExceptionMiddleware
{
private readonly RequestDelegate _next;
public ExceptionMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task Invoke(HttpContext context, ILogger<ExceptionMiddleware> logger)