pre-commit
Introduction
pre-commit is better githooks that are generic across projects, used to check yaml, markdown, run linters, and make sure the code is in good shape before making a commit and pushing it, or just running it in CI.
Configurations
File goes in root: .pre-commit.config.yaml
Base file
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-added-large-files
Rust file
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: forbid-new-submodules
- id: check-added-large-files
args: ["--maxkb=2000"]
- repo: https://github.com/doublify/pre-commit-rust
rev: v1.0
hooks:
- id: fmt
- id: clippy
args: ["--", "-D", "clippy::pedantic"]
- repo: https://github.com/hadolint/hadolint
rev: v2.10.0
hooks:
- id: hadolint
One liners
# Initialize a repo
pre-commit sample-config | tee .pre-commit-config.yaml && pre-commit autoupdate
References
Docker
Docker is an open platform for developing, shipping, and running applications.
Update all containers and restart any updated ones
docker compose pull
docker compose up -d
Remove all volumes that are dangling (DANGEROUS)
docker volume rm $(docker volume ls -qf dangling=true)
Useful Docker tools
- diun
General Use Tools Oneliners
Password Generation
Generate a password of 64 characters with symbols
pwgen -sy 64 1
Generate a password or passhrase with 64 characters
pwgen -s 64 1
GPG
List all existing keys
gpg --list-secret-keys --keyid-format=long
Generate a new key
gpg --full-generate-key
Export public key
gpg --armor --export <KEY ID>
Export private key
gpg --export-secret-key --armor <KEY ID>
Import
gpg --import private.key
emerge
emerge is a command line interface to Portage, the Gentoo Package manager. emerge is used to install, update and maintain packages on Gentoo.
Update system
sudo eix-sync
sudo emerge -avuDN @world
sudo emerge --depclean
Update kernel
This is a script to automatically update the kernel to a selected versio. The set can be automated with awk, but I have not found the need to do so.
eselect kernel list
sudo eselect kernel set <kernel_version>
cd /usr/src/linux
sudo make oldconfig
sudo make -j${nproc}
sudo make modules_install
sudo make install
sudo eclean-kernel -n3
sudo emerge @module-rebuild