Skip to content

Instantly share code, notes, and snippets.

@hmahadik
hmahadik / ffmpeg_fast_resize_using_gpu.md
Created February 27, 2024 23:41
ffmpeg fast resize using GPU
docker run -it --rm --gpus all --privileged -v /home/machinevision:/src --workdir=/src nightseas/ffmpeg bash
ffmpeg -hwaccel cuvid -c:v hevc_cuvid -resize 1280x720 -i Dropbox/Mvi\ 0071.mp4 -c:v hevc_nvenc -b:v 5M mvi_0071_720p.mp4
@hmahadik
hmahadik / parallelize.py
Created September 8, 2023 17:33
Parallelize any function using multi-processing in python
""" Based on https://stackoverflow.com/questions/67132064/python-multiprocessing-pool-as-decorator """
import functools
import time
from multiprocessing import Pool
def parallelize(func=None, **options):
if func is None:
return functools.partial(parallel, **options)
def wrapper(iterable, *args, **kwargs):
@hmahadik
hmahadik / install_docker_and_brinq_navqplus.md
Last active May 13, 2024 19:20
Set up docker and brinq edge ai on NavQ+
@hmahadik
hmahadik / sshd_config
Created November 14, 2022 23:08
sshd_config for i.MX 8M Plus
# $OpenBSD: sshd_config,v 1.102 2018/02/16 02:32:40 djm Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
@hmahadik
hmahadik / install_bash_rc_aliases.sh
Last active June 20, 2022 18:12
Update .bashrc and .bash_aliases
echo "Updating .bashrc"
mv ~/.bashrc ~/.bashrc.bk
wget -O ~/.bashrc https://raw.githubusercontent.com/hmahadik/Scripts/master/.bashrc
echo "Updating .bash_aliases"
mv ~/.bash_aliases ~/.bash_aliases.bk
wget -O ~/.bash_aliases https://raw.githubusercontent.com/hmahadik/Scripts/master/.bash_aliases
source ~/.bashrc
@hmahadik
hmahadik / run_samba.sh
Last active October 20, 2021 17:49
Command to run a samba server inside a docker container
#!/bin/sh
docker rm -f samba
docker run -dit --name samba --net host --privileged -v /home/developer:/developer -d dperson/samba -p -u "developer;" -s "developer;/developer;no;no;no;developer" -n
@hmahadik
hmahadik / install_docker_bash_completion.sh
Created October 6, 2021 20:45
Adding docker bash completion to iMX 8M Plus
#!/bin/bash
curl -s https://raw.githubusercontent.com/docker/docker-ce/master/components/cli/contrib/completion/bash/docker -o /usr/share/bash-completion/completions/docker
echo "Remember to log out and log back in for changes to take effect."
@hmahadik
hmahadik / pyarmnn_embed.py
Last active September 14, 2021 19:32
Script to measure time taken to run an embeddings model using pyarmnn
import os
import cv_utils
import network_executor
import utils
import cv2
import time
import sys
try:
model_path = os.path.join('/tmp', sys.argv[1])
@hmahadik
hmahadik / auto-refresh-html-img.js
Created August 19, 2021 15:18
Refreshes the first HTML img element every 5 seconds.
let interval = setInterval(()=>{
let img = document.getElementsByTagName("img").item(0);
img.src = img.src;
console.log("Reloaded. Next reload in 5s.");
}, 5000);
@hmahadik
hmahadik / set-up-nvidia-tegra-apt-repo-sources.sh
Created June 17, 2021 20:47
Run this script from inside the container using sudo
#!/bin/bash
# heavily borrowed from mdegans/docker-tegra-ubuntu
set -eux
wget https://repo.download.nvidia.com/jetson/jetson-ota-public.asc -O /etc/apt/trusted.gpg.d/jetson-ota-public.asc
chmod 644 /etc/apt/trusted.gpg.d/jetson-ota-public.asc
apt-get update && apt-get install -y --no-install-recommends ca-certificates
echo "deb https://repo.download.nvidia.com/jetson/common r32.4 main" > nvidia-l4t-apt-source.list
echo "deb https://repo.download.nvidia.com/jetson/t194 r32.4 main" >> nvidia-l4t-apt-source.list
mv nvidia-l4t-apt-source.list /etc/apt/sources.list.d/
apt-get update