I absolutely failed at a timed challenge on how to serialize and deserialize a binary tree in JS.
This is my way of compensating for that failure 🤦
Hopefully this helps someone!
| export const ttlCache = <K extends string, V = any>({ ttl, maxSize }: { ttl: number, maxSize?: number }) => { | |
| let cache: Record<K, { value: V; expiresAt: number } | undefined> = Object.create(null); | |
| return { | |
| set: (key: K, value: V) => { | |
| const keys = Object.keys(cache) as K[]; | |
| if (maxSize && keys.length === maxSize) { | |
| delete cache[keys[0]]; | |
| } |
| // ==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== |
| <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> |
| 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); | |
| }, []); |
PR for using cursor based pagination for fetching apps.
Frame times (90fps) are inconsistent causing linear movements to feel jittery/non-linear.
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) => path.reduce((obj, p) => obj[p], data);| 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. |