Wednesday, March 8, 2023

Fix spell-fu-word-add or +spell/add-word in (doom) emacs

 If words cannot be added to the dictionary, you should create the directory:

.emacs.d/.local/etc/ispell/

Then create a file named .pws there and put the following line in it:

personal_ws-1.1 en 0

Restart emacs and you should be good to go.


Saturday, February 25, 2023

Another way of swapping alt and ctrl (using xkb)

EDIT: This might not be necessary. Refer to the original post and see updates.

I noitced that the method I described in a previous post does not work on Arch Linux. I came up with this quick (and probably dirty approach) to get the same effect.

First run this command:

xkbcomp $DISPLAY original.xkb

This will dump the current xkb config to a file named original.xkb. Make a copy of this file:

cp original.xkb swapped-alt-ctl.xkb

Edit the newly created swapped-alt-ctl.xkb file. Find the codes for LALT/LCTL and RALT/RCTL and swap them. For example, in my own file I found these for left alt/ctrl:

<LCTL> = 37;
<LALT> = 64;

I changed that to:

<LCTL> = 64;
<LALT> = 37;

Similarly for the right side I changed this:

<RCTL> = 105;
<RALT> = 108;

to:

<RCTL> = 108;
<RALT> = 105;

Then in order to reload the new config, run:

xkbcomp swapped-alt-ctl.xkb $DISPLAY

Put this in an appropriate place, like in your ~/.xinitrc file before the window manager is executed.

There might be a better way of doing this with xkb, but this works for me for now!

Issues with loading swank in stumpwm

 I had this issue that swank would not load when run in .stumpwmrc; SBCL would complain that it can't require "sb-cltl2", even though the package was available when I tried it in an SBCL repl. This comment on github finally made me realize what was happening.

I had to edit my /usr/share/xsessions/stumpwm.desktop file and change the "Exec=" line to this:

Exec=env SBCL_HOME=/usr/lib/sbcl stumpwm

After that, swank would load successfully.

Friday, December 9, 2022

Installing Artifactory on Kubernetes using Helm

Run this (with appropriate modifications):

export MASTER_KEY=$(openssl rand -hex 32)

export JOIN_KEY=$(openssl rand -hex 32)

export VARIANT=-cpp-ce

helm upgrade --install artifactory${VARIANT} --set artifactory.masterKey=${MASTER_KEY} --set artifactory.joinKey=${JOIN_KEY} --namespace artifactory jfrog/artifactory${VARIANT} --create-namespace --set postgresql.persistence.size=500Gi

VARIANT can be empty for the pro version, or "-oss" or "-cpp-ce" for open source versions.

Remember to keep MASTER/JOIN key so you'd need to use them again if wanting to upgrade. Maybe store them in a kubernetes secret like this:

kubectl create secret generic my-masterkey-secret -n artifactory --from-literal=master-key=${MASTER_KEY}

kubectl create secret generic my-joinkey-secret -n artifactory --from-literal=join-key=${JOIN_KEY}

Thursday, October 27, 2022

Quick note on Cloudflare tunnel credentials

 When running a command like this:

    cloudflared tunnel run --token <base64-encoded-token>

the base64-encoded token is a json file with a, t, and s fields. This json file however cannot be used as a credentials file. If you decode it, put it in a file, and then put a line saying "credentials-file: /path/to/cred.json" and run `cloudflared tunnel run`, you'll get errors lie:

2022-10-23T22:26:56Z ERR Failed to serve quic connection error="Unauthorized: Failed to get tunnel" connIndex=0 ip=198.41.200.33

2022-10-23T22:26:56Z ERR Register tunnel error from server side error="Unauthorized: Failed to get tunnel" connIndex=0 ip=198.41.200.33

The cred.json file needs the same three values as the base64-token, but they should be named AccountTag, TunnelID, and TunnelSecret.

Tuesday, November 3, 2020

Converting Main/High 10 profile to Main/High with ffmpeg and nvenc

 Use this:

ffmpeg -hwaccel nvdec -i input.mkv -c:a copy -c:v h264_nvenc -cq:v 21 -profile:v main -pix_fmt yuv420p output.mkv

Also, adding "-loglevel verbose" option to ffmpeg helped me figuring out the problem for me, because I was trying to encode the video and nvenc kept giving me some error along the lines of "no nvenc supported device" which clearly wasn't true. With the logging option, I realized since input was in "high 10" profile, it was trying to produce a 10 bit output too, which my device did not support. 

Sunday, August 30, 2020

Switching CTRL and ALT keys in Ubuntu 20.04

UPDATE 1: In a more recent distro, items 1-3 might not be needed, since they might already exist in the default xkb config files. Search the files for what we're about to add, and do not add the suggested items if they already exist.

UPDATE 2: If you don't use gnome, like I do on my x-only-no-desktop-environment arch linux setup, item 4 has no effect. Instead you can run "setxkbmap -option ctrl:swap_lalt_lctl -option ctrl:swap_ralt_rctl" (e.g. by putting that in your ~/.xinitrc file).

 Adapted from this: https://askubuntu.com/questions/885045/how-to-swap-ctrl-and-alt-keys-in-ubuntu-16-04

1. Edit /usr/share/X11/xkb/symbols/ctrl and add this snippet at the end:

// Swap the functions of the right Alt key and the right Ctrl key.
partial modifier_keys
xkb_symbols "swap_ralt_rctl" {
    replace key <RALT> { [ Control_R, Control_R ] };
    replace key <RCTL> { [ Alt_R, Meta_R ] };
};

NOTE: The reason we only deal with swapping right alt and right ctrl in this step (and the next ones) is that the functionality for switching left alt and left ctrl is already in place and only needs to be enabled in step 4.

2. Edit /usr/share/X11/xkb/rules/evdev.lst and add the following line to the "! option" section:

ctrl:swap_ralt_rctl Swap Right Alt key with Right Ctrl key

3. Edit /usr/share/X11/xkb/rules/evdev and add the following line to the "! option = symbols" section:

ctrl:swap_ralt_rctl   =   +ctrl(swap_ralt_rctl)

4. Run this:

dconf write "/org/gnome/desktop/input-sources/xkb-options" "['ctrl:swap_lalt_lctl','ctrl:swap_ralt_rctl']"