Skip to content

Instantly share code, notes, and snippets.

@amir-saniyan
amir-saniyan / git-pull-all.sh
Created September 29, 2024 13:38
Pull all subdirectory repositories script (two level nested)
#!/usr/bin/env bash
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
cd "$SCRIPTPATH"
for dir in */ ; do
echo "$dir"
cd "$SCRIPTPATH/$dir"
@amir-saniyan
amir-saniyan / aes.py
Created September 24, 2024 10:53
Python 3 - Encrypt/Decrypt using AES 256
# Python 3 - Encrypt/Decrypt using AES 256
# pip install pycryptodome
# Crypto.__version__ == 3.20.0
import base64
import hashlib
from Crypto.Cipher import AES
from Crypto.Random import get_random_bytes
def crop_face(image_path, x, y, width, height, grow=0.25):
try:
image = cv2.imread(image_path)
image_width = image.shape[1]
image_height = image.shape[0]
x = max(0, min(image_width - 1, x))
y = max(0, min(image_height - 1, y))
@amir-saniyan
amir-saniyan / Persian Names Cleaner.md
Last active July 8, 2024 18:21
Persian Names Cleaner

Persian Names Cleaner

from tqdm import tqdm
from collections import OrderedDict
import csv


def read_names(file_path):
    names = []
@amir-saniyan
amir-saniyan / python-motion-detector.md
Last active December 10, 2022 09:49
Python Motion Detector

Python Motion Detector

Motion Detector Using BackgroundSubtractorKNN

import cv2

_IMAGE_SIZE = (512, 512)

_BACKGROUND_SUBTRACTOR_HISTORY = 100
@amir-saniyan
amir-saniyan / create-private-branch-of-a-public-repository.md
Last active September 29, 2024 13:41
Create private branch of a public repository

Create private branch of a public repository

This gist describes how to create private branch (downstream) of a public repository (upstream).

Initialize repository

$ git init private-repo
$ cd private-repo

Cross compiling ONNX Runtime on Ubuntu for Raspberry Pi

The following steps shows how to cross compiling ONNX Runtime on Ubuntu for Raspberry Pi with docker.

Install Docker Engine

Install qemu

Password Protect Web Directories in Nginx Docker Containers

In the name of God

This gist describes how to setup password protect web directories in Nginx docker containers.

Step 1: Create Password File

To create the password file using the OpenSSL utilities, run the following command in terminal:

@amir-saniyan
amir-saniyan / Raspberry Pi Hardware ID.md
Last active March 11, 2024 08:48
Raspberry Pi Hardware ID

In the name of God

Raspberry Pi Hardware ID

The following C++ code, shows how to get Raspberry Pi hardware ID(s) in various ways. You can concatenate the strings and calculate it's hash to take Raspberry Pi Fingerprint:

rpid.cpp: