Skip to content

Instantly share code, notes, and snippets.

@tomterragni
tomterragni / myssh
Created September 10, 2025 14:37
Script to automate ssh connection and allow tunnelling of remote port 3306 to a local port
#!/usr/bin/env bash
set -Eeuo pipefail
# ---------- Defaults ----------
CERT=""
USER=""
HOST=""
DO_TUN=false
DO_STOP=false
DO_STATUS=false
#!/bin/bash
# Sometimes the touchbar freezes (in particular, the Esc key stops working - annoying when using Vi) on my Macbook Pro and requires restarting.
sudo pkill TouchBarServer
sudo killall ControlStrip
sudo -k
echo 'The touchbar service will restart shortly...'
@tomterragni
tomterragni / .bashrc
Created August 10, 2022 10:49
workaround for Anaconda and VNC conflict
# copy these lines AFTER the conda initialisation in your .bashrc file
# FIX CONFLICT BETWEEN ANACONDA AND VNC
# https://forums.centos.org/viewtopic.php?t=66886
if [ ! -d /home/centos/.bin/ ]; then
# echo 'folder does not exists'
mkdi
@tomterragni
tomterragni / sudo
Created June 3, 2022 11:36
Mac Touch ID for sudo in terminal
# This is the PAM sudo config file: /etc/pam.d/sudo
# sudo: auth account password session
###############################################
# add the following line to enable Touch ID authentication in e.g. unix scripts which use sudo,
# as described in https://dev.to/equiman/how-to-use-macos-s-touch-id-on-terminal-5fhg
auth sufficient pam_tid.so
###############################################
auth sufficient pam_smartcard.so
@tomterragni
tomterragni / restartaudio
Last active June 3, 2022 11:31
Restart the coreaudio service
#!/bin/bash
# Sometimes the coreaudio service freezes on Macbook Pro and requires restarting.
pid=`ps ax | grep 'coreaudio[a-z]' | awk '{print $1}'`
sudo kill $pid
sudo -k
echo 'The coreaudio service will restart shortly...'
@tomterragni
tomterragni / detect.sh
Last active December 4, 2025 10:12
detect utility: finds a substring in all files within the current folder
#!/bin/bash
show_help() {
cat << EOF
Usage: $0 [OPTIONS] <extension> <pattern>
Search for files with a specific extension and find lines matching a pattern.
Arguments:
extension File extension to search for (without the dot)
@tomterragni
tomterragni / centos_locales-warning.md
Last active August 28, 2020 09:15
How to fix CentOS locales warning

If a CentOS system returns the message Centos warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory

try the following (possibly replacing the locale en_US with the appropriate one):

echo 'LANG=en_US.utf-8' | sudo tee -a /etc/environment > /dev/null
echo 'LC_ALL=en_US.utf-8' | sudo tee -a /etc/environment > /dev/null

. /etc/environment
@tomterragni
tomterragni / custom.css
Created December 16, 2019 09:01
CSS for Jupyter notebooks
/*
Put this CSS file in your ~/.jupyter/custom/ (if using Jupyter) or
~/.ipython/profile_default/static/custom/ (if using IPython) folder
in order to edit default appearance of Jupyter notebooks.
See: https://medium.com/@RayZen/change-the-notebook-cell-width-d7762d3a71e1
*/
// make content wider
.container { width:90% !important; }

Keybase proof

I hereby claim:

  • I am tomterragni on github.
  • I am tomterragni (https://keybase.io/tomterragni) on keybase.
  • I have a public key ASBhIMC_NwL9Od65Cr3x4PHZbUxoos96Y7-QWKm2Tf7B1go

To claim this, I am signing this object:

@tomterragni
tomterragni / .bash_profile
Last active March 28, 2021 09:15
bash settings
# Misc scripts
export PATH=/Users/tommasoterragni/Misc_IT_management/scripts:$PATH
# added by Anaconda3 5.1.0 installer
export PATH="/Applications/anaconda3/anaconda3/bin:$PATH"
export PATH=/usr/local/bin:$PATH
# alias vari aggiunti a mano
alias l='ls -alt'