Python
Tools list:
- project management: uv
- code format, sort imports, lint: ruff
- git hooks: pre-commit
To setup/use on Ubuntu the toolchain configured in pyproject.toml
- install
uv
mkdir -p $HOME/.local/bin
curl -LsSf https://astral.sh/uv/install.sh | sh
. $HOME/.profile
- sync the project:
cd $HOME/fishtest
uv sync
- install/uninstall the git hook to automate the code format, sort, lint:
cd $HOME/fishtest
uv run pre-commit install
# uninstall the git hook
uv run pre-commit uninstall
# skip temporarily the hook during a commit
git commit --no-verify -a -m "bad syntax commit"
- (optional) if you want to format, sort imports, lint, by hand:
uv run ruff format
uv run ruff check --select I --fix
uv run ruff check
- (optional) if
ruff
starts formatting in a wrong way, clean the cache:
uv run ruff clean
Python version
- pyenv simple Python version management for Linux/WSL
- fishtest server: Python 3.13
- fishtest worker: Python 3.6
CSS, HTML, Javascript
Google HTML/CSS Style GuideGoogle JavaScript Style Guide
Tools list:
- Node Version Manager
- auto-formatter: Prettier
- W3C markup validator
Command line:
npx prettier --write 'server/fishtest/static/{css/*.css,html/*.html,js/*.js}'
Shell
Generate a sri.txt
to open a PR for the fishtest worker code
The fishtest worker writes in the sri.txt
file the hash of the worker files, the GitHub fishtest Continuous Integration stops if the hash is invalid. To generate a new sri.txt
before opening a PR for the fishtest worker code, simply run:
python3 worker.py a a --only_config --no_validation
Install several GCC versions on Ubuntu
Launch the following script to have several versions of GCC on Ubuntu alongside the default one, manage the different GCC versions using update-alternatives
. This works also for Windows Subsystem for Linux.
Click to view
#!/bin/bash
# add gcc 13 and gcc 14 to Ubuntu 24.04
# launch this script using "sudo"
# check for non official gcc versions on:
# https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test?field.series_filter=
# install the default building tools
apt update
apt install -y build-essential software-properties-common
# install other GCC versions
apt install -y gcc-14 g++-14
# configure the alternatives for gcc and g++, setting a higher priority to a newer version (ymmv)
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 50 --slave /usr/bin/g++ g++ /usr/bin/g++-13
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 60 --slave /usr/bin/g++ g++ /usr/bin/g++-14
# check or change the alternatives configuration
update-alternatives --config gcc
Install several Clang versions on Ubuntu
Launch the following script to have several versions of Clang on Ubuntu alongside the default one: install some Clang versions using the LLVM Ubuntu/Debian packages and manage the different Clang versions using update-alternatives
. This works also for Windows Subsystem for Linux.
Click to view
#!/bin/bash
# add Clang 18 and Clang 19 to a clean Ubuntu
wget https://apt.llvm.org/llvm.sh
sudo apt update
sudo bash llvm.sh 18
sudo bash llvm.sh 19
# configure the alternatives for clang and llvm-profdata, setting a higher priority to a newer version (ymmv)
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-19 60 --slave /usr/bin/clang++ clang++ /usr/bin/clang++-19 --slave /usr/bin/llvm-profdata llvm-profdata /usr/bin/llvm-profdata-19
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-18 40 --slave /usr/bin/clang++ clang++ /usr/bin/clang++-18 --slave /usr/bin/llvm-profdata llvm-profdata /usr/bin/llvm-profdata-18
# check or change the alternatives configuration
sudo update-alternatives --config clang
# to uninstall a Clang version
# LLVM_VERSION=18
# sudo apt purge -y clang-$LLVM_VERSION lldb-$LLVM_VERSION lld-$LLVM_VERSION clangd-$LLVM_VERSION && sudo apt autoremove -y
Install a pull request
The script below fetches and checks out a pull request. Assuming the script is named pull.sh
and is in the current directory, it is used as
./pull.sh PULL_ID
Click to view
#!/bin/sh
BRANCH_NAME=PR$1
git switch master
git branch -D $BRANCH_NAME
git fetch -p origin pull/$1/head:$BRANCH_NAME
git switch $BRANCH_NAME