Skip to content

Instantly share code, notes, and snippets.

@amir-saniyan
amir-saniyan / create-private-branch-of-a-public-repository.md
Last active January 5, 2025 07:43
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 January 7, 2026 19:38
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 

@amir-saniyan
amir-saniyan / EmbedResource.cmake
Last active May 27, 2025 03:31
Pure CMake function to convert any file into C/C++ source code, implemented with only CMake commands.
####################################################################################################
# This function converts any file into C/C++ source code.
# Example:
# - input file: data.dat
# - output file: data.h
# - variable name declared in output file: DATA
# - data length: sizeof(DATA)
# embed_resource("data.dat" "data.h" "DATA")
####################################################################################################