Skip to content

Instantly share code, notes, and snippets.

View mahmoud-eskandari's full-sized avatar
🪲
What the bug? WTB?

Mahmoud Eskandari mahmoud-eskandari

🪲
What the bug? WTB?
View GitHub Profile
@mahmoud-eskandari
mahmoud-eskandari / innodb_to_ndbcluster_migration.sh
Last active August 11, 2024 21:29
MySQL InnoDB to NDBCluster migration script (ignores non-compatible foreign keys)
#!/bin/bash
# Written by Mahmoud Eskandari @ BoomerangApp - 2024
# Warning: Backup your innoDB before run!
# ****** Caution ******
# If you mistakenly swap the source and destination,
# the source database will be deleted. This script will also delete and recreate the destination database.
# Please be careful.
#
@mahmoud-eskandari
mahmoud-eskandari / server_publish_mp4_as_hls_golag.go
Last active July 2, 2024 05:43
Simple Golang Mp4 to hls server
package main
import (
"bytes"
"fmt"
"io"
"math"
"net/http"
"os"
"path"
@mahmoud-eskandari
mahmoud-eskandari / README.md
Last active August 8, 2024 13:26
Install v2ray on Bridge:(Ubuntu +18 via systemd) - Upstream (Ubuntu +18/CentOS +7 via docker)

پنل x-ui

پنل تحت وب مدیریت V2ray و ساخت کاربر و مدیریت سرور

mkdir x-ui && cd x-ui
docker run -itd --network=host \
    -v $PWD/db/:/etc/x-ui/ \
 -v $PWD/cert/:/root/cert/ \
@mahmoud-eskandari
mahmoud-eskandari / docker-compose.yml
Created February 8, 2022 09:31
squid-authenticated Docker / Telegram mtproto
version: '3.8'
services:
sq:
image: robhaswell/squid-authenticated
restart: always
ports:
- "3128:3128"
environment:
- "SQUID_USERNAME=user"
- "SQUID_PASSWORD=pass..."
@mahmoud-eskandari
mahmoud-eskandari / first-j-weekday.sql
Last active January 22, 2022 12:10
بدست آوردن نیمه شب شنبه‌ی هفته‌ی جاری در SQL, MySQL
TIMESTAMP(DATE_SUB(CURDATE(),INTERVAL
CASE weekday(CURDATE())
WHEN 0 THEN 2
WHEN 1 THEN 3
WHEN 2 THEN 4
WHEN 3 THEN 5
WHEN 4 THEN 6
WHEN 5 THEN 0
WHEN 6 THEN 1
END
@mahmoud-eskandari
mahmoud-eskandari / CompleteListOfMimeTypes_mime_to_suffix.json
Last active May 2, 2021 02:05
Complete list of mime types to file extensions/suffixes and vice versa
{
"application/andrew-inset": [
"ez"
],
"application/applixware": [
"aw"
],
"application/atom+xml": [
"atom"
],
@mahmoud-eskandari
mahmoud-eskandari / Mount-ext4-disk.text
Last active July 1, 2020 14:04
Mount a new disk to linux
sudo -i
# example sda
lsblk >> get list of partitions
fdisk /dev/sda
>> New Partition
n
@mahmoud-eskandari
mahmoud-eskandari / README.md
Last active April 18, 2023 06:01
SSH Tunnel as systemd service

${LOCAL_ADDR IP:PORT}

یعنی سرور ایرانتون و پورت داخلی که میخواهید روش ساکس داشته باشید و باید با این جایگزین بشود.

مثال:

10.10.10.10:9090

و قسمت پایین هم یوزر سرور خارجتون و آدرس IP سرور خارجیتونه که باید جایگزین کنید تو خط 7 فایل ssh-tunnel-as-systemd.sh

@mahmoud-eskandari
mahmoud-eskandari / GolangSimpleEval.go
Last active May 19, 2020 10:45
Golang Simple Eval string
func EvalStr(str string, input map[string]string) string {
for key := range input {
re := regexp.MustCompile(`(?mU)\[` + key + `\](.*)\[/` + key + `\]`)
for _, match := range re.FindAllString(str, -1) {
if len(input[key]) > 0 {
inner := strings.Replace(match, `[`+key+`]`, "", -1)
inner = strings.Replace(inner, `[/`+key+`]`, "", -1)
str = strings.Replace(str, match, inner, -1)
} else {
str = strings.Replace(str, match, "", 1)
@mahmoud-eskandari
mahmoud-eskandari / _flattenNestedMap.js
Created April 16, 2020 17:11
flatten nested array of objects by a key
function flattenMap(itemList, key) {
return itemList.flatMap(item => {
if (typeof item[key] === 'undefined' || item[key].length === 0) {
return item;
}
let childs = item[key];
delete item[key];
return [item, ...flattenMap(childs, key)];
});
}