Skip to content

Instantly share code, notes, and snippets.

@Juul
Juul / luks2_to_luks1.md
Last active March 15, 2024 09:47
Converting LUKS2 to LUKS1

If you want to use GRUB to unlock your encrypted drive on boot then you likely want to use LUKS1 instead of LUKS2. If you already have a LUKS2 partition, most guides around the web will tell you that you simply have to convert your keys to PBKDF2 before you can convert a LUKS2 partition to LUKS1, however, as seen in this bug report, that's not quite the whole truth.

Run luksDump:

cryptsetup luksDump /dev/<your_device>

You will get output like this:

@Juul
Juul / how_to_autorandr.md
Last active July 20, 2023 02:09
How to automatically change screen setup when docking/undocking

The tool autorandr can save configurations for various monitor setups and load them based on what's plugged in, or be used to manually load a saved configuration.

Use the latest version of autorandr. The version in Ubuntu 20.04 didn't work for me. To install:

sudo pip3 install "git+http://github.com/phillipberndt/autorandr#egg=autorandr"

Then for each monitor configuration, plug monitors in as needed and configure them correctly manually, then run:

@Juul
Juul / wikipedia_disable_sticky_header.md
Created March 3, 2023 04:11
How to disable the sticky header when scrolling on new wikipedia layout (Vector 2022)

When logged in and scrolling down past a certain point, a sticky header annoyingly appears and takes up vertical screen real estate. Since all of those UI elements are available by scrolling up this seems like more of an annoyance than anything, especially for people using large font sizes on wide aspect ratio screens.

To disable, go to Preferences -> Appearance and click Custom CSS next to Vector (2022). Then save the following to the new page:

.client-js.vector-sticky-header-enabled .vector-sticky-header {
  display: none !important;
}
@Juul
Juul / chrome_disable_cors.md
Last active February 6, 2023 08:38
How to disable CORS on modern Chrome / Chromium

There are lots of wrong/incomplete instructions on how to completely disable CORS checks for Chrome/Chromium.

Here's what works for me as of February 2023:

mkdir -p /tmp/foo
chromium-browser --disable-web-security -disable-site-isolation-trials user-data-a-dir="/tmp/foo"

This should only be used by developers who know what they are doing. Logging into anything with a browser running with security disabled is a recipe for getting your credentials stolen or worse.

@Juul
Juul / taiyilian_blacklist.md
Last active January 10, 2023 12:34
How to blacklist / disable / ignore the keyboard devices created by USB bluetooth audio only adapters

I bought one of these weird USB bluetooth audio adapters that only acts as a bluetooth audio transmitter, meaning that it doesn't show up as a bluetooth device at all but rather as a USB audio device.

The specific device I got is branded as 1Mii, shows up in X logs with the name TaiYiLian and in lsusb as "Cambridge Silicon Radio, Ltd".

I can't really recommend it. There is no way to select which device to pair with (I believe it picks the device currently in pairing mode with the highest signal strength) and there is a delay every time audio is played before it kicks in (at least on my system).

Another problem is that it shows up as not just a USB audio device, but also two keyboards and these keyboards send keystrokes which causes X to loose focus with no way of regaining it by clicking. The only way I found to get normal keyboard functionality back is to ctrl+alt+F2 into a terminal and then switch back to X. Unfortunately this seems to happen repeatedly, so just having it plugged in before boot doesn't h

@Juul
Juul / saa-2n_compile.md
Created June 15, 2022 06:50
Compile firmware for NanoVNA V2 Plus clone SAA-2N

The SAA-2N is a knockoff/clone of the NanoVNA V2 Plus and you should NOT buy one.

Order an official one from https://nanorfe.com/nanovna-v2.html

However, if one for some reason falls into your hands, it might be unobvious how to find a firmware that compiles for it. I'm not sure if there are mutliple sub-versions of the SAA-2N but this one has a 4" screen.

sudo apt install gcc-arm-none-eabi  python3-serial
git clone -recursive https://github.com/nanovna-v2/NanoVNA2-firmware
@Juul
Juul / hard_drive_ssd_smart_test.md
Last active June 12, 2022 09:17
How to use S.M.A.R.T. to test and wipe harddrives and SSDs

With smartctl you can talk to the hd/ssd's built-in firmware, get detailed status info and ask it to execute tests.

First:

sudo apt install smartmontools

To do a quick health test (which can report OK even if the drive is having issues):

@Juul
Juul / openwrt_digitalocean_ddns.md
Last active March 21, 2022 08:48
How to use ddns on OpenWRT using Digital Ocean's API and skibish's daemon

Digital Ocean has an API that, among other things, allows DNS changes.

A github user called skibish maintains a small daemon written in go that implements DDNS using this API.

This guide shows you how to make this work on OpenWRT.

DNS records

Let's say you want the subdomain home.example.org to point to your home router. You can either use Digital Ocean's DNS servers for the entire example.org domain or you can add the following records to your existing DNS server to let Digital Ocean only handle the subdomain:

@Juul
Juul / wds_bridge_notes.md
Last active December 6, 2023 13:00
4-address mode aka WDS for OpenWRT

To turn a router into a bridge between wifi and ethernet, with the router being a wifi client/station, you need 4-address mode aka Wireless Distributions System or WDS.

This does not necessarily work between vendors so make sure your AP and client use chips from the same manufacturer.

It seems that enabling WDS on an AP's wifi interface does not prevent non-WDS clients from connecting normally, at least in my limited experience.

On the AP you simply add option wds '1' to the relevant wifi-iface section. E.g:

config wifi-iface 'default_radio0'
@Juul
Juul / anamorphic_desqueeze_photos.sh
Created October 16, 2021 08:45
Anamorphic desqueeze photos
#!/bin/bash
# It appears my anamorphic lens is closer to 140% than the 133% is says on the label
# TODO Have an argument to force orientation since the identify command seems to not always work
echo "Creating directory: desqueezed/"
mkdir -p desqueezed
for f in `find -maxdepth 1 -iname "*.jpg" -o -iname "*.jpeg"`; do