Skip to content

Instantly share code, notes, and snippets.

@jwpleow
jwpleow / cameratest.py
Created May 6, 2022 09:27
Test cameras
# pip install opencv-python
import cv2
numCameraDeviceIndicesToTest = 10
vidcapList = []
for i in range(numCameraDeviceIndicesToTest):
vidcap = cv2.VideoCapture(i)
if vidcap.isOpened():
vidcapList.append(vidcap)
@jwpleow
jwpleow / FindROS.cmake
Last active June 29, 2022 10:07
FindROS.cmake
#=============================================================================
# Finds the ROS library and components for integration into CMake projects without using catkin.
#
# Simply add to your project:
# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/path/to/folder/containing/this/")
# find_package(ROS REQUIRED COMPONENTS roscpp tf2 cv_bridge pcl_ros)
#
# Then, link ros::<component> to your target
# add_executable(myprogram main.cpp)
# target_link_libraries(myprogram ros::roscpp ros::tf2 ros::cv_bridge ros::pcl_ros)
@jwpleow
jwpleow / .zshrc
Last active July 30, 2023 14:23
zshrc
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
@jwpleow
jwpleow / CVSignalling.hpp
Last active June 29, 2022 02:59
Condition Variable wrapper
#include <condition_variable>
#include <mutex>
// For single consumer signalling only! Written to help the listener always retrieve the latest available information
class CVFunctionSignaller
{
private:
enum class SignalState : int8_t
{
Shutdown = -1,
@jwpleow
jwpleow / zsh.bash
Last active July 30, 2023 14:23
zsh setup
# Install zsh from apt
sudo apt install zsh
# Install OMZ plugin manager
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# https://github.com/athityakumar/colorls
# Zsh-z autojump
git clone https://github.com/agkozak/zsh-z $ZSH_CUSTOM/plugins/zsh-z
@jwpleow
jwpleow / pcl-visualiser.cpp
Last active January 25, 2022 07:48
PCL drop in visualisation
#include <pcl/visualization/pcl_visualizer.h>
static auto gviewer = pcl::visualization::PCLVisualizer::Ptr(new pcl::visualization::PCLVisualizer ("3D Viewer"));
static bool gfirstpclreceived{false};
void func(){
pcl::PointCloud<pcl::PointXYZ>::Ptr pcloud(new pcl::PointCloud<pcl::PointXYZ>());
while(true){
// add this in the loop
if (gfirstpclreceived) {
@jwpleow
jwpleow / hardwarelogger.py
Created August 21, 2021 14:42
Hardware logging (Memory usage, CPU by core, Core temperatures)
# python3 -m pip install psutil
import psutil
import datetime
import time
import math
import os
logfile = f'HWLOG-{datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")}.csv'
num_cpus = len(psutil.cpu_percent(percpu=True)) # Do an initial call to start tracking cpu usage
@jwpleow
jwpleow / setup.bash
Last active July 9, 2022 14:12
ubuntu setup script
#!/bin/bash
set -eu
set -o pipefail
# Git
sudo add-apt-repository ppa:git-core/ppa -y
sudo apt update
sudo apt install git -y
# install clang/llvm etc?
#include <ctime> // for std::time
#include <sstream>
#include <chrono>
#include <iomanip>
std::string getDateTime()
{
auto t = std::time(nullptr);
auto tm = *std::localtime(&t); // not thread safe?
std::ostringstream oss;
@jwpleow
jwpleow / .tmux.conf
Last active October 11, 2024 06:46
Setting up tmux
# INSTALLATION
# sudo apt install tmux xsel && git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
# Install plugins with Ctrl+b + I (capitalised!!)
# select text via mouse by holding shift first - if having issues with selection going to another pane, use prefix + z to zoom/unzoom on the current panel
# Prefix default = Ctrl + b (C-b)
# Copy Pasting using copy mode:
# enter copy mode - C-b [, start copying with C-space, and press y to copy with tmux-yank