Skip to content

Instantly share code, notes, and snippets.

@mcihad
mcihad / main.go
Created January 7, 2024 17:59
Point in Polygon algorithm and parse coordinates from kml file
package main
import (
"encoding/xml"
"fmt"
"os"
"strconv"
"strings"
)
@mcihad
mcihad / choice_from_db.py
Created July 19, 2023 06:49
django choices özelliğinin veritabanından alınması
class Birim(models.Model):
kisa_ad = models.CharField(_("Kısa Ad"), max_length=50)
ad = models.CharField(_("Ad"), max_length=50)
class Meta:
verbose_name = _("Birim")
verbose_name_plural = _("Birimler")
def __str__(self):
return self.ad
package main
import (
"fmt"
"math"
"strings"
)
var birlerList = [...]string{"", "Bir", "İki", "Üç", "Dört", "Beş", "Altı", "Yedi", "Sekiz", "Dokuz"}
var onlarList = [...]string{"", "On", "Yirmi", "Otuz", "Kırk", "Elli", "Altmış", "Yetmiş", "Seksen", "Doksan"}
public class NumberWorker: BackgroundService
{
private readonly ILogger<TimeWorker> _logger;
private readonly ChannelReader<int> _channel;
public NumberWorker(ILogger<TimeWorker> logger, ChannelReader<int> channel)
{
_logger = logger;
_channel = channel;
}
@mcihad
mcihad / main.go
Created December 25, 2022 10:11
Soap Servislerinden Go Programlama Dili İle Kimlik Doğrulama
package main
import (
"bytes"
"encoding/xml"
"fmt"
"io/ioutil"
"net/http"
"text/template"
)
@mcihad
mcihad / index.py
Created December 17, 2022 18:09
Telegram Bot. Download youtube video and send
import os
import asyncio
import youtube_dl
import logging
from urllib.parse import urlparse
from telegram import __version__ as TG_VER
try:
from telegram import __version_info__
@mcihad
mcihad / event_emitter.go
Created November 20, 2022 19:27
Golang EventEmitter
package main
import "fmt"
type EventFunc = func(i interface{})
type Event struct {
Funcs []EventFunc
Once bool
CallCounter int
@mcihad
mcihad / gecikme_hesap.dart
Created April 17, 2020 16:36
Gelir İdaresi Başkanlığının Verilerine Göre Gecikme Zammı Hesabı
import 'package:date_calc/date_calc.dart';
import 'package:test/test.dart';
import 'package:intl/intl.dart';
class DateDifference {
int years;
int months;
int days;
DateDifference(this.years, this.months, this.days);
@mcihad
mcihad / main.py
Created March 2, 2020 06:25
python lru_cache performance test. lru_cache performans testi
from datetime import datetime
from functools import lru_cache, wraps
"""
eğer fonksiyon aldığı parametreye göre aynı sonucu döndürüyor ve bu çok sık tekrar ediyorsa
lru_cache(Least Recently Used) kullanmak performansı ciddi oranda artıracaktır.
"""
def profiler(num: int):
def decorator(func):
@mcihad
mcihad / djangopass.js
Created February 12, 2020 17:31
Nodejs check django password
const crypto = require("crypto")
function checkDjangoPassword(password,encodedPassword) {
var passArr=encodedPassword.split("$")
iter = parseInt(passArr[1])
salt = passArr[2]
shapass = passArr[3]
var key = crypto.pbkdf2Sync(password, salt, iter, 32, 'sha256');
var pass = key.toString("base64")
return pass == shapass