Skip to content

Instantly share code, notes, and snippets.

View souporserious's full-sized avatar

Travis Arnold souporserious

View GitHub Profile
import { FSWatcher } from "chokidar";
import { Project, ProjectOptions } from "ts-morph";
import invariant from "invariant";
interface TsMorphWatcherFsEvent {
type: "add" | "unlink" | "change";
path: string;
}
type TsMorphWatcherEvent = TsMorphWatcherFsEvent | { type: "ready" };
@bvaughn
bvaughn / useSubscription-and-useMutableSource.md
Last active December 29, 2021 02:12
`useSubscription` and `useMutableSource` tearing and deopt behavior.

useSubscription and useMutableSource1 tearing and deopt behavior.

Mounting a new tree

The tree below represents a React application mounting. During mount, two components read from an external, mutable source. The first one (List) reads version 1 of that data and the second one (Item) reads version 2.

Deopt

useSubscription (legacy mode)

N/A.

babel-plugin-transform-mui-imports npm

A plugin to make authoring with MUI components efficient, both for humans and bundlers.

Here's why:

@TehShrike
TehShrike / weekday-names.js
Created January 21, 2020 23:04
The names of the days of the week using browser locale
const anArbitrarySundayEarlyInTheMonth = new Date(2020, 0, 5)
const dayNumbers = [ 0, 1, 2, 3, 4, 5, 6 ]
const formatter = new Intl.DateTimeFormat(undefined, {
weekday: `short`,
})
const weekdayNames = dayNumbers.map(dayNumber => {
const date = new Date(anArbitrarySundayEarlyInTheMonth)
date.setDate(date.getDate() + dayNumber)
return formatter.format(date)
import * as React from "react"
import { Override, Data, useTransform, motionValue } from "framer"
const x = motionValue(0)
export function Card(props): Override {
const rotate = useTransform(x, [-100, 100], [-20, 20])
return {
rotate,
x,
@steveruizok
steveruizok / useScrollHeader.ts
Last active May 13, 2022 06:36
A Framer X hook to hide or show a header based on a scroll position.
import * as React from "react"
import {
Override,
motionValue,
transform,
useTransform,
MotionValue,
} from "framer"
type States = "open" | "closed" | "opening" | "closing"
@swyxio
swyxio / adaptive_intent.md
Created May 3, 2019 08:04
an adaptive, intent based CLI "state machine"

an adaptive, intent based CLI "state machine"

one realization from working on Netlify's CLI is that the CLI framework we used, oclif, didn't provide a great user experience out of the box.

Emphasis on great: it does a lot of nice things, like offering flag and argument parsing, help documentation, and pluggability. That's good for the CLI developer. But what about the CLI user?

  • Idiomatic oclif code often checks for required preconditions, and if it doesn't exist, it prints a warning and then process.exit(1).
  • Decent code prints a helpful warning telling the user what they got wrong. It is informative.
  • Better code offers a prompt, creates a file, or something similar to solve the precondition before proceeding. (possibly recursively). It is intent-based.
  • Great code remembers past inputs to prompts and uses that to offer useful defaults. It is adaptive.
@wkillerud
wkillerud / styleguide.config.js
Created April 4, 2019 06:46
A workaround for the poor performance described in styleguidist/react-docgen-typescript#112 based on the work done in strothj/react-docgen-typescript-loader#40.
/**
* The MIT License
*
* Further resources on the MIT License
* Copyright 2018 Jason Strothmann <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
/*
* This script fetches all color styles from a Figma team/document.
*
* Dependencies:
*
* - node-fetch
*
* Due to a limitation in the Figma /styles endpoint, we need to use a
* document for actually using the colors in a color grid 🙄That's why
* we're both fetching from /styles and /files below.
@swyxio
swyxio / Write My Code For Me: Cheating at Developer Experience.md
Last active October 16, 2021 22:01
some thoughts on adding templating/scaffolding to CLIs and how it can be done well

Write My Code For Me: Cheating at Developer Experience

this is a draft of a blogpost that i'll be posting somewhere. Feedback welcome! also feel free to ping me on twitter

I've recently been working on some CLI that involves printing out a bunch of boilerplate template code for developer convenience. I found that there were a few interesting DX angles to this and figured I should write down the rough problem areas and the stances I chose. Most of us are familiar with CLIs like https://yeoman.io/, this task is variously called "scaffolding" or "templating" or some such similar term, with varying degrees of intelligence in the task. I'll refer to it as "templating" in this essay.

Part 1: Should You?

Caramel, not just Sugar