Skip to content

Instantly share code, notes, and snippets.

View federicotorrielli's full-sized avatar
☣️
I write awful commit names

Federico Torrielli federicotorrielli

☣️
I write awful commit names
View GitHub Profile
@federicotorrielli
federicotorrielli / starship.toml
Created August 20, 2024 09:53
My starship prompt and configuration file
# ~/.config/starship.toml
[battery]
full_symbol = "🔋"
charging_symbol = "🔌"
discharging_symbol = "⚡"
[[battery.display]]
threshold = 30
style = "bold red"
@federicotorrielli
federicotorrielli / update_betterfox.sh
Created August 2, 2024 11:21
This script will compare the version of user.js from the Betterfox repository with the local version, download and install if there's a new version, and notify the user.
#!/bin/bash
# Set variables
REMOTE_URL="https://raw.githubusercontent.com/yokoffing/Betterfox/main/user.js"
LOCAL_DIR="$HOME/.mozilla/firefox"
PROFILE_DIR=$(ls -d "$LOCAL_DIR"/*.default-release | head -n 1)
LOCAL_FILE="$PROFILE_DIR/user.js"
TMP_FILE="/tmp/user.js.tmp"
# Function to send desktop notification
#!/usr/bin/env python3
import re
import subprocess
import requests
from bs4 import BeautifulSoup
from rich.console import Console
from rich.table import Table
from rich.prompt import Confirm
from getpass import getpass
@federicotorrielli
federicotorrielli / check_python_readiness.py
Created July 15, 2024 08:48
This program reads a list of package requirements from a file and checks each package's compatibility with a specified Python version. It fetches package information from PyPI, validates version constraints, and ensures compatibility with the given Python version, providing detailed results for each package.
import sys
import re
import requests
from packaging import version, specifiers
def parse_requirement(requirement):
# Ignore git repository requirements
if requirement.startswith('git+'):
return None, None
@federicotorrielli
federicotorrielli / files2clipboard.sh
Last active July 2, 2024 08:16
Copy multiple code files to clipboard
#!/bin/bash
# Exit immediately if a command exits with a non-zero status
set -e
# Function to display an error message and exit
error_exit() {
echo "Error: $1" >&2
exit 1
}
@federicotorrielli
federicotorrielli / install_fonts_from_folder.sh
Created May 30, 2024 13:59
Installing fonts from a folder in Linux :)
#!/bin/bash
# Script to install fonts from a specified folder on a Linux system
# Function to display usage instructions
usage() {
echo "Usage: $0 FONT_FOLDER"
echo "Install all fonts from the specified folder to the system."
echo "Example: $0 /path/to/font/folder"
exit 1
@federicotorrielli
federicotorrielli / llm_server_setup.sh
Last active December 4, 2024 10:32
LLM Server Setup - Machine Learning Ubuntu 20.04 server setup
#!/bin/bash
# Exit immediately if a command exits with a non-zero status.
set -e
# Function to print messages with date and time
log() {
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')] $@"
}
@federicotorrielli
federicotorrielli / battery_health.sh
Created December 8, 2023 12:17
Check the battery health of a linux device
#!/bin/bash
# Get the full energy capacity of the battery as designed and the current full energy capacity
# Replace commas with dots to ensure proper arithmetic operations
energy_full_design=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep energy-full-design: | awk '{gsub(",","."); print $2}')
energy_full=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep energy-full: | awk '{gsub(",","."); print $2}')
# Calculate battery health as a percentage using awk
battery_health=$(awk -v e_full="$energy_full" -v e_design="$energy_full_design" 'BEGIN {printf "%.2f", (e_full/e_design)*100}')
@federicotorrielli
federicotorrielli / copy.sh
Created June 7, 2023 12:57
This shell script copies the content of a file to the clipboard using xclip
#!/bin/bash
# Function for displaying help
function display_help() {
echo "Usage: $0 [file/directory]... [options]"
echo
echo "Copy the content of [file] or all files in [directory] to clipboard"
echo
echo "Options:"
echo " --help Show this help message"
@federicotorrielli
federicotorrielli / lrzip_install.sh
Last active June 7, 2023 08:19
This simple script helps install lrzip on almost any linux distribution
#!/bin/bash
# Check if the script is run as root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
# Detect the Linux distribution
if grep -qiE 'debian|ubuntu' /etc/os-release; then