Skip to content

Instantly share code, notes, and snippets.

@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 March 7, 2024 11:48
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:

@amir-saniyan
amir-saniyan / File To Header.md
Last active August 23, 2020 17:48
This code converts any file to C++ header file.

File To Header

This code converts any file to C++ header file.

Usage

usage: file_to_header.py [-h] -i INPUT -o OUTPUT -n NAME [-k KEY]

Converts any file to C++ header file.
@amir-saniyan
amir-saniyan / EmbeddingPython.md
Created August 17, 2020 10:04
C++ implementation of "Hello World" embedding Python

Embedding Python

This gist contains C++ implementation of Hello World embedding Python.

HelloWorld.cpp:

#include <cstdlib>
#include <stdexcept>

#include <Python.h>
@amir-saniyan
amir-saniyan / C++ File IO.md
Created July 22, 2020 16:53
C++ helper functions to read and write files.

C++ File I/O

This gist contains C++ helper functions to read and write files.

FileHelper.h:

#include <string>
#include <vector>

Cross-compiling MXNet on Ubuntu for Raspberry Pi

Obtaining the toolchain

$ sudo apt install crossbuild-essential-armhf
$ sudo apt install crossbuild-essential-arm64