Skip to content

Instantly share code, notes, and snippets.

@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).
@pgaskin
pgaskin / ubus.go
Created May 25, 2022 23:31
Simple client for OpenWrt's HTTP RPC.
// Package ubus contains a simple client for OpenWrt's HTTP RPC.
package ubus
import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
@pgaskin
pgaskin / otp.js
Created May 6, 2022 07:16
TOTP/HOTP implementation for modern browsers (RFC 4226/6238)
/** Compute a HOTP/TOTP for a base32 secret. */
export async function computeOTP(secret, digits = 6, counter = Math.floor(Date.now() / (30 * 1000))) {
// parse the secret as base32, stripping whitespace and padding
const parsedSecret = Uint8Array.from(Array
.from(secret.replace(/[\s=]/g, "").toUpperCase())
.reduce((state, c) => {
const n = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".indexOf(c)
if (n < 0) throw new Error("Invalid base32")
state.as = (state.as << 5) | n
state.in += 5
@pgaskin
pgaskin / 1_openwrt-22.03-mikrotik-hap-ac2-fix-vlans.patch
Last active April 26, 2022 01:49
Get rid of the forced vlan 1/2 tagging and split eth0/1 on the hAP ac2.
From 632be27eefda4638bcecd6068c3553f8f64ce4c8 Mon Sep 17 00:00:00 2001
From: Patrick Gaskin <[email protected]>
Date: Mon, 25 Apr 2022 03:08:05 -0400
Subject: [PATCH] ipq40xx: essedma: disable default vlan tagging for the
Mikrotik hAP ac2
This removes the separate WAN gmac eth1 and fixes VLAN tagging.
---
target/linux/ipq40xx/base-files/etc/board.d/02_network | 5 ++++-
.../files/arch/arm/boot/dts/qcom-ipq4018-hap-ac2.dts | 6 ++++++