Skip to content

Instantly share code, notes, and snippets.

@surajRathi
surajRathi / PathTracking.ipynb
Created January 29, 2024 10:58
Python Implementation of PID and simple geometric controllers with animation code.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@surajRathi
surajRathi / generate_copy_html_cmd.py
Created December 8, 2023 10:30
Copy tmux selection as html (colored)
#! /usr/bin/python3
# Formats taken from the ones that Jetbrains IDEs use.
HTML_FORMATS = (
"text/html;charset=UTF-16",
"text/html;charset=UTF-16BE",
"text/html;charset=UTF-16LE",
"text/html;charset=ISO-8859-1",
"text/html;charset=US-ASCII",
@surajRathi
surajRathi / pc_publisher.h
Created October 23, 2023 11:06 — forked from srathi-monarch/pc_publisher.h
Point Cloud Publishing with sensor_msgs::PointCloudIterator
#include <memory>
#include <tuple>
#include <ros/ros.h>
#include <sensor_msgs/PointCloud2.h>
#include <sensor_msgs/point_cloud2_iterator.h>
template <bool RGB = false> class PCPublisher {
@surajRathi
surajRathi / time_it.hpp
Created October 23, 2023 11:06 — forked from srathi-monarch/time_it.hpp
Simple scope based code execution time printer.
#include <chrono>
#include <iostream>
#include <string>
class TimeIt {
private:
std::string m_name;
std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
@surajRathi
surajRathi / time_it.hpp
Created October 23, 2023 11:06 — forked from srathi-monarch/time_it.hpp
Simple scope based code execution time printer.
#include <chrono>
#include <iostream>
#include <string>
class TimeIt {
private:
std::string m_name;
std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
@surajRathi
surajRathi / fix_timestamps.sh
Last active October 31, 2023 05:39
Fix timestamps for photos saved via whatsapp, to have them show up correctly in Google Photos. Enable backup of both of the Cleansapp folders in Google Photos.
#! /usr/bin/sh
# For Whatsapp saved photos.
adb pull -a -z zstd /storage/emulated/0/Pictures/Whatsapp ./
cd Whatsapp
exiftool '-FileCreateDate<${Filename; s/IMG-([0-9]{4})([0-9]{2})([0-9]{2})-.*\.jpg/$1:$2:$3 12:00:00+5:30/}' '-Exif:DateTimeOriginal<${Filename; s/IMG-([0-9]{4})([0-9]{2})([0-9]{2})-.*\.jpg/$1:$2:$3 12:00:00+5:30/}' *.jpg
cd ..
mv Whatsapp Cleansapp
adb push -z zstd ./Cleansapp /storage/emulated/0/Pictures/
rm -r Cleansapp
@surajRathi
surajRathi / .zshrc.local
Last active July 14, 2023 20:17 — forked from srathi-monarch/.zshrc.local.zsh
Zsh config to be used on top of GRML zsh config. Includes ros, fzf.
export PATH="${PATH}:${HOME}/.local/bin:${HOME}/.cargo/bin"
# export PATH=/usr/local/cuda-11.7/bin${PATH:+:${PATH}}
# export LD_LIBRARY_PATH=/usr/local/cuda-11.7/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
# HISTFILE="$HOME/.zsh_history"
HISTSIZE=10000000
SAVEHIST=10000000
# setopt BANG_HIST # Treat the '!' character specially during expansion.
setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format.
setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits.
@surajRathi
surajRathi / clear_chrome_cache.sh
Created June 2, 2023 09:33
Clear the cache type of directories of Google Chrome in the ~/.config directory.
rm -r ~/.config/google-chrome/Default/{Service\ Worker,File\ System,IndexedDB} ~/.config/google-chrome/Profile\ 2/{Service\ Worker,File\ System,IndexedDB} ~/.config/google-chrome/Profile\ 3/{Service\ Worker,File\ System,IndexedDB} ~/.config/google-chrome/Profile\ 8/{Service\ Worker,File\ System,IndexedDB} ~/.config/google-chrome/Profile\ 11/{Service\ Worker,File\ System,IndexedDB}
@surajRathi
surajRathi / use_minted.tex
Last active April 29, 2023 11:25
When using minted for displaying highlighted code, you need to set the outputdir.
\usepackage[outputdir=../out]{minted}
@surajRathi
surajRathi / no_print.py
Created March 30, 2023 18:08
Blocks printing by remapping sys.stdout and/or sys.stderr.
# Use this as a context manager,
# with NoPrint(stdout=True, stderr=False):
# code_to_run()
class NoPrint:
def __init__(self, stdout=True, stderr=False):
self.stdout = stdout
self.stderr = stderr
def __enter__(self):