Skip to content

Instantly share code, notes, and snippets.

View xacnio's full-sized avatar

Alperen Çetin xacnio

View GitHub Profile
@xacnio
xacnio / date_validate_regex_turkish_month_names.md
Created February 20, 2023 11:52
Date regex validate - turkish month names

Regex Pattern

^(?:(?:31(\/|-|\.|\ )(?:0?[13578]|1[02]|(?:Ocak|Mart|Mayıs|Temmuz|Ağustos|Ekim|Aralık)))\1|(?:(?:29|30)(\/|-|\.|\ )(?:0?[1,3-9]|1[0-2]|(?:Ocak|Mart|Nisan|Mayıs|Haziran|Temmuz|Ağustos|Eylül|Ekim|Kasım|Aralık))\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.|\ )(?:0?2|(?:Şubat))\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.|\ )(?:(?:0?[1-9]|(?:Ocak|Şubat|Mart|Nisan|Mayıs|Haziran|Temmuz|Ağustos|Eylül))|(?:1[0-2]|(?:Ekim|Kasım|Aralık)))\4(?:(?:1[6-9]|[2-9]\d)\d{2})$
  • Validating date (Validating with months' maximum days, checking year for february checking)
  • Multiple separators
  • Month names

Source

@xacnio
xacnio / read-memory-by-proc.cpp
Last active April 19, 2022 14:28
C++ Read Memory By Process on Windows
HWND hwndMyWindow;
hwndMyWindow = FindWindowEx(NULL, NULL, "ConsoleWindowClass", NULL);
if (hwndMyWindow != NULL)
{
DWORD procID;
GetWindowThreadProcessId(hwndMyWindow, &procID);
if (procID != NULL)
{
HANDLE hProcess = OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, FALSE, procID);
if (hProcess)
@xacnio
xacnio / turkish-to-english.go
Created April 11, 2022 18:04
Golang - Turkish characters to english characters
func TurkishToEnglish(text string) string {
var text2 = []rune(text)
chars := map[rune]rune{
'ğ': 'g', 'Ğ': 'G', 'Ü': 'U', 'ü': 'u', 'ş': 's', 'Ş': 'S', 'Ö': 'O', 'ö': 'o', 'ç': 'c', 'Ç': 'C', 'İ': 'I', 'ı': 'i',
}
for i := 0; i < len(text2); i++ {
if val, ok := chars[text2[i]]; ok {
text2[i] = val
}
}
@xacnio
xacnio / telegram_video_sticker_ffmpeg.md
Last active November 17, 2024 23:57
Telegram - Create Video Sticker (.WEBM) with FFMPEG

Command

ffmpeg -y -i animated_sticker.mov -r 30 -t 2.99 -an -c:v libvpx-vp9 -pix_fmt yuva420p -s 512x512 -b:v 400K output.webm
  • If .webm file size greater than 256 KB, you should reduce "-b:v 400K"
  • .mov video file may has alpha channel but not required.
  • My video sticker pack for example: https://t.me/addstickers/msn_animations

Telegram Sticker Command