Skip to content

Instantly share code, notes, and snippets.

@Juul
Juul / python_asyncio_subprocess_pipe.md
Created October 28, 2024 08:48
python asyncio pipe stdin from one subprocess to another

Put this in cmd1.sh

#!/bin/bash

while true; do
    echo "hello"
    echo "you"
    sleep 1
done
@Juul
Juul / building_casparcg-client.md
Created July 24, 2024 01:23
Building casparcg client 2.3.0 on Ubuntu 22.04

Download and extract casparcg client-2.3.0 tar.gz release file

Fetch missing oscpack. If using code from git repo then you can fetch via git submodules.

cd client-2.3.0/
cd lib/
rm -rf oscpack
sudo apt install git
git clone https://github.com/MariadeAnton/oscpack
@Juul
Juul / openwrt_stubby_quad9.md
Last active July 25, 2024 23:28
DNS over TLS on OpenWRT / Debian using stubby and Quad9 9.9.9.9

This configures dnsmasq to forward queries to a locally running stubby which makes the DNS over TLS requests.

OpenWRT

opkg update
opkg install stubby

Edit /etc/config/dhcp adding the following to the dnsmasq section:

@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):