Rebase git branch on a different branch

git rebase --onto new_base old_base
| 20 Dec 2021

Log Varnish hash data

When starting Varnish, add -p vsl_mask=+Hash argument to the command. Print varnish logs with this command:

sudo varnishlog -n /opt/varnish -q 'ReqURL ~ "my_request"'
| 17 Dec 2021

lxd: delete all images

Delete all images which contain build-cache in their name:

lxc image list -c l --format csv | grep build-cache | xargs -I % lxc image delete %
| 2 Dec 2021

Improve Bluetooth headset audio quality

In order to enable mic on a bluetooth headphones, you need to change device configuration to Headset Head Unit in Settings > Sound menu. However, if you do so, the audio quality of the headphones will be quite bad.

Pipewire introduced support for the mSBC codec. This codec allows your headphones to enable microphone and still have okay-ish audio quality.

mSBC codec is disabled by default. To enable it, create ~/.config/pipewire/media-session.d/bluez-monitor.conf file with the following content:

properties = {
    bluez5.msbc-support = true
}

Restart Pipewire:

systemctl --user restart pipewire.service

HSP/HFP, codec mSBC option should be available in Settings > Sound menu

| 30 Nov 2021

Merge repositories and keep history

There is a special command git-subtree to merge / split repositories. It is not installed as a part of git package:

sudo dnf install git-subtree

The command to merge repository jsnjack/X to subfolder myfolder/new at branch master:

git subtree add -P myfolder/new [email protected]:jsnjack/X.git master
| 25 Nov 2021

Remote debugging with headless Chrome

Add the following arguments to chrome options:

options = webdriver.ChromeOptions()
options.add_argument("headless")
options.add_argument("remote-debugging-address=0.0.0.0")
options.add_argument("remote-debugging-port=9222")
wd = webdriver.Chrome(chrome_options=options)
  • start Chrome and navigate to chrome://inspect page
  • make sure Discover network targets is checked
  • click Configure button next to the previous option
  • add a new target, for example (must be an IP address): 10.214.36.58:9222
  • the remote browser should be automatically discovered and appear in Remote target list
  • click Inspect
| 23 Nov 2021

Setup lxd server as remote server

lxc config set core.https_address "[::]"
lxc config set core.trust_password new_password

After all clients are connected to the remote it is recommended to unset password:

lxc config unset core.trust_password
| 3 Sep 2021

Kernel panic after update

Traceback example: After update, kernel panic at boot with error: Unable to mount root fs on unknown-block(0,0)

Solution:
  1. Restart your server and on the boot screen select any other boot option with older kernel
  2. (optional, Leaseweb servers) Install missing dependency
sudo dnf install dracut-network
  1. Navigate to /boot and verify that initramfs-file doesn’t exist for the latest kernel version
  2. Generate it
# 4.18.0-338.el8.x86_64 is kernel version
dracut -f /boot/initramfs-4.18.0-338.el8.x86_64.img 4.18.0-338.el8.x86_64
  1. Regenerate grub files
grub2-mkconfig -o /boot/grub2/grub.cfg
  1. Restart
Sources:
| 1 Sep 2021

List all files installed by a package

List all files installed by a specific package:

sudo dnf repoquery -l golang-bin
| 13 Jul 2021

Show top 10 process with open files

lsof | awk '{print $1}' | sort | uniq -c | sort -r -n | head
| 13 Jul 2021