Skip to content

Instantly share code, notes, and snippets.

@metaquanta
metaquanta / Pi ⟷ Mini UART connection.md
Last active August 19, 2023 18:28
MP Select Mini USART Interface

MP Select Mini

The serial cable (that ordinarily connects to the LCD controller) has four wires: Red, White, Green, Black.

  • Red ➙ Ground
  • White ➙ TX USART1 - pin 42
  • Green ➙ RX USART1 - pin 43
  • Black ➙ +3.3V (yup, they're backwards)

†: on the STM32 processor

@metaquanta
metaquanta / authorize_crd.sh
Last active February 16, 2023 04:30
Setup Chromoting/CRD/Chrome Remote Desktop from the command line.
#!/bin/sh
# This assumes the package is installed.
# wget https://dl.google.com/linux/direct/chrome-remote-desktop_current_amd64.deb
# sudo apt install ./chrome-remote-desktop_current_amd64.deb
# # And maybe
# wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
# sudo apt install ./google-chrome-stable_current_amd64.deb
# # Fix the likely missing dependencies.
# sudo apt --fix-broken install
@metaquanta
metaquanta / gist_dark_mode.js
Created January 17, 2021 20:20
Fix GitHub Gist's dark mode
// ==UserScript==
// @name dark mode - gist.github.com
// @namespace Violentmonkey Scripts
// @match https://gist.github.com/*
// @grant none
// @version 1.0
// @author m@metaquanta.com
// @description 1/15/2021: Gist deserves the same dark mode as GitHub.
// ==/UserScript==
document.firstElementChild.setAttribute("data-color-mode", "dark");
@metaquanta
metaquanta / audit_command.sh
Created December 13, 2020 11:29
How to SyscallFilter a systemd unit
#!/bin/bash
# $1 is the command to audit (it will be run)
echo "my pid: $$"
# Log all chidren of this shell
auditctl -a always,exit -S all -F ppid=$$
$1
#!/bin/env -S deno -q run
import yargs from 'https://deno.land/x/yargs/deno.ts'
function readStdin(): AsyncIterable<string> {
return {
[Symbol.asyncIterator]: async function* () {
const buffer = new Uint8Array(1024);
const decoder = new TextDecoder();
@metaquanta
metaquanta / git-buildpackage.md
Last active November 26, 2020 08:24
Playing Debian maintainer
@metaquanta
metaquanta / bash_aliases
Last active November 25, 2020 07:52
Shell foo
# for each line of cmd1, pass it to cmd2.
# cmd1 | each cmd2 %
alias each="xargs -I% -d '\\n'"
# print the sizes of dirs(!) and files in cwd.
alias lsz="du -d 1 -h"
# this'll format /proc/xxx/cmdline as expected.
alias strs='strings -s \ -1'
# like `open` on a mac
alias open=xdg-open
@metaquanta
metaquanta / README.md
Last active November 20, 2020 23:31
Install Tails to local disk

In this example I'm installing Tails to the internal storage of an ASUS Chromebook C302 with mrchromebox's EFI firmware. The steps should be the same for any Tails-supported EFI computer. My internal disk is mmcblk0 and its first partition is mmcblk0p1 and my Tails USB drive is sda and its first partition is sda1. Yours may differ, so substitue appropriately.

The Tails installer doesn't seem to want to install to internal storage even though mine's recognized as an SD card.

  1. Boot Tails as normal but set a root password in "Additional Settings".

  2. Launch "Root Terminal".

  3. Create partitions on internal storage with the same geometry as the Tails partitions.

@metaquanta
metaquanta / autobacklight
Created October 17, 2020 06:20
Adjust backlight throughout the day to correspond to the location of the sun
#!/bin/bash
# /usr/local/bin/autobacklight
BL_DARK=15
BL_BRIGHT=187
SOLAR_NOON=17:15Z
now_s=$(date +%s)
noon_s=$(date -d "${SOLAR_NOON}" +%s)
import { AffineTransform } from "./math/2d/AffineTransform";
import { M } from "./math/2d/M";
import { V } from "./math/2d/V";
const R = [
M(1, 0, 0, 1),
M(0, 1, 1, 0),
M(0, 1, 1, 0),
M(-1, 0, 0, -1),
];