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']"

Thursday, February 23, 2017

Running LXDE inside Xephyr in Arch Linux

Install Xephyr:
sudo pacman -S xorg-server-xephyr
Install LXDE:
sudo pacman -S lxsession-gtk3 lxpanel-gtk3 pacmanfm-gtk3 openbox lxtask-gtk3 lxde-icon-theme lxterminal-gtk3 lxrandr-gtk3
Then run Xephyr:
Xephyr -ac -noreset -query localhost -screen 1920x1080 -keybd ephyr,,,xkbmodel=evdev :3
And in another terminal:
DISPLAY=:3 startlxde

Friday, September 30, 2016

D-Bus user session

I noticed that I cannot open the user dbus in Ubuntu while I could do that in Arch Linux. It seems there is no user dbus by default in Ubuntu (or Ubuntu server at least). To have one:

$ sudo apt install dbus-user-session

Then `sudo systemctl start --user dbus` or reboot.

Monday, September 12, 2016

Mysterious crashes in DPDK application when using the pcap driver.

I was experiencing mysterious crashes in my DPDK application when using pcap virtual devices (using the --vdev option). What's more, when there was more crashes, I didn't seem to be getting all the packets I should have. So I investigated, and found out I was attempting to capture packets from multiple threads. That seems to be a no no with the pcap driver, considering it explicitly does not support multiple queues. I limited the number of cores available to my application using the -c option, and everything was solved.

Fixing "no driver found for eth_pcap0"

I was getting a "no driver found for eth_pcap0" error message whenever I wanted to use an "eth_pcap" virtual device with my DPDK application. But the DPDK sample app "test-pmd" worked just fine with those. So I took a look at its Makefile and found out adding this line to my Makefile fixes the issue:

DEPDIRS-y += lib drivers


Monday, May 30, 2016

ISO seems to be empty in Linux

So I had this ISO that I knew wasn't corrupted because I've seen it mounted and used on a Windows machine. In Linux though, mount gave me a "wrong fs type" error and both Archive Mounter and Archive Manager said the ISO is empty.

A quick search brought me to this Ubuntu Forums thread that gave me the answer. The ISO was in the UDF format. This is how I managed to mount it: sudo mount -t udf -o loop ~/path/to.iso mountdir

Friday, May 27, 2016

Enabling temperature sensors in Ubuntu

After installing lm-sesnors, you can see the current value of system sensors by running "sensors". If you suspect your system has more sensors than "sensors" is showing you, run "sensors-detect" and have it scan for more sensors. Then when it asks you if you want appropriate modules added to your /etc/modules file, say yes. Restart your computer and check "sensors" again.

Tuesday, April 19, 2016

Emacs configure script not finding gnutls even though you have it.

You probably don't have pkg-config installed. At least that was the case for me in my new Arch install. I just did a `sudo pacman -S pkg-config`, then configured emacs again.

Monday, April 18, 2016

modprobe: FATAL: Module uio not found.

What the hell is going on? Where is this u-i-o module DPDK needs? It's simple. Your probably using a cloud image; a vagrant VM or an EC2 instance most probably. You don't have everything you need pre-installed. Simply run "sudo apt-get install linux-generic linux-headers-generic" and you'll be fine. Go wild!

Saturday, March 12, 2016

Fixing problematic keys in st (suckless terminal)

Some keys were not working in Suckless Terminal (st). In particular Backspace and END keys were not working. Performing the following two steps fixes the problem (courtesy of the st page in the ArchWiki):


  1. Put this line in ~/.inputrc or /etc/inputrc:
    set enable-keypad on
  2. Run this in your terminal (you can put it in ~/.bashrc):
    stty erase '^H'

Monday, March 7, 2016

Container fstab not working in LXC

It seems that from some version of LXC, the deafults have changed such that container fstab simply has stopped working for me. This is how I fixed the problem: add the following line to your container config file:
lxc.mount = /var/lib/lxc/container-name/fstab
Fix the container name in that, and you're ready to go.

Sunday, February 14, 2016

How to enable graph style meters in htop 2.0?

The graph style meters added in htop 2.0 are really cool. You can see a sample in the htop homepage (at the moment anyway). In order to have one of those, go to setup (R2), then meters. Choose one of the meters (or add a new one) select it and hit space to change its style until it's on "graph".

Wednesday, November 11, 2015

Fixing VLC stutter on Android

VLC is a great player on the desktop, but my experience with it on Android has not been the best. Everytime I play start playing a track there's a delay and then a stutter. I can never hear the first couple of seconds properly. Worse this behavior continued for the entirety of an m4b audiobook I just tried to play.

Then I thought, why haven't I tried tweaking with the settings and see what happens. Sure enough, a few minutes later, I found a solution. Go to Preferences, then Advanced. Change Audio output from "OpenSL ES" to "Audio Track (Java)". Done! Everything is fine now.

Saturday, November 7, 2015

Fixing MTP mounting error in Ubuntu

I used to be able to mount my Galaxy S4 over USB but for some weird reason I started getting an error message a few days ago. Today I finally managed to fix the problem. First run lsusb to get the bus and device ID:

$ lsusb | grep -i samsung
Bus 002 Device 104: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II], GT-I9300 Phone [Galaxy S III], GT-P7500 [Galaxy Tab 10.1]

Now we know that the device is on bus 002 and its device ID is 104. Let's take a look at it:

$ ls -l /dev/bus/usb/002/104
crw-rw---- 1 mostafa audio 189, 231 Nov  7 17:23 /dev/bus/usb/002/104

For some reason, the device belongs to the audio group and I'm not part of that group. So I simply run:

$ sudo addgroup mostafa audio

Then I logout and login and the problem is fixed. As a temporary workaround, if you don't want to logout right now, you can run:

$ sudo chmod 666 /dev/bus/usb/002/104