Skip to content

Instantly share code, notes, and snippets.

@mahelbir
mahelbir / PATCH.py
Created March 7, 2023 01:17
Python script to zip changed files with .git (differences between working directory and staging area)
import subprocess
import os
import zipfile
import sys
from datetime import datetime
out = subprocess.check_output(["git", "diff", "--name-only", "--diff-filter=d"]).decode().splitlines()
out2 = subprocess.check_output(["git", "ls-files", "--others", "--exclude-standard"]).decode().splitlines()
if len(out) > 0 or len(out2) > 0:
@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) {