Skip to content

Instantly share code, notes, and snippets.

@exogen
exogen / graphql-server.js
Last active October 26, 2017 18:06
Simple GraphQL server
const express = require('express')
const graphqlHTTP = require('express-graphql')
const makeExecutableSchema = require('graphql-tools').makeExecutableSchema
const schema = makeExecutableSchema({
typeDefs: `
type Query {
user: User
}
@exogen
exogen / diff-create-react-app.sh
Last active November 22, 2017 03:19
Show divergence from create-react-app as a diff.
#!/usr/bin/env bash
#
# Determine divergence from create-react-app!
# Use this if you've ejected from create-react-app and want to see how its
# latest output would differ in key areas (package.json, config, scripts).
#
# - Assumes you can run create-react-app, so make sure it's installed.
# - Only shows files you've modified or removed from create-react-app.
# - Runs $FORMAT_COMMAND below on the create-react-app directory so formatting
# differences don't show up. Use something like Prettier, eslint --fix, etc.
// This is based on some transpiled Babel code causing the `default` export
// to be undefined. If you look at the ultimate code that ends up in the Next.js
// bundle, `Object` method references are changed to strange `@babel/runtime`
// references, which seems to potentially cause a circular import (?) resulting
// in it being undefined.
exports.__esModule = true;
exports.default = DebugProvider;
exports.DebugContext = void 0;
var _react = _interopRequireWildcard(require("react"));
@exogen
exogen / parse-icu.js
Created October 26, 2020 20:11
Tiny ICU message syntax parser
/**
* Parses ICU message syntax into an AST.
* Supports these features:
* - Apostrophe escapes (uses DOUBLE_OPTIONAL mode).
* - {simple} substitution.
* - {var, type} substitution.
* - {var, type, format} substitution, where format can contain complex nesting
* of additional ICU messages, for example:
* “I’ve invited {n, plural, offset:1
* =0 {nobody!}