Skip to content

Instantly share code, notes, and snippets.

View mthri's full-sized avatar
🦄

Amir Motahari mthri

🦄
View GitHub Profile
@mthri
mthri / docker_command.MD
Created November 7, 2023 08:24
common docker command
sudo docker rmi
sudo docker rm
sudo docker ps -a
sudo docker exec -it CONTAINER_HASH /bin/sh
sudo docker logs CONTAINER_HASH
sudo docker run -d CONTAINER_NAME:VERSION
sudo docker build -t IMAGE_NAME:VERSION .
sudo docker compose up -d
sudo docker compose down
@mthri
mthri / bash.sh
Created February 12, 2023 11:05
bash command combination for make life easier
# search some word in all log file in current directory
ls | cut -d " " -f2 | xargs grep "WORD"
# see live last log in current directory
ls -ltrh | rev | cut -d' ' -f 1 | rev | tail -n1 | xargs tail -f
@mthri
mthri / ucs2_tools.py
Last active January 2, 2023 08:54
python3 UCS-2 decoder encoder | good for quectel gsm module
import binascii
def ucs2_decode(hex_string: str) -> str:
return binascii.unhexlify(hex_string).decode('utf-16-be')
def ucs2_encode(text: str) -> str:
encoded = text.encode('utf-16-be')
hexlify = binascii.hexlify(encoded)
return hexlify.decode().upper()
@mthri
mthri / script.sh
Created December 24, 2022 16:59
search some word in all files of a folder
ls | cut -d " " -f2 | xargs grep "SOME WORD"
@mthri
mthri / readme.md
Last active September 29, 2022 09:48
get http proxy form proxychain program

If you are using proxychain for chaing proxy then need to get it http proxy for some reason(i.e set it on Telegram) you need to run some proxy server with this program. In this example I will use proxy.py. this is a http proxy server writed with pure python.

after config proxychains use following code.

pip install proxy.py
proxychains proxy

by defualt run http proxy on host 127.0.0.1 and port 8899

@mthri
mthri / converter.py
Created February 5, 2022 07:12
convert arabic alphabet to persian in python
def arabic_to_persian(text: str) -> str:
# arabic: persian
characters = {
'ك': 'ک',
'دِ': 'د',
'بِ': 'ب',
'زِ': 'ز',
'ذِ': 'ذ',
'شِ': 'ش',
'سِ': 'س',
@mthri
mthri / tunneling.sh
Created December 15, 2021 08:52
Create an SSH Tunnel on Linux and Connect to MySQL
ssh -p 22 -N -L 3306:127.0.0.1:3306 [USER]@[SERVER-IP]
# -p -> ssh port
mysql -u [MYSQL-USER] -p -h 127.0.0.1
@mthri
mthri / mysql.sql
Created May 13, 2021 22:37
solved mysql docker tcp connection
CREATE USER 'root'@'%' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
FLUSH PRIVILEGES;
@mthri
mthri / Remove Old Snap Versions.sh
Created May 4, 2021 20:53
Remove Old Snap Versions
#!/bin/bash
# Removes old revisions of snaps
# CLOSE ALL SNAPS BEFORE RUNNING THIS
set -eu
LANG=en_US.UTF-8 snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
snap remove "$snapname" --revision="$revision"
done
@mthri
mthri / check_required_input.js
Created March 7, 2021 12:12
check required input
function full_fill_check(target_element) {
let all_required_checked = true
$(target_element).find('input:required').each((index, element) => {
if (!$(element).val()) {
$(element).attr('placeholder', '*اجباری')
all_required_checked = false
}
})
if (!all_required_checked) {
Swal.fire(