Skip to content

Instantly share code, notes, and snippets.

function copyStylesInline(destinationNode, sourceNode) {
const containerElements = ["svg", "g"];
for (let cd = 0; cd < destinationNode.children.length; cd++) {
const child = destinationNode.children[cd];
if (containerElements.indexOf(child.tagName) !== -1) {
copyStylesInline(child, sourceNode.children[cd]);
continue;
}
const style = sourceNode.children[cd].currentStyle || window.getComputedStyle(sourceNode.children[cd]);
if (style === "undefined" || style == null) continue;
@surajRathi
surajRathi / format.sheets
Created August 12, 2022 12:49
Google Sheets Indian Currency Custom Number Format
[$₹][>9999999]##\,##\,##\,##0.00;[$₹][>99999]##\,##\,##0.00;[$₹]##,##0.00
#! /usr/bin/bash
# Installing ROS
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt install curl -y # if you haven't already installed curl
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo apt update -y
@surajRathi
surajRathi / SSH Reverse Tunneling .md
Created October 25, 2022 11:45
SSH Reverse Tunneling

SSH Reverse Tunneling

  1. Start a SSH Server on you local machine.

  2. Someone with cu access must do:sh -fN -R 7090:localhost:23 keerthi@your_public_ip

    • -f: Fork to background # I think we can drop this flag
    • -N: Dont execute any command
    • -R: Do port forwarding This will bind 7090 on your machine to 22 on the CU.
@surajRathi
surajRathi / print_pkgs.zsh
Last active August 9, 2023 09:16
Extract dependencies from ROS package launch files
#!/usr/bin/zsh
cat **/**.launch | grep -oE '\$\(find [^)]*\)' | cut -d ' ' -f 2 | cut -d ')' -f 1 | sort | uniq
cat **/**.launch | grep -oE 'pkg="[^" ]*?"' | cut -d '"' -f 2 | sort | uniq
# (cat **/**.launch | grep -oE '\$\(find [^)]*\)' | cut -d ' ' -f 2 | cut -d ')' -f 1 | sort | uniq; cat **/**.launch | grep -oE 'pkg="[^" ]*?"' | cut -d '"' -f 2 | sort | uniq) | sort | uniq

From the USB/IP site:

USB/IP Project aims to develop a general USB device sharing system over IP network. To share USB devices between computers with their full functionality, USB/IP encapsulates "USB I/O messages" into TCP/IP payloads and transmits them between computers. Goes without saying, make sure host and client are on the same network.

Host Setup
  • Install usbip package
@surajRathi
surajRathi / jupyter_remote.sh
Created December 10, 2022 12:39
open https://localhost:8080 on the local machine
ssh -L 8080:localhost:8021 [email protected] python -m jupyter notebook --port=8021

To use devices inside your nspawn container do:

Edit systemd-nspawn@<machine_name>.service and add a line like the below

DeviceAllow="/dev/serial/by-id/usb-Roboteq_Motor_Controller_SDC2XXX-if00 rwm"
DeviceAllow=char-ttyACM rwm
DeviceAllow=char-usb_device rwm
DeviceAllow=ttyACM rwm

To see valid device types do:

@surajRathi
surajRathi / sbg.launch
Last active December 16, 2022 16:38
Running SBG Ellipse N
<launch>
<node name="sbg_device" pkg="sbg_driver" type="sbg_device" output="screen">
<rosparam command="load" file="/home/suraj/ws/tmp/sbg/sbg.yaml" />
</node>
</launch>
@surajRathi
surajRathi / .zshrc.local
Last active July 14, 2023 20:00
Arch zsh config
export XDG_CONFIG_HOME=$HOME/.config
# 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.
setopt SHARE_HISTORY # Share history between all sessions.
setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history.
setopt HIST_IGNORE_DUPS # Don't record an entry that was just recorded again.