Skip to content

Instantly share code, notes, and snippets.

View andyrichardson's full-sized avatar

Andy Richardson andyrichardson

View GitHub Profile
@andyrichardson
andyrichardson / script.js
Last active December 9, 2022 14:51
Tampermonkey script to make Quip document hierarchy a little easier to digest
// ==UserScript==
// @name Quip Style Change
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Reduce bottom margin on section elements to make grouping of content more implicit.
// @author Andy Richardson
// @match https://your-quip-domain.com/* <- SWAP THIS
// @icon https://www.google.com/s2/favicons?sz=64&domain=quip-apple.com
// @grant none
// ==/UserScript==
@andyrichardson
andyrichardson / csv.md
Created January 21, 2022 15:16
JSON <-> CSV conversion

csvToJson

const csvToJson = (arr: any[]) => {
  const keys = Object.keys(arr[0])
  return arr.reduce(
    (p, c) => `${p}\n${keys.map((k) => c[k]).join(',')}`,
    keys.join(','),
  )
}
@andyrichardson
andyrichardson / linux.xml
Created September 12, 2021 09:54
Linux host, Linux guest, libvirt config (w/ igvt-g)
<domain xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0" type="kvm">
<name>popos20.10</name>
<uuid>6c914fa3-f90a-40d0-b17d-cc24ed8ee3d8</uuid>
<metadata>
<libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
<libosinfo:os id="http://system76.com/popos/20.10"/>
</libosinfo:libosinfo>
</metadata>
<memory unit="KiB">4194304</memory>
<currentMemory unit="KiB">4194304</currentMemory>
@andyrichardson
andyrichardson / react-portal.tsx
Created July 13, 2021 13:41
React portal example
import { useLayoutEffect, useRef } from "react";
import { createPortal } from "react-dom";
const createPortalComponent = (el: HTMLElement) => ({ children }) => {
const ref = useRef<HTMLElement>(document.createElement("div"));
useLayoutEffect(() => {
el.appendChild(ref.current);
return () => el.removeChild(ref.current);
}, []);

07/07/21

Events Pagination

Peek.2021-07-06.11-17.mp4

PR for using cursor based pagination for fetching apps.

About

Frame times (90fps) are inconsistent causing linear movements to feel jittery/non-linear.

Version

  • Quest 2 (v28)
  • Virtual Desktop: V1.20.5 (client and streamer)

Reproduction (desktop)

  • Make sure desktop is running at at least 90fps
  • Visit this ufotest
@andyrichardson
andyrichardson / JSON-to-CSV.md
Last active April 22, 2021 11:07
Conversion of JSON to CSV without libraries

JSON to CSV

Conversion of JSON to CSV without libraries

const jsonToCSV = (data, columns) => {
  // Create CSV string
  const makeRow = (columns) => columns.map((c) => (c === undefined ? '' : `${JSON.stringify(c)}`)).join(',') + '\n';
 const resolvePath = (data, path) =&gt; path.reduce((obj, p) =&gt; obj[p], data);
@andyrichardson
andyrichardson / iwinfo.log
Created April 19, 2021 12:03
`iw list` response for RT3200 (snapshot release)
Wiphy phy1
wiphy index: 1
max # scan SSIDs: 4
max scan IEs length: 2190 bytes
max # sched scan SSIDs: 0
max # match sets: 0
Retry short limit: 7
Retry long limit: 4
Coverage class: 0 (up to 0m)
Device supports AP-side u-APSD.

Unidirectional pagination

const paginateQuery = async <T>({
    params,
    acc = [],
    pageSize,
  }: {
    params: DynamoDB.DocumentClient.QueryInput;
    acc?: T[];
export type Event<K extends string = string, V extends any = any> = {
key: K;
value: V;
};
export class EventTarget<T extends Event> {
private listeners: { [key in T["key"]]?: Array<(event: any) => void> } = {};
public addEventListener<K extends T["key"]>(
type: K,