Skip to content

Instantly share code, notes, and snippets.

View pgaskin's full-sized avatar
💭
busy for a week or two

Patrick Gaskin pgaskin

💭
busy for a week or two
View GitHub Profile
@pgaskin
pgaskin / fedora-37-vfio-bind.sh
Created January 27, 2023 23:59
Simple early-boot VFIO device binding by PCI address on Fedora 37.
# enable AMD IOMMU with DMA passthrough
# note: iommu=pt is much faster than the default translated DMA since memory access doesn't need to go through the hypervisor
sudo sed -i '1 s/$/ amd_iommu=on iommu=pt/' /etc/kernel/cmdline
# list IOMMU groups
# record the PCI IDs of all devices in the target group
for d in /sys/kernel/iommu_groups/*/devices/*; do
n=${d#*/iommu_groups/*};
n=${n%%/*};
test $n -eq $pn || printf '\nIOMMU Group %s\n' $n;
@pgaskin
pgaskin / fedora-37-systemd-boot.md
Last active January 28, 2023 00:00
Using systemd-boot on Fedora 37.

Using systemd-boot on Fedora 37

If doing a fresh install, start with an EFI system partition and an ext4 /boot/ partition.

  1. Remove unnecessary packages.

    rm -rf /etc/dnf/protected.d/{grub,shim}*
    dnf remove grubby grub2\* shim\*
@pgaskin
pgaskin / qchlimit.s
Created September 27, 2022 21:28
Limit qcom battery charging on Android. Written in assembly for fun.
// as qchlimit.s -o qchlimit.o
// ld qchlimit.o -o qchlimit
// llvm-strip --strip-all --strip-sections qchlimit
// adb root && adb shell 'killall qchlimit ; /path/to/qchlimit 35 75 &'
.global _start
.text
.equ SYS_openat, 56
.equ SYS_pread64, 67
.equ SYS_pwrite64, 68
@pgaskin
pgaskin / lineage18.1_kiev.md
Last active September 25, 2022 19:05
My notes about LineageOS 18.1 on the Moto One 5G Ace.

2022-09-24

Installation

  • TWRP is buggy, seems to cause problems with LOS + FlameGapps.
  • Use LOS recovery after flashing stock 11.
  • fastbootd usb doesn't seem to work.

Battery life

  • Can stop charging with echo 1 > /sys/class/power_supply/qcom_battery/input_suspend.
  • See stuff about cnss-daemon.
package net.pgaskin.kl125gesture;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.Closeable;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.DatagramPacket;
@pgaskin
pgaskin / remote-control-gestures.md
Last active August 13, 2022 12:18
Observations about touch gesture behavior in the RealVNC app.

One finger drag

  • ignore until moved a few pixels
  • iff one finger is down (ignore events otherwise without changing state), cancel any fling or pending tap (only cancel the tap if it's before the initial release) and do mouse cursor move
  • fling based on final velocity
  • cancel fling on move (not necessarily on finger down)
  • relative to device dpi, not real local or remote screen

Two finger drag (when not in the middle of a tap gesture, but can cancel it if still before the first stage finger up)

  • ignore until a threshold is reached for a gesture below, then cancel any fling or pending tap (only cancel the tap if it's before the initial release)
  • vertical scroll
// Package grdist parses Queen's University SOLUS (Oracle PeopleSoft Student
// Records 9) Grade Distribution Reports.
//
// Works as of August 2022.
package grdist
import (
"bytes"
"errors"
"fmt"
@pgaskin
pgaskin / asu.go
Last active August 7, 2022 11:08
package main
import (
"bytes"
"context"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"fmt"
"io"
// Command otpprint prints TOTP codes.
package main
import (
"crypto/hmac"
"crypto/sha1"
"encoding/base32"
"encoding/binary"
"fmt"
"hash"
package config
import "bytes"
// bsutil implements efficient zero-allocation operations on a byte slice.
type bsutil []byte
var asciiSpace = [256]uint8{'\t': 1, '\n': 1, '\v': 1, '\f': 1, '\r': 1, ' ': 1}
// Clone returns a clone of b (but not the underlying data).