Or: “Everybody likes being given a glass of water.”
By Merlin Mann.
It's only advice for you because it had to be advice for me.
| import type {SanityClient} from '@sanity/client' | |
| import {v5 as uuidv5} from 'uuid' | |
| import {buildCollectionDocumentId, commitCollectionDocument} from './sanityOps' | |
| import type {ShopifyDocumentCollection} from './storageTypes' | |
| import {SHOPIFY_COLLECTION_DOCUMENT_TYPE, UUID_NAMESPACE_COLLECTIONS} from './constants' | |
| import {DataSinkCollection} from './requestTypes' | |
| import {idFromGid} from './requestHelpers' |
| import invariant from "tiny-invariant"; | |
| class AmalgoBox extends HTMLElement { | |
| get input() { | |
| return this.querySelector("input") as HTMLInputElement; | |
| } | |
| get button() { | |
| return this.querySelector("button") as HTMLButtonElement; | |
| } |
| import React, {useEffect, useState, useRef} from 'react' | |
| import documentStore from 'part:@sanity/base/datastore/document' | |
| import {catchError, distinctUntilChanged} from 'rxjs/operators' | |
| import isEqual from 'react-fast-compare' | |
| type Params = Record<string, string | number | boolean | string[]> | |
| interface ListenQueryOptions { | |
| tag?: string | |
| apiVersion?: string |
| import S from '@sanity/desk-tool/structure-builder' | |
| import userStore from 'part:@sanity/base/user' | |
| // Get the logged in user | |
| const getCurrentUser = () => { | |
| userStore.me.subscribe((user) => { | |
| // Instead of a local variable, we use this window object to re-use it through the Studio | |
| if (user) { | |
| window._sanityUser = user ?? undefined | |
| } |
| async function getComponents(fileKey, token) { | |
| // Get file | |
| const file = await fetch(`https://api.figma.com/v1/files/${fileKey}`, { | |
| headers: { "X-Figma-Token": token } | |
| }).then((r) => r.json()) | |
| if (file.err === undefined) { | |
| // Get style ids | |
| const styleIds = Object.keys(file.styles) |
| import log from "ololog" | |
| class Grid { | |
| rows = [] | |
| width = 0 | |
| height = 0 | |
| chars = { | |
| active: ["┌", "─", "┒", "┃", "┛", "━", "┕", "│"], | |
| inactive: ["┌", "─", "┐", "│", "┘", "─", "└", "│"], |
| // deno run --allow-net --allow-write download-shows.ts | |
| import { download } from "https://deno.land/x/download/mod.ts"; | |
| const showList = 'https://syntax.fm/api/shows'; | |
| async function getShowList(): Promise<Show[]> { | |
| const list = await (await fetch(showList)).json(); | |
| return list; | |
| } |