Skip to content

Instantly share code, notes, and snippets.

View pgaskin's full-sized avatar
💭
I may be slow to respond (especially for Kobo stuff).

Patrick Gaskin pgaskin

💭
I may be slow to respond (especially for Kobo stuff).
View GitHub Profile
#!/bin/sh
set -eu
encode_integer() {
local value=$1
printf "0x10 0x%08X" $((value&0xFFFFFFFF))
}
encode_dimen() {
# https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/util/TypedValue.java

setup

mkdir /opt/rsync-backup
cd /opt/rsync-backup
go mod init rsync-backup
go mod tidy
go build .
mkdir -p /etc/sysusers.d /etc/tmpfiles.d
ln -sf /opt/rsync-backup/rsync-backup.sysusers /etc/sysusers.d/rsync-backup.conf
@pgaskin
pgaskin / htoprc
Last active October 30, 2023 06:57
# Beware! This file is rewritten by htop when settings are changed in the interface.
# The parser is also very primitive, and not human-friendly.
htop_version=3.2.2
config_reader_min_version=3
fields=0 48 38 39 119 40 2 46 47 49 1
hide_kernel_threads=1
hide_userland_threads=1
hide_running_in_container=0
shadow_other_users=0
show_thread_names=0
#!/bin/bash
set -euo pipefail
cd "$(dirname "$0")"
if [[ $# -ne 1 ]] && [[ $# -ne 2 ]]; then
echo "usage: $0 fw [old_fw]"
exit 2
fi
test -f ~/kp/v/$1/nickel
@pgaskin
pgaskin / phyphox.py
Created April 14, 2023 05:53
Python client for getting data from the Phyphox remote access server.
#!/usr/bin/env python3
import itertools
import json
import math
import socket
import time
import urllib.error
import urllib.request
import urllib.parse
<# ::
@@ start "" powershell -WindowStyle Hidden -NoProfile -ExecutionPolicy Bypass -Command "Invoke-Expression (Get-Content -Raw '%~f0')"
#>
$ErrorActionPreference = "Stop"
try {
Add-Type -Language CSharp -ReferencedAssemblies $("System.Windows.Forms", "System.Drawing") @"
using System;
using System.Drawing;
using System.Reflection;
@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.