Skip to content

Instantly share code, notes, and snippets.

View a-type's full-sized avatar

Grant Forrest a-type

View GitHub Profile
@a-type
a-type / portable.md
Created March 22, 2026 02:19
Solving "This is likely not portable."

Okay, I run into this a lot. At least since PNPM.

Here's at least one thing that's worked for me:

Whatever the non-portable type is that it's complaining about (something imported from another library and re-exported)...

  1. Create a named type alias for that type in the module
  2. Export that type alias
  3. Explicit cast the thing to that type alias
@a-type
a-type / Icon.tsx
Last active March 16, 2023 20:04
Figma icon script
import { ComponentProps, forwardRef, SVGAttributes } from 'react';
import { styled } from 'stitches.config';
import { IconName } from './generated/iconNames';
export interface IconProps extends ComponentProps<typeof StyledSvg> {
name: IconName;
}
export const Icon = forwardRef<SVGSVGElement, IconProps>(function Icon(
@a-type
a-type / typescriptreact.code-snippets
Created March 16, 2023 15:32
React + TS code snippets
{
"TS React FC": {
"scope": "typescriptreact",
"prefix": "rfc",
"body": [
"export interface ${1:${TM_FILENAME/(.*)\\..+$/$1/}}Props {",
" $2",
"}",
"",
"export function $1({ $3 }: $1Props) {",
@a-type
a-type / liveblocksApi.ts
Last active May 18, 2022 17:04
Liveblocks API types
import {
LiveList,
LiveMap,
LiveObject,
Lson,
LsonObject,
} from '@liveblocks/client';
type ExtractObjectShape<T extends LiveObject<LsonObject>> =
T extends LiveObject<infer U> ? U : never;
@a-type
a-type / liveblocksHooks.ts
Created February 4, 2022 20:28
Liveblocks hooks with suspense
import { LiveList, LiveMap, LiveObject, Presence } from '@liveblocks/client';
import { useRoom } from '@liveblocks/react';
import { useState, useEffect, useMemo, useRef } from 'react';
import invariant from 'tiny-invariant';
import { useAsset } from 'use-asset';
export function useRoot() {
const room = useRoom();
// suspend until root storage is ready
const { root } = useAsset((r) => {
@a-type
a-type / cert.yaml
Created December 10, 2021 20:12
LiveKit k8s manifests
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: livekit-cert
spec:
secretName: livekit-tls
dnsNames:
- livekit.your.domain.com
issuerRef:
name: letsencrypt-production
@a-type
a-type / useShipControls.ts
Last active August 14, 2021 13:03
react-three-fiber spaceship controls (hacky)
// various tmp vars to avoid allocation in frame loop
const frameMovement = new Vector3();
const frameRotation = new Euler();
const tempQuat = new Quaternion();
const tempQuat2 = new Quaternion();
const tempForward = new Vector3();
const tempRight = new Vector3();
const tempUp = new Vector3();
function useShipControls(api: RAPIER.RigidBody) {
@a-type
a-type / abort-test.js
Created July 1, 2021 21:43
Abort controller synchronous call test
var controller = new AbortController();
fetch('/', { signal: controller.signal })
.then(res => res.text())
.then(text => console.log(text));
// busywait for a while, should keep the thread busy until the request
// completes.
let i = 0; while (i < 100000) {
i++;
console.log(i);
@a-type
a-type / problem-report.txt
Created June 21, 2021 14:37
Color Picker problem report
Process: Color Picker [4360]
Path: /Applications/Color Picker.app/Contents/MacOS/Color Picker
Identifier: com.sindresorhus.Color-Picker
Version: 1.5.0 (14)
App Item ID: 1545870783
App External ID: 842742849
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Color Picker [4360]
User ID: 501
@a-type
a-type / sleep.log
Last active April 6, 2021 14:22
Twilio sleep bug log
Some messages have been moved to the Issues panel.
index.js:31900 The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. https://goo.gl/7K7WLu
173 @ index.js:31900
o @ index.js:1
(anonymous) @ index.js:1
171../browser @ index.js:31410
o @ index.js:1
r @ index.js:1
(anonymous) @ index.js:1
index.js:26667 2021-04-06T14:07:37.885Z info [connect #1] Connecting to a Room