Skip to content

Instantly share code, notes, and snippets.

@sgarciav
sgarciav / rename_files.md
Last active October 9, 2025 20:26
Recursively rename parts of a file from the terminal

Suppose you have a directory with files named rb_001.png and so on with increasing numbers. And you want to rename the rgb part of the name to image. You'll cd into that directory and execute:

find . -type f -exec rename 's/rgb/image/' '{}' \;

You'll need to install:

sudo apt-get update && sudo apt-get install rename

#include <pcl_ros/transforms.hpp>
bool transformCloud(pcl::PointCloud<pcl::PointXYZ>::Ptr& cloud,
const std::string target_frame)
{
const std::string source_frame = cloud->header.frame_id;
geometry_msgs::msg::TransformStamped transform_stamped;
bool success = getTransform(source_frame, target_frame, transform_stamped);
if (not success) { return false; }
pcl_ros::transformPointCloud(*cloud, *cloud, transform_stamped);
@sgarciav
sgarciav / angle_between_vectors.cpp
Created December 4, 2024 21:40
C++ function to compute angle between two vectors
bool angleBetweenVectors(Eigen::Vector3f u, Eigen::Vector3f v, double& angle_rad)
{
float dot_product = u.dot(v);
float norms = u.norm() * v.norm();
// Avoid division by zero or invalid acos input
if (norms == 0) {
RCLCPP_ERROR(this->get_logger(), "One or both vectors have zero magnitude.");
return false;
}
@sgarciav
sgarciav / webcam_settings.md
Last active September 16, 2024 15:19
Webcam Settings via Terminal
@sgarciav
sgarciav / connect_to_internet.md
Created May 22, 2024 01:27
Connect to internet from terminal

Instructions

Taken from here:

  ip a # get DEVICE
  sudo ifconfig <DEVICE> up
  nmcli dev wifi list # get SSID
  sudo nmcli --ask dev wifi connect <SSID>
@sgarciav
sgarciav / pdfgrep_pdftk.md
Created March 27, 2024 19:18
Extract a specfic pdf page given a keyword
  1. Find the page that hosts the keyworkd:

    pdfgrep -in <keyword> <pdf-file>

  2. Extract specific pdf page:

pdftk cat output

@sgarciav
sgarciav / docker_no_sudo.md
Last active September 16, 2024 11:19
Docker without sudo

About

When you first install Docker, you have to execute its commands with sudo. Follow these steps to add your user to the docker group such that there won't be a need to execute with sudo.

See: https://docs.docker.com/engine/install/linux-postinstall/

Steps

  • Add the docker group if it doesn't already exist:
@sgarciav
sgarciav / web-app-notes.md
Last active March 26, 2023 15:01
Collection of notes for Flask and Django development

Alternative method for displaying an image

This method relies on a static folder. Doesn't work when hosted on the web - which is why I needed to leverage the Google Cloud Storage.

@app.route('/display/<filename>')
def display_image(filename):
    return redirect(url_for('static', filename='processed_imgs/' + filename), code=301)

Syntax to use in html file if wanting to use the display_image function

About

Instructions for using git lfs to track large file (greater tham 100MBs). See instructions here.

You can also watch this video to learn about the different features that lfs provides.

$ sudo apt install git-lfs
$ cd /path/to/[GIT REPO]
$ git lfs install
$ git track [filename or type of file you wish to track]