Skip to content

Instantly share code, notes, and snippets.

View stevenjj's full-sized avatar

Steven Jens Jorgensen stevenjj

View GitHub Profile
@stevenjj
stevenjj / bind_thread_to_core.cpp
Created October 17, 2024 16:16
Bind thread to core with pthread
void bind_thread_to_core(int core_id) {
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
CPU_SET(core_id, &cpuset);
pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
}
@stevenjj
stevenjj / push_old_remote_to_new.md
Last active July 11, 2022 02:58
Git push all branches from old remote to new

Pushes all branches to new git remote

git push destination +refs/remotes/source/*:refs/heads/*

where:

destination - new remote git url/ssh
source - old remote git url/ssh
@stevenjj
stevenjj / create10GBswapSpace
Last active January 6, 2022 01:00
Creates a 10GB swap space in linux
# From: https://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/
# 1. Enter root mode
sudo -s
# 2. Add 10GB of swap space.
# e.g: 10240 MB * 1024 = 10485760
dd if=/dev/zero of=/swapfile1 bs=1024 count=10485760
# Note: the swapfile1 generated is placed in the root folder /
@stevenjj
stevenjj / bestFitLine.py
Created November 19, 2021 19:07
Best fit line with r^2 computation using numpy
#!/usr/bin/env python3
#==================================================================================================================
# Best fit line with r^2 computation using numpy
# Author: Steven Jens Jorgensen
# Nov. 19, 2021
# MIT License
# Description:
# This python code creates a best fit line for a given x and y data series using numpy.polyfit
# It also computes the r^2 value without importing additional dependencies
@stevenjj
stevenjj / chirpRampFunc.py
Last active November 19, 2021 18:17
Chirp signal in python with Tukey window
#!/usr/bin/env python3
#==================================================================================================================
# Chirp Ramp
# Author: Steven Jens Jorgensen
# Nov. 18, 2021
# MIT License
# Description:
# This python code produces a chirp signal which ramps a cosine from a starting frequency to a target frequency.
# A tukey window is applied to ensure smooth amplitude changes in the beginning and end of the signal
@stevenjj
stevenjj / c_cpp_properties.json
Created November 8, 2021 22:35
Simple VSCode cpp properties for ROS catkin development
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/devel/include",
"/opt/ros/noetic/include",
"/usr/include/**",
"${workspaceFolder}/**"
],
printf '[' > compile_commands.json
find ./build -type f -name 'compile_commands.json' -exec sh -c "cat {} | tail -n+2 | head -n-1 && printf ','" >> compile_commands.json \;
sed -i '$s/.$//' compile_commands.json
printf '\n]\n' >> compile_commands.json
@stevenjj
stevenjj / install_gtest_ubuntu.md
Created November 27, 2019 03:59 — forked from Cartexius/install_gtest_ubuntu.md
Install gtest in Ubuntu