My gists

Gists

Add M-{ binding to zsh

Adding this line in .zshrc will cause inserting a pair of {} and putting the cursor between the brackets when typing M-{

bindkey -s '^[{' '{}^B'

Enabling luajitlatex on texlive

Add an extra url to a given remote in git

Use this command to add another url to an existing remote in a git repository. Pushing to the remotee will update all repositories.

git remote set-url origin --add --push [email protected]:alfunx/foo

Source

React on docking-undocking on Lenovo

We want to run a script whenever the laptop is docked or undocked. The idea is to add a udev role to run a given script. The main nuisance is that each dock reports a different USB ID, so we need to add one for each of the models. On gentoo, udev rules need to be added to /etc/udev/rules.d/

We create a file named /etc/udev/rules.d/81-thinkpad-dock.rules and permissions 644 with the following content:

# Save this file (after modifying ID_VENDOR and ID_MODEL if necessary) as /etc/udev/rules.d/81-thinkpad-dock.rules

# Ultra dock 1
SUBSYSTEM=="usb", ACTION=="add|remove", ENV{PRODUCT}=="17ef/1010/5041", RUN+="/sbin/thinkpad-dock.sh"
# Ultra dock 2
SUBSYSTEM=="usb", ACTION=="add|remove", ENV{PRODUCT}=="17ef/1010/5031", RUN+="/sbin/thinkpad-dock.sh"
# Basic dock
SUBSYSTEM=="usb", ACTION=="add|remove", ENV{PRODUCT}=="17ef/1013/5031", RUN+="/sbin/thinkpad-dock.sh"
# Pro dock
SUBSYSTEM=="usb", ACTION=="add|remove", ENV{PRODUCT}=="17ef/1012/5040", RUN+="/sbin/thinkpad-dock.sh"

The correct PRODUCT string can be found by running

udevadm monitor --subsystem-match=usb --property --udev

Once the file is in place, udev rules can be reloaded with:

udevadm control --reload-rules

Adventures with bbswitch

The goal

For the time being, I want the nvidia GPU to be off at all times. I purchased a dGPU laptop only because the non-dGPU motherboards of the T460s seem to be affected by a design flaw and will eventually cause spurious reboots when a module of RAM is installed. Note that it is not guaranteed that the dGPU mobo are not presenting this flaw.

The issue

Apparently bbswitch worked a while ago. Now it is a bit unclear if it actually works or not. To sort things out, let me first update to the latest kernel. This appears to be

Linux bl4ckspoons 5.8.9-gentoo

On startup it seems to turn the card OFF, provided that /etc/modprobe.d/bbswitch.conf reads as follows

options bbswitch load_state=0 unload_state=-1

Notice that dmesg still complains about the following warning

ACPI Warning: \_SB.PCI0.RP09.PEGP._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20200528/nsarguments-59)

This appears to work, at least on the first suspend cycle. I should double check with powertop if the power consumption is actually low

Setup openvpn on the Rπ

Goal

The goal here is for the moment to open a vpn connection and only route torrent traffic through

Once this has been achieved, I would also like to open perhaps a socks proxy on the pi and be able to route stuff from my laptop directly through the vpn, perhaps using some privoxy rules

Issues

the script sets up the routing tables so that all traffic is routed through the vpn. It seems to me that this is an overkill, why would I want to run my updates on the VPN?

Setup gpg in Plasma

Goal

On startup, plasma sources the executable files in .config/plasma-workspace/env In this directory, there is the file 10-agent-startup.sh

Smooth in the sense of Whitney

Why?

Consider a set \(X⊂ℝ^n\); then a function \(f:X→ℝ\) is said to be $C^r$/-smooth in the sense of Whitney/ if there exist functions \(f_α:X→ℝ\), where α is a multi-index so that the appropriate Taylor expansion holds on \(X\)

Lagrange interpolation polynomials

What are LIPs

LIPs are used for polynomial interpolation. Given points $x_j∈ℝ$ that
are pairwise distinct for $j=0,\cdots k$, we can construct polynomials
$p_j(x)$ that have the following property:
$$
  p_{i}(x_{j}) = δ_{ij}
$$
In particular, given a function $f(x)$, we can construct a polynomial
that agrees with $f$ at any of the points $x_{j}$.  The problem is
that such interpolation might oscillate wildly

Creating a work identity on GitHub

Why is emacs not opening my attachments?

It so happens that I am unable to open attachments with mu4e; a terminal window (xterm?) briefly opens and then closes and nothing is shown. According to this question, it is because emacs kills the terminal (and the spawned process) too early. Notably, it seems that opening pdfs works from org.

So I investigate what is called by mu4e when opening attachments; checking with M-x view-lossage I find out that the function that is called when opening the attachment is gnus-article-press-button.

It appears that I have to modify a file called .mailcap in my home, containing the line

application/*; xdg-open %s

We then also need to call M-x mailcap-parse-mailcaps to force a re-read of the file. I got this information from the wiki

Updating the Raspberry Pi

I am debugging a boring network issue (which causes data to stutter and very slow and intermittent transfer speeds). It does seem to be a driver issue, so I am trying first of all to upgrade the kernel and stuff…

I prepared a backup of the sd-card in ~/mnt/cccmedia/sd-img.img with dd. Please note it is the whole sd-card, not any of the partitions.

Then we need to update the sources.list file

nano /etc/apt/sources.list

In my case this could be a little problematic since I had been using my own kernel, but more on this later…

Managing certificates with letsencrypt

I happen to have neglected my certificates and now they are rotting away. Some have expired, others are pointing to the wrong domain.

First of all, how to get rid of unwanted certificates? we just call

letsencrypt delete

the program will ask which certificate to delete.

We can check that everything is in order with

letsencrypt certificates

Then we set up the new certificate with

letsencrypt

which will parse the apache configuration and suggest what to do.

Wiring an Android TV to a Raspberry pi

First, we need to install a dhcp server on the pi.

TODO: the server fails to start on boot

Once it is up, the TV refuses to connect, since it can’t ping google.

So, we set up a fake captive portal on the Pi, as described in this post.

Nextcloud is down, now why?

Updating gpg keys

Once in a while we need to renew the gpg keys. Here is how:

gpg --list-keys

will show the available keys, then one needs to

gpg --edit-key xxxxxxxx

then at the gpg prompt we need to call expire and follow the prompts; choose subkeys with key n, where n is the number of the subkey to select. Rinse and repeat the expire treatment. Finally exit with save

If the keys are meant to be published, they should be pushed with

gpg --keyserver pgp.mit.edu --send-keys xxxxxxx

reference