Skip to content

Instantly share code, notes, and snippets.

sciyoshi / esbuild-relay.js
Created Feb 19, 2021
Esbuild plugin for compiling relay queries
View esbuild-relay.js
import { promises } from "fs";
import crypto from "crypto";
import path from "path";
import { print, parse } from "graphql";
const plugin = {
name: "relay",
setup: build => {
build.onLoad({ filter: /\.tsx$/, namespace: "" }, async args => {
let contents = await promises.readFile(args.path, "utf8");
difosfor / my-element.ts
Last active Feb 7, 2021
Typed LitElement events
View my-element.ts
import { customElement, LitElement } from 'lit-element';
type UnpackCustomEvent<T> = T extends CustomEvent<infer U> ? U : never;
// Define custom event types and details here
interface CustomEventMap {
* Dispatched when an error occurs.
'my-error': CustomEvent<{ error: Error }>;
maraisr / environment.ts
Created Nov 26, 2019
Next.js + Relay + TypeScript
View environment.ts
import fetch from 'isomorphic-unfetch';
import React, { createContext, useContext, useMemo } from 'react';
import { ReactRelayContext } from 'react-relay';
import {
davialexandre / gruvbox_dark.json
Created Jun 23, 2019
Gruvbox Dark color scheme for the new Windows Terminal
View gruvbox_dark.json
"background" : "#282828",
"black" : "#282828",
"blue" : "#458588",
"brightBlack" : "#928374",
"brightBlue" : "#83A598",
"brightCyan" : "#8EC07C",
"brightGreen" : "#B8BB26",
"brightPurple" : "#D3869B",
"brightRed" : "#FB4934",
andywer /
Last active Jun 7, 2021
React - Functional error boundaries

React - Functional error boundaries

Thanks to React hooks you have now happily turned all your classes into functional components.

Wait, all your components? Not quite. There is one thing that can still only be implemented using classes: Error boundaries.

There is just no functional equivalent for componentDidCatch and deriveStateFromError yet.

Proposed solution

# -*- coding: utf-8 -*-
import json
import toml
def read_pipenv_lock():
with open('Pipfile.lock') as lock:
return json.loads(
gricard /
Last active Jun 3, 2021
Just some notes about my attempt to upgrade to webpack 4

If you enjoyed reading this, I'm intending to do more blogging like this over here:

This is not a complaint about Webpack or v4 in any way. This is just a record of my process trying it out so I could provide feedback to the webpack team

Hmm... I don't see any docs for 4.0 on I guess I'll just wing it. All I need to do is npm i -D webpack@next, right?

+ webpack@4.0.0-beta.2
LeZuse /
Created Oct 5, 2017
Restart Webpack on config change
$ yarn start
yarn run v1.1.0
$ nodemon
[nodemon] 1.12.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: webpack/webpack.config.js
[nodemon] starting `webpack-dev-server --config webpack/webpack.config.js`
Project is running at https://localhost:4201/
webpack output is served from /assets/
Content not from webpack is served from ***
majackson /
Last active Jun 10, 2021
Django migrations without downtime

Django Migrations without Downtime

The following instructions describe a set of processes allowing you to run Django database migrations against a production database without having to bring the web service down.

Note that in the below instructions, migrations are all run manually at explicit points, and are not an automatic part of the deployment process.

Adding Fields or Tables

Adding a (nullable) field or a new table

  1. Make the model or column addition in your code.
r3m0t /
Created Apr 27, 2017
Migration conflict file
# coding: utf-8
"""Cause git to detect a merge conflict when two branches have migrations."""
# myapp/management/commands/
# you'll need myapp/management/commands/ and myapp/management/ in PY2, see Django docs
from __future__ import absolute_import, unicode_literals
import io
import os
import six