Skip to content

Instantly share code, notes, and snippets.

View jcs's full-sized avatar
💭
cvs -q up -PAd

joshua stein jcs

💭
cvs -q up -PAd
View GitHub Profile
@jcs
jcs / gist:0a199038709a241afa2c384e45d54927
Created July 20, 2021 01:44
LG UltraFine 21.5" USB control
uhidev5 at uhub6 port 4 configuration 1 interface 0 "LG Electronics Inc. USB Controls" rev 2.00/3.04 addr 7
uhidev5: iclass 3/0
uhid5 at uhidev5: input=64, output=64, feature=8
uhidev6 at uhub6 port 4 configuration 1 interface 1 "LG Electronics Inc. USB Controls" rev 2.00/3.04 addr 7
uhidev6: iclass 3/0
uhid6 at uhidev6: input=4, output=0, feature=6
uhidev7 at uhub6 port 4 configuration 1 interface 2 "LG Electronics Inc. USB Controls" rev 2.00/3.04 addr 7
uhidev7: iclass 3/0
uhid7 at uhidev7: input=6, output=0, feature=13
@jcs
jcs / matebook_dsdt.md
Created July 19, 2019 16:08
Matebook X DSDT - Touchpad (TPL1)
    Scope (_SB.PCI0.I2C1)
    {
        Device (TPL1)
        {
            Name (HID2, Zero)
            Name (SBFB, ResourceTemplate ()
            {
                I2cSerialBusV2 (0x004C, ControllerInitiated, 0x00061A80,
                    AddressingMode7Bit, "\\_SB.PCI0.I2C1",
@jcs
jcs / ihidev.md
Last active July 19, 2019 20:20
The Great ihidev(4) Debugging

The Problem

  • I2C-connected Windows Precision Touchpads on Skylake and newer laptops don't generate interrupts through the IOAPIC when using OpenBSD - polling has to be used to fetch touchpad data

OpenBSD

ioapic0 at mainbus0: apid 2 pa 0xfec00000, version 20, 120 pins
[...]
dwiic0 at pci0 dev 21 function 0 "Intel 100 Series I2C" rev 0x21: apic 2 int 16
@jcs
jcs / move_git_commits.sh
Last active December 19, 2016 18:19
moving git commits from one tree to another
# moving git commits from one tree to another, preserving original git commit metadata like date/time
# (creating a new hash, of course)
# find current commits
git log jcs --author=jcs@jcs.org --no-merges --oneline --no-abbrev-commit --reverse | sed 's/ .*//' > commits
# in new git tree, for each $hash in $commits
git --git-dir=/path/to/old/tree/.git format-patch -k -1 --stdout <hash> | git am -3 -k
@jcs
jcs / netpbm-resize pseudo-code
Created June 4, 2016 16:25
using netpbm to resize jpegs and pngs of arbitrary size to fixed square, preserving ratio with transparency
#
# solution for resizing jpegs and pngs of arbitrary size down to a 72x72
# square, preserving source ratio, and filling non-square sides with
# transparency
#
# ahead of time, convert a transparent 72x72 png to blank-72.pam and save
# it with your code
#
# pngtopam -quiet -alphapam < blank-72.png > blank-72.pam
#
@jcs
jcs / openbsd_cbp.md
Last active April 2, 2024 20:18
OpenBSD (with encrypted softraid) on the Chromebook Pixel (2015)
@jcs
jcs / asus c201.md
Last active April 17, 2024 17:44
Disabling SPI write protection, reflashing, and unbricking an Asus Chromebook C201

####Disabling SPI write protection

Put the Chromebook in developer-mode:

  • With machine powered off, hold down Esc and Refresh(F3) while hitting power button
  • At warning prompt, hit Control+D, then Enter at prompt about enabling developer mode
  • Machine will format itself

Now remove the write-protect screw to enable flashrom to flash new Coreboot/Libreboot.

Flip powered-off machine over and remove 8 philips-head screws. 2 are located under rubber feet.

Keybase proof

I hereby claim:

  • I am jcs on github.
  • I am jcs (https://keybase.io/jcs) on keybase.
  • I have a public key whose fingerprint is 51DE 5E0C 5643 6F37 D718 0936 603C A7D7 27C9 E467

To claim this, I am signing this object:

@jcs
jcs / gist:5573685
Last active April 2, 2024 20:18
macOS FileVault encryption and OpenBSD encrypted softraid on a Macbook Air/Pro

Update (2019-05-06): The Broadcom wireless card in the MacBook Pro works and can be crammed into the Air.

Update (2015-12-04): This document used to be very lengthy as there were many manual steps required to get OpenBSD and Mac OS X working together through Boot Camp Assistant (BCA), which created a hybrid MBR and enabled a legacy BIOS emulation mode which older versions of Windows (and OpenBSD) required. Newer Macbooks stopped supporting older versions of Windows through BCA and now only support Windows 10 since it uses GPT and UEFI. However, now that newer versions of OpenBSD support GPT and UEFI, Boot Camp Assistant is no longer needed at all to boot OpenBSD.

macOS FileVault encryption and OpenBSD encrypted softraid on a Macbook Air/Pro

OpenBSD works pretty well on at least the Mid-2011 Macbook Air (A1370, SandyBridge) and Mid-2013 Macbook Air (Haswell). The new KMS code in 5.4 brings up the MBA's eDP display in 1366x768 with backlight