Skip to content

Instantly share code, notes, and snippets.

View WestonThayer's full-sized avatar

Weston Thayer WestonThayer

View GitHub Profile
@WestonThayer
WestonThayer / _app.jsx
Last active March 14, 2022 21:06
Basic Next.js focus restoration
// Browsers keep track of where your keyboard focus is when you click
// a link, and they restore focus to the same link when you navigate
// back (via https://web.dev/bfcache/)
//
// SPAs like Next.js break this paradigm because they handle routing
// themselves. This is a basic approach bringing the feature back. It
// doesn't handle restoring the view-state (well, Next.js handles
// scroll restoration out-of-the-box, but that's it) like re-opening
// dropdowns or dialogs or FAQ items that contained the clicked link.
@WestonThayer
WestonThayer / instructions.md
Created August 9, 2019 01:01
App to get Windows scancodes

How to compile

On a Windows machine, you'll first need Visual Studio (the free version is fine). Once that's complete:

  1. Open a command prompt
  2. Find vcvarsall.bat in your VS installation path, then call it with x64 as it's argument. It will look something like: call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x64
  3. Run cl main.c -nologo -Zi -link user32.lib

That should compile and generate main.exe.

name: test
on:
push:
branches: [main]
jobs:
test:
runs-on: windows-latest
steps:
- run: "& 'C:\\Windows\\Resources\\Ease of Access Themes\\hc1.theme'"
# Will upload an artifact to the run with a desktop screenshot
// https://github.com/microsoft/playwright/issues/27130
/**
* Turn a single string character into KeyboardEvent.code and whether a Shift
* modifier is required.
*
* I have no idea how this works if your local keyboard layout isn't US.
*
* @param {string} char
*