Skip to content

Instantly share code, notes, and snippets.

// Command aftership-order-status extracts the full status information from an
// aftership order-status webpage.
package main
import (
"bytes"
"encoding/json"
"errors"
"math/bits"
"os"
@pgaskin
pgaskin / lzstring.go
Last active January 11, 2026 10:58
Simple lzstring decompression in Go.
package lzstring
import (
"errors"
"math/bits"
"unicode/utf8"
"unsafe"
)
// Decompress decompresses a lzstring-compressed byte sequence from a slice of
@pgaskin
pgaskin / lzstring-tiny.js
Last active January 11, 2026 07:08
Ultra-compact lzstring decompress implementation.
function decompress(buf) {
const fromCharCode = String.fromCharCode
const invalid = new Error("invalid")
let idx = 0, u16 = 0, bit = 0
const uint = bits => {
let res = 0
for (let i = 0; i < bits; i++) {
if (bit == 0) {
if (idx >= buf.length) {
@pgaskin
pgaskin / adb_418203510_workaround.go
Last active September 26, 2025 01:31
Workaround for chrome://inspect over ADB hanging. https://issuetracker.google.com/issues/418203510
package main
import (
"bytes"
"context"
"errors"
"flag"
"fmt"
"io"
"log/slog"
@pgaskin
pgaskin / zyte.go
Last active September 25, 2025 13:25
package zyte
import (
"bytes"
"cmp"
"context"
"encoding/json"
"fmt"
"io"
"maps"
package main
import (
"context"
"crypto/rand"
"crypto/rsa"
"encoding/binary"
"io"
"log/slog"
"net"
@pgaskin
pgaskin / TapoC100.md
Last active July 28, 2025 02:10
TP-Link Tapo C100 notes

TP-Link Tapo C100

Overview

I've tried v4.20 and v5.0 hardware revisions.

The v5.0 ones seem a bit more responsive in general, though it's unclear if it's due to firmware or hardware. The v5.0 one does talk out loud when setting it up.

For both versions, recent firmware updates have significantly improved the reliability.

// Command i3-multi-input sends input to all selected i3wm windows. It is
// intended to be bound to a keyboard shortcut.
//
// bindsym --release $mod+Shift+a exec --no-startup-id i3-multi-input
package main
import (
"fmt"
"iter"
"os"
/* last updated for ff 134 */
/* toolkit.legacyUserProfileCustomizations.stylesheets = true */
/* compact mode:
browser.compactmode.show = true
extensions.activeThemeID = firefox-compact-dark@mozilla.org
browser.uidensity = 1
browser.tabs.inTitlebar = 0
*/
package jsonx
import (
"strconv"
"unicode/utf8"
)
// AppendKey appends a JSON key to an object, adding a comma if necessary.
func AppendKey(e []byte, k string) []byte {
if len(e) == 0 {