Skip to content

Instantly share code, notes, and snippets.

import tree from "./tree";
test("it should serialise the tree", () => {
expect(tree("path/to/folder")).toMatchInlineSnapshot(); // jest will fill this in automatically
});
@ericmeltzer
ericmeltzer / ancestors.md
Last active August 21, 2020 20:02
How to talk to your ancestors

Talk to your ancestors

Screen Shot 2020-07-19 at 1 35 23 PM

When I lived in China I frequently had the chance to talk to people who experienced an event that I had only read about. The past 70 years in China have been rather… eventful, and I’d talk to some older person and find out they had first-hand stories about the Cultural Revolution, or occasionally even the Chinese civil war. The difference between what’s written in history books and people’s personal recollections were often stark!

When the COVID pandemic was looming but its significance was still only being talked about in the West by a handful of iconoclastic investors, I really wished I could talk to someone who had been through the Spanish Flu (or hell, the Black Death!) to get a sense of what it felt like right before the excrement hit the air-conditioning.

But even more than that, I’ve always desperately wishe

@phooky
phooky / no_masters.sh
Last active December 16, 2020 16:54
A quick bash script for changing the "master" branch of your github repo(s) to an alternative of your choosing.
#!/bin/bash
# There's a better way to do this! Use:
# https://github.com/dfm/rename-github-default-branch
# instead.
#
# Also: don't change the default branch name on your gists! Github appears to have them
# locked to master; it will break your gist.
set -e
@thesved
thesved / bmc-template
Last active October 4, 2021 07:36
Business Model Canvas in Roam Research w/ tables and block embeds
- [[Business Model Canvas]] test
- table: Roam Research BMC
- {{[[table]]}}
- ((top row id))
- ((bottom row id))
- structure
- intermediary rows
- {{[[table]]}}
- {{[[embed]]: ((activity id))}}
- {{[[embed]]: ((resource id))}}
// I've only used this for focus management, I'm willing to bet you don't
// actually want to do this unless it's focus management
function useUpdateEffect(effect, deps) {
let mounted = useRef(false)
useEffect(() => {
if (mounted.current) {
return effect()
} else {
mounted.current = true
@MichaelCurrin
MichaelCurrin / README.md
Last active March 5, 2024 22:06
GitHub GraphQL - Get files in a repository

Get GitHub Files

Get the metadata and content of all files in a given GitHub repo using the GraphQL API

You might want to get a tree summary of files in a repo without downloading the repo, or maybe you want to lookup the contents of a file again without download the whole repo.

The approach here is to query data from GitHub using the Github V4 GraphQL API.

About the query

@DavidWells
DavidWells / add-user-to-private-repo.js
Created April 26, 2020 21:41
Add GitHub user to private GitHub repo utility function
const axios = require('axios')
const GITHUB_REPO = process.env.GITHUB_REPO
const GITHUB_API_TOKEN = process.env.GITHUB_API_TOKEN
const GITHUB_USERNAME = process.env.GITHUB_USERNAME
module.exports = function addUserToGithubRepo(username) {
const githubEndpoint = `https://api.github.com/repos/${GITHUB_REPO}/collaborators/${username}`
const config = {
'headers': {
'User-Agent': GITHUB_USERNAME,
@WebReflection
WebReflection / dom-libraries.md
Last active February 6, 2024 15:50
A recap of my FE / DOM related libraries

My FE/DOM Libraries

a gist to recap the current status, also available as library picker!

Minimalistic Libraries

do one thing only and do it well

  • µhtml (HTML/SVG auto-keyed and manual keyed render)
  • augmentor (hooks for anything)
  • wickedElements (custom elements without custom elements ... wait, what?)
import { useEffect, useMemo, useState, useCallback } from "react";
import useQueryString from "./useQueryString";
function useQueryStringWithIndexValue(key, initialIndex, values) {
const computedValues = useMemo(() => values.map(v => v.toLowerCase()), [
values
]);
const [value, onSetValue] = useQueryString(key, values[initialIndex]);
const [index, setIndex] = useState(initialIndex);
import { useState, useEffect, useCallback } from 'react'
function usePromise(createPromise) {
const [error, setError] = useState()
const [value, setValue] = useState()
useEffect(() => {
let current = true
createPromise().then(