Skip to content

Instantly share code, notes, and snippets.

@andmax
andmax / .gitconfig
Created November 27, 2023 13:55
Good ~/.gitconfig with helpful aliases
[user]
name = Andre Maximo
email = andmax@gmail.com
[credential]
helper = cache --timeout=3600
[core]
editor = emacs -nw
[filter "lfs"]
required = true
clean = git-lfs clean -- %f
@andmax
andmax / github_ssh_gpg.txt
Last active November 20, 2023 10:49
git github ssh gpg
- To properly use github, it is important to add SSH and GPG keys
- to respectively connect (allowing git push/pull/clone) to github and
- sign commits (allowing git commit -S) adding a "verified" tag to it
- Using SSH key to connect sometimes requires to go thru port 443 instead of
- port 22 when accessing github:
- Edit ssh config to use port 443 https when accessing github via ssh
- and also to use ssh key (must be the same added in github):
@andmax
andmax / bluetooth_restart.sh
Created June 7, 2023 11:57
Script to restart bluetooth
#!/usr/bin/bash
echo 'clearing dmesg...';
sudo dmesg -c && clear;
DEVICE=$(rfkill list all | grep -o 'hci*.');
sudo hciconfig ${DEVICE} down;
sudo rmmod btusb;
sudo service bluetooth disable;
sudo modprobe btusb;
@andmax
andmax / .bashrc
Last active April 25, 2024 15:40
Add runx func. + env.vars. in ~/.bashrc to improve it
# Good run x times function to have readily available in cmd line to
# just do: $ runx 10 cmd args <- run 10 times cmd with args
function runx() {
for ((n=0;n<$1;n++))
do ${*:2}
done
}
# The py_envs can help add a python path before running python or jupyter
# It is used as $ py_envs jupyter notebook
@andmax
andmax / good_unix_tools.txt
Last active April 27, 2023 17:19
Good unix tools
1. Image viewer: https://feh.finalrewind.org/
Python virtual environments (venv) are good to:
1. Use a specific version of Python;
2. Do pip install rightly (without sudo);
3. Be able to use other Python versions as jupyter notebook run kernel.
It is the recommended way of organizing packages versions in Python 3.3+.
To create/activate/deactivate a venv:
python3.8 -m venv ~/python3.8-venv
@andmax
andmax / clangd
Last active August 19, 2022 15:34
clangd to teach emacs c++
Install clangd to have IDE support in emacs:
https://clangd.llvm.org/
Add following snippet to ~/.emacs:
(require 'eglot)
(add-to-list 'eglot-server-programs '((c++-mode c-mode) "clangd"))
(add-hook 'c-mode-hook 'eglot-ensure)
(add-hook 'c++-mode-hook 'eglot-ensure)
Create file ~/.clangd with:
@andmax
andmax / install opencv
Last active April 20, 2023 12:08
Hints on installing OpenCV (4.5.5) on Ubuntu (20.04)
0. A better option than below guidelines is to install OpenCV in Python via:
pip install opencv-python
sudo apt update
sudo apt install libgl1
1. Remove opencv installed by apt (probably not the most recent version)
2. Clean-up and update apt (so dependencies can be installed)
3. Install dependencies
4. Set gcc/g++ to maximum allowed version (8 for cuda-10.2)
@andmax
andmax / ssh_agent_avoid_passphrase
Created October 25, 2021 18:19
Hint to use SSH agent to avoid entering passphrase to connect to a node using private key
.ssh/config:
Host *
(...)
AddKeysToAgent yes
(...)
eval `ssh-agent`
ssh-copy-id -i ~/.ssh/id_rsa.pub node:
ssh node
@andmax
andmax / install_fresh_docker_avoid_vpn_conflict
Last active October 25, 2021 18:13
Fresh install Docker + avoid VPN conflict
# Fresh install Docker + avoid VPN conflict
sudo rm -rf /etc/docker/*
sudo apt-get remove --purge *docker*
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
sudo apt update