Skip to content

Instantly share code, notes, and snippets.


swyx sw-yx

Block or report user

Report or block sw-yx

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
sw-yx / Netlify9PartDemo Description and
Last active Oct 2, 2019
Netlify9PartDemo Description and
View Netlify9PartDemo Description and
sw-yx /
Last active Sep 25, 2019 — forked from bnb/
sw-yx / cities.js
Last active Sep 16, 2019
threejs boilerplate
View cities.js
let renderer, camera, controls, scene,
width = window.innerWidth,
height = window.innerHeight;
function addShapes() {
Last active Oct 30, 2019
process.env = {
* docs:
NETLIFY: 'true',
// // URLs
sw-yx /
Last active May 31, 2019
oclifconf2019 notes

some notes

  • decent representaiton here across paypal, twilio, apollo, stripe, intuit, adobe/cordova, and thats just the people ive met so far. and ofcourse salesforce, heroku, and netlify
  • jeff dickey (oclif creator) leaving heroku. not sure what hes doing next
  • salesforce cli has 16k total unique users, ~2k daily active. 90 community plugins
  • twilio is launching a big oclif initiative at Signal Conf in a few weeks
  • paypal working on something big too, a few devs here
  • salesforce/heroku have 10 people fulltime and 70ish domain expert contributors on CLI. a lot more community plugin contributors
sw-yx /
Created May 3, 2019
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.
sw-yx / createCtx-noNullCheck.tsx
Last active Nov 20, 2019
better createContext APIs with setters, and no default values, in Typescript. this is documented in
View createCtx-noNullCheck.tsx
// create context with no upfront defaultValue
// without having to do undefined check all the time
function createCtx<A>() {
const ctx = React.createContext<A | undefined>(undefined)
function useCtx() {
const c = React.useContext(ctx)
if (!c) throw new Error("useCtx must be inside a Provider with a value")
return c
return [useCtx, ctx.Provider] as const
sw-yx / final
Last active Apr 16, 2019
Why React is Not Reactive - React Rally CFP
View final

This is the CFP for my React Rally talk, which was eventually accepted and given here:

Final Submission: Why React is not Reactive

Functional-reactive libraries like RxJS make it easy to understand how data changes, giving us tools to declaratively handle events and manage state. But while our render methods react to state changes, React isn’t reactive. Instead, we write imperative event-handlers, and trip up on gotchas like async setState and race conditions. Why? In this talk we build a Reactive React to show the difference between the "push" and "pull" paradigms of data flow and understand why React chooses to manage Scheduling as a core Design Principle, enabling awesome features like async rendering and Suspense!

Theme: This talk is a deep dive into React's core design principle around scheduling. Instead of abstract discussion, we make it accessible and real by exploring an alternate universe in which React was an FRP library and actually run

You can’t perform that action at this time.