Skip to content

Instantly share code, notes, and snippets.

// From the excellent answer here : https://stackoverflow.com/a/17955149/7036639
/*
* daemonize.c
* This example daemonizes a process, writes a few log messages,
* sleeps 20 seconds and terminates afterwards.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@adujardin
adujardin / jetpack_auvidea_j120_tx2.sh
Last active August 13, 2019 16:47
Patch the jetpack for the auvidea carrier board J120 and Tegra X2 https://auvidea.com/firmware/
#/bin/bash
# https://auvidea.com/firmware/
path_jetpack="./64_TX2/"
backup_folder="./64_TX2_backup_files/"
patch_name="auvidea-kernel-J90-J120-v1.6"
wget "http://www.auvidea-pcb.com/firmware/tx2/1.6/${patch_name}.zip"
unzip "${patch_name}.zip"
@adujardin
adujardin / mount_ext4.sh
Created July 30, 2018 12:37
Mount partition fstab
#https://ubuntuforums.org/showthread.php?t=1145596
# Make mounting point
sudo mkdir /mnt/mountpoint # Pick the name for "mountpoint" and use it throughout
sudo chown -R ${USER}: /mnt/mountpoint # Example: sudo chown -R john: /mnt/mountpoint
# find UUID
sudo blkid | grep "sdb1" # assuming it's sdb1
# edit fstab
@adujardin
adujardin / Loader.cpp
Created July 26, 2018 16:30
Dynamic loading of a lib
#define MAJOR_VER 1
#define MINOR_VER 0
#ifdef _WIN32
#define WINDOWS
#endif
#ifdef WINDOWS
#include <Windows.h>
#include <delayimp.h>
@adujardin
adujardin / gen_randstr_and_cpy.sh
Created July 25, 2018 09:24
Generate random string and put them int the clipboard in a loop
#!/bin/bash
while true
do
random_str=" $(cat /dev/urandom | tr -dc 'a-zA-Z' | fold -w 15 | head -n 1)"
echo $random_str
echo -ne " $random_str" | xclip -selection c
sleep 0.1
done
@adujardin
adujardin / install_cudnn.sh
Created July 11, 2018 10:26
Install cuDNN on linux
#!/bin/bash
set -e
NONE='\x1b[m'
BOLD='\x1b[1m'
RED='\x1b[31m'
ITALIC='\x1b[3m'
tmp_folder="/tmp/cudnn_install"
@adujardin
adujardin / castMatEigenSL.cpp
Created April 27, 2018 08:41
Functions to cast the ZED SDK sl::Matrix4f to Eigen::Matrix4f
void Transform2Matrix4f(const sl::Matrix4f &array_, Eigen::Matrix4f &mat_) {
for(int y = 0; y < 4; y++) {
for(int x = 0; x < 4; x++)
mat_(y, x) = array_.m[y * 4 + x];
}
}
void Matrix4f2Transform(const Eigen::Matrix4f &mat_, sl::Matrix4f &array_) {
for(int y = 0; y < 4; y++) {
for(int x = 0; x < 4; x++)
@adujardin
adujardin / maxPerf.sh
Last active February 13, 2018 15:39 — forked from jmtatsch/maxPerf.sh
Nvidia's Max Performance Script for Tegra X1
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
enable_fan(){
# turn on fan for safety
echo "Enabling fan for safety..."
@adujardin
adujardin / tegra_detection.sh
Last active February 13, 2018 15:21
NVIDIA Tegra version detection
#!/bin/bash
tegra_detection=$(
case "$(cat /sys/module/tegra_fuse/parameters/tegra_chip_id)" in
("64") echo "tegra_k1" ;;
("33") echo "tegra_x1" ;;
("24") echo "tegra_x2" ;;
(*) echo "unknown" ;;
esac)
@adujardin
adujardin / ocv_sbs_capture.py
Last active February 14, 2018 17:25
Capture a ZED image with openCV from python without the SDK
import numpy as np
import cv2
cap = cv2.VideoCapture(0) # depending on the ZED ID
while(True):
ret, frame = cap.read() # Capture SbS frames
height, width = frame.shape[:2]
left = frame[0:height,0:int(width*0.5)]