Skip to content

Instantly share code, notes, and snippets.

View ugovaretto's full-sized avatar

Ugo Varetto ugovaretto

View GitHub Profile
@ugovaretto
ugovaretto / gist:6efa47cf6ff31827eab8e8987a094e34
Created April 18, 2025 05:46
Build python from source and install in home directory on Linux
./configure --prefix=~/.local -enable-optimizations --with-lto=full --prefix=$PWD/run --with-ensurepip --libdir=$PWD/run/lib
ln -sf ~/.local/lib64/python3.13/lib-dynload ~/.local/lib/python3.13/lib-dynload
# without the above line you'll get errors saying that the module _posixsubprocess cannot be found
@ugovaretto
ugovaretto / wakeonlan.sh
Last active April 4, 2025 12:08
Wakeon lan on Ubuntu 24.10
# sudo nmcli connection show # retrieve NIC name
# run as sudo
nmcli connection modify netplan-enp8s0 802-3-ethernet.wake-on-lan magic
nmcli connection modify netplan-enp8s0 802-3-ethernet.auto-negotiate yes
reboot
@ugovaretto
ugovaretto / .clangd
Created September 18, 2024 15:19
Clangd configuration for C++20
CompileFlags:
Add: [-std=c++20]
@ugovaretto
ugovaretto / chain.cpp
Created September 18, 2024 14:36
Funcitonal chaining in c++
// Copyright (c) 2024 - Ugo Varetto
// Function chaining.
#include <concepts>
#include <iostream>
#include <iterator>
#include <optional>
#include <tuple>
#include <type_traits>
#include <vector>
//----------------------------------------------------------------------------
@ugovaretto
ugovaretto / pyglet_ps4.py
Last active April 28, 2024 05:05
Map PlayStation 4 button to pyglet joystick buttons
# Map pyglet joystick buttons between ps4 and pyglet controller
def pyglet_raw_to_ps4_button_dict() -> dict[str, str]:
"""Convert raw button names to PS4 button names.
Returns:
dictionary mapping Pyglet raw button names to PS4 button names
The "0x9:" prefix is omitted.
In order to map the raw name to the PS4 name
@ugovaretto
ugovaretto / hibernate.sh
Last active January 9, 2024 08:32
Setup eth card for wake on lan and hibernate
#!/usr/bin/env bash
#run with 'sudo ./hibernate.sh'
#argument is the name of the eth network adapter e.g. 'eno1'
ethtool -s $1 wol pumbg
systemctl hibernate
@ugovaretto
ugovaretto / atuin.fish
Created January 8, 2024 10:01
Atuin configuration file
#Atuin configuration for fish is broken as of 2024-1-8 (using $"(...)" instead of (...))
#Add source <this file> to $HOME/.config/fish/config.fish
set -gx ATUIN_SESSION (atuin uuid)
function _atuin_preexec --on-event fish_preexec
if not test -n "$fish_private_mode"
set -g ATUIN_HISTORY_ID (atuin history start -- "$argv[1]")
end
end
@ugovaretto
ugovaretto / multidispatch.py
Last active December 2, 2023 15:13
Minimal Python multidispatch framework
# Minimal Multidispatch example.
# Type safe: if types not included in overload set exception is raised
# Author: Ugo Varetto
# License SPDX: UPL-1.0 (Permissive license)
import sys
def __create_overload_table(obj):
if getattr(obj, '__overload_table', None):
@ugovaretto
ugovaretto / weztermdeps.sh
Created June 1, 2023 08:53
Wez term dependencies on Linux
sudo apt install libx11-xcb-dev libxcb-util libxcb-util-dev libxcb-image0-dev libxcb1-dev libxkbcommon-dev libxkbcommon-x11-dev
@ugovaretto
ugovaretto / config.kdl
Created May 28, 2023 12:25
zellij configuration
// If you'd like to override the default keybindings completely, be sure to change "keybinds" to "keybinds clear-defaults=true"
keybinds {
normal {
// uncomment this and adjust key if using copy_on_select=false
// bind "Alt c" { Copy; }
}
locked {
bind "Ctrl g" { SwitchToMode "Normal"; }
}
resize {