Skip to content

Instantly share code, notes, and snippets.

View mirzakhany's full-sized avatar
🎯
Focusing

Mohsen Mirzakhani mirzakhany

🎯
Focusing
View GitHub Profile
@mirzakhany
mirzakhany / tinyURL.go
Created June 3, 2024 09:36 — forked from maxclav/tinyURL.go
Simple Key Generation (using base62 encoded hash) for Tiny URL in Go (GoLang).
package tinuURL
import (
"crypto/md5"
"fmt"
"time"
"github.com/google/uuid"
"github.com/jxskiss/base62"
)
@mirzakhany
mirzakhany / curl.md
Created April 24, 2023 11:24 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@mirzakhany
mirzakhany / kill_quey_pg.sql
Created March 13, 2019 12:44
kill a qurey that hanged
SELECT pg_cancel_backend(pid) FROM pg_stat_activity WHERE state= 'active' AND query='<quey>';
@mirzakhany
mirzakhany / random_str.go
Created August 8, 2018 10:22
fast random string golang
package main
import (
"crypto/sha1"
"fmt"
"math/rand"
"time"
)
var ID = make(chan string)
@mirzakhany
mirzakhany / main.go
Created July 30, 2018 10:07
generate random code in golang for verification sms,email and so on
package main
import (
"fmt"
"math"
"math/rand"
)
func generateCode(length int) string {
x := math.Pow(10, float64(length-1))
@mirzakhany
mirzakhany / utf8_uri_encode.py
Created May 23, 2017 10:17
utf8_uri_encode in python
def utf8_uri_encode(utf8_string, length=0):
unicode = ''
values = []
num_octets = 1
unicode_length = 0
string_length = len(utf8_string)
for i in range(0, string_length):
@mirzakhany
mirzakhany / lcd.c
Created November 16, 2016 13:22
HD44780 LCD module using a 74HCT164 serial in, parallel out out shift register
/*
File: lcd.c
Version: 0.1.0
Date: Feb. 25, 2006
C header file for HD44780 LCD module using a 74HCT164 serial in, parallel
out out shift register to operate the LCD in 8-bit mode. Example schematic
usuing a Powertip PC-1202A LCD available at http://www.micahcarrick.com
Uses the avr-libc library for gcc (avr-gcc).
@mirzakhany
mirzakhany / lm35.c
Created November 16, 2016 13:17
LM35 temp sensor with avr in c
/*
* Author: mohsen Mirzakhany
* website:ellab.ir
* email:[email protected]
*
*
*/
#include <avr/io.h>
@mirzakhany
mirzakhany / meli_code.py
Last active May 22, 2019 06:25
persian national id validation in python
def is_meli_code_valid(meli_code):
code_len = len(str(meli_code))
if code_len < 8 or not meli_code.isdigit():
return False
code_r = '0000000000' + str(meli_code)
code = code_r[-10:]
crc_code = int(code[-1:])
@mirzakhany
mirzakhany / fibonacci.py
Created November 16, 2016 13:05
Fibonacci function in Python
import sys
from math import sqrt
def F(n):
return ((1+sqrt(5))**n-(1-sqrt(5))**n)/(2**n*sqrt(5))
def F():
a,b = 0,1
yield a
yield b
while True: