Skip to content

Instantly share code, notes, and snippets.

View jhurliman's full-sized avatar
🐨

John Hurliman jhurliman

🐨
View GitHub Profile
@jhurliman
jhurliman / l4t-version.sh
Created May 7, 2024 19:28
Extract the NVIDIA Jetson L4T <RELEASE>.<MAJOR> version from /etc/nv_tegra_release
function get_L4T_major_version_only {
# Will return the L4T <release>.<major> version (ex: "32.6" or "32.4")
local RELEASE=$(cat /etc/nv_tegra_release | grep -oP "R\d{2}" | grep -oP "\d{2}")
local MAJOR_VERSION=$(cat /etc/nv_tegra_release | grep -oP "REVISION: \d{1}\.\d{1}" | grep -oP "\d{1}.\d{1}" | grep -oP "\d{1}". | grep -oP "\d{1}")
echo "${RELEASE}.${MAJOR_VERSION}"
}
@jhurliman
jhurliman / base64.js
Created September 29, 2011 06:39 — forked from Marak/base64.js
An extremely simple implementation of base64 encoding / decoding using node.js Buffers (plus url-safe versions)
/*
* base64.js: An extremely simple implementation of base64 encoding / decoding using node.js Buffers
*
* (C) 2010, Nodejitsu Inc.
* (C) 2011, Cull TV, Inc.
*
*/
var base64 = exports;
@jhurliman
jhurliman / catch2-exception-printer.cpp
Created March 8, 2024 05:53
Better C++ exception printing for Catch2
#include <cxxabi.h>
#include <typeinfo>
CATCH_TRANSLATE_EXCEPTION(const std::exception& e) {
std::string s;
int status;
const char* name = typeid(e).name();
char* realname = abi::__cxa_demangle(name, 0, 0, &status);
if (realname) {
@jhurliman
jhurliman / docker-root.sh
Created March 5, 2024 23:13
Use docker to become root on the host system
docker run -it --rm --privileged -v /:/host ubuntu chroot /host bash
@jhurliman
jhurliman / circular_array.h
Created April 5, 2020 08:42
CircularArray - Wraps std::array and provides a circular iterator in C++
#pragma once
#include <algorithm>
#include <array>
template <class T, size_t N>
class CircularArray {
public:
CircularArray() {}
CircularArray(const T initValue) { std::fill_n(data_.begin(), data_.size(), initValue); }
@jhurliman
jhurliman / aquarium_publish.py
Last active August 31, 2023 18:07
Upload a COCO JSON dataset and inference results to Aquarium Learning
#!/usr/bin/env python3
"""Publish ground truth or inference COCO JSON labels to Aquarium."""
import argparse
import os
import typing as tp
from pathlib import Path
import aquariumlearning as al
"""
Convert a tab-separated text file list of timestamped body marker positions
from <https://accad.osu.edu/research/motion-lab/mocap-system-and-data> into an
MCAP file.
"""
import argparse
import csv
import json
import typing as tp
@jhurliman
jhurliman / sample_near_center_of_mass.py
Created July 26, 2023 17:10
[Python] sample_near_center_of_mass(mask, num_samples, distance)
from scipy.ndimage import center_of_mass
from typing import List
Vec2 = Tuple[float, float]
def sample_near_center_of_mass(
mask: NDArray[np.uint8], num_samples: int = 10, distance: float = 5
) -> List[Vec2]:
"""
@jhurliman
jhurliman / start-tensorboard.sh
Created May 4, 2023 16:44
Run a tensorboard docker service
#!/usr/bin/env bash
docker run --init \
-d \
--restart unless-stopped \
--hostname jupiter.martian.ag \
--log-opt max-size=50m \
-p 6006:6006 \
-e DOCKER_USER=$(id -un) \
-e DOCKER_USER_ID=$(id -u) \
@jhurliman
jhurliman / killgpu.sh
Created May 4, 2023 03:53
Shell alias to kill all processes using the GPU. Only for headless NVIDIA GPU machines!
alias killgpu='nvidia-smi --query-compute-apps=pid --format=csv,noheader | xargs --no-run-if-empty sudo kill'