Skip to content

Instantly share code, notes, and snippets.

View zamantousif's full-sized avatar
😎
Your best teacher is your last mistake

Mohammed Tousif Zaman zamantousif

😎
Your best teacher is your last mistake
View GitHub Profile
@zamantousif
zamantousif / gist:5fef5f118b58620009d68a7047dfdd07
Created June 5, 2024 07:27
Kill all instances of a program in linux
# uses pkill to kill the process
# to echo the PIDs
# echo $(ps -ef | grep "some search" | awk '{print $2}')
# e.g. to kill every instance of "spotify" app
for pid in $(ps -ef | grep "spotify" | awk '{print $2}'); do pkill -9 $pid; done
@zamantousif
zamantousif / gist:c00b0f4c61dcb4141868f4282a7c6b37
Created April 18, 2024 11:58
Choose from all available terminals
# Choose which terminal to use by default from all available ones
update-alternatives --config x-terminal-emulator
@zamantousif
zamantousif / gist:0a89c56e06bd9087aa4908b2f5ce23ff
Last active April 17, 2024 14:50
Install/update nodejs npm using nodesource API on Ubuntu
# Check the valid version to install as per your Ubuntu distribution on nodesource github
# https://github.com/nodesource/distributions?tab=readme-ov-file#ubuntu-versions
# Run below commands for installing latest available nodejs from nodesource ppa on Ubuntu 22.04 (latest at the time of writing)
curl -fsSL https://deb.nodesource.com/setup_21.x | sudo -E bash - &&\
sudo apt-get install -y nodejs
# If running into dpkg errors, follow the advice here https://github.com/nodesource/distributions/issues/1157#issuecomment-1605699451
# sudo dpkg --remove --force-remove-reinstreq libnode72:amd64
@zamantousif
zamantousif / create_ubuntu_iso.sh
Created July 21, 2023 13:54
Create bootable disk from ubuntu iso
# Note the correct disk to install the ubuntu OS: e.g. /dev/sdx
fdisk -l
# Copy the ISO file to the disk
sudo dd bs=4M if=/path/to/iso of=/dev/sdx status=progress oflag=sync
# Now disk is ready to be used as a bootable drive
@zamantousif
zamantousif / example.cpp
Created July 13, 2023 12:48
Eigen library usage
// When you want to initialize a matrix with const specifier inline use the finished() call
const double rot = 0.0; // angle in radians
const Eigen::Matrix3d RotateAboutZAxis =
(Eigen::Matrix3d(3, 3) << cos(rot), -sin(rot), 0, sin(rot), cos(rot), 0, 0, 0, 1).finished();
@zamantousif
zamantousif / gist:3eaed0a561eb399e0c14f5250d09d9b3
Created June 5, 2023 11:51
Manage gcc, g++ using update-alternatives on Linux
# Follow this advice on managing compiler versions using update-alternatives
# https://askubuntu.com/questions/26498/how-to-choose-the-default-gcc-and-g-version
# Below commands allow selecting the default compiler for gcc and g++ from the list of available ones
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
@zamantousif
zamantousif / install_clang_format.sh
Last active April 3, 2025 12:22
Install clang-format
# Reference:
# https://apt.llvm.org/
# For convenience there is an automatic installation script available that installs LLVM for you.
# To install the latest stable version:
bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
# To install a specific version of LLVM:
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh