Skip to content

Instantly share code, notes, and snippets.

@mahelbir
mahelbir / MClient.cs
Created February 19, 2025 13:20
.NET Http Client Library
using System.Text;
using Newtonsoft.Json;
namespace Common;
public class MClient
{
private readonly HttpClient _httpClient;
private readonly List<Task<HttpResponseMessage>> _requests;
private List<MClientResponse> _responses;
@mahelbir
mahelbir / Mapper.cs
Last active February 19, 2025 13:09
.NET Object Mapper
using System.Collections;
using System.Reflection;
namespace Common;
public static class Mapper
{
public static TDestination Map<TSource, TDestination>(TSource source)
where TSource : class
where TDestination : class, new()
@mahelbir
mahelbir / kkm.js
Created August 21, 2022 21:13
Kur Korumalı Vadeli Mevduat Faizi Hesaplama
function kkm(charge, startRate, endRate, days=92, percentage=17){
let interest = charge * (percentage / 100) * (days / 365);
let forex = (endRate - startRate) * (charge / startRate);
if(forex > interest){
return forex + charge;
} else {
return interest + charge;
}
}
@mahelbir
mahelbir / patch.php
Created July 16, 2022 12:22
PHP file to zip changed files (differences between working directory and staging area)
#!/usr/bin/env php
<?php
exec("git diff --name-only --diff-filter=d", $out);
exec("git ls-files --others --exclude-standard", $out2);
if (count($out) > 0 || count($out2) > 0) {
$zip = new ZipArchive();
$zipName = "patch-" . date("YmdHi") . ".zip";
if ($zip->open($zipName, ZipArchive::CREATE)) {
foreach ($out as $line) {