Skip to content

Instantly share code, notes, and snippets.


Dan Harper danharper

View GitHub Profile
gaearon /
Last active Jul 1, 2020
A Gentle Introduction to Prepack, Part 1


When this guide is more complete, the plan is to move it into Prepack documentation.
For now I put it out as a gist to gather initial feedback.

A Gentle Introduction to Prepack (Part 1)

If you're building JavaScript apps, you might already be familiar with some tools that compile JavaScript code to equivalent JavaScript code:

  • Babel lets you use newer JavaScript language features, and outputs equivalent code that targets older JavaScript engines.
bvaughn / updating-subscriptions-when-props-change-example.js
Last active Jun 21, 2020
Advanced example for manually updating subscriptions in response to props changes in an async-safe way
View updating-subscriptions-when-props-change-example.js
// This is an advanced example! It is not typically required for application code.
// If you are using a library like Redux or MobX, use the container component provided by that library.
// If you are authoring such a library, use the technique shown below.
// This example shows how to safely update subscriptions in response to props changes.
// In this case, it is important to wait until `componentDidUpdate` before removing a subscription.
// In the event that a render is cancelled before being committed, this will prevent us from unsubscribing prematurely.
// We also need to be careful about how we handle events that are dispatched in between
// `getDerivedStateFromProps` and `componentDidUpdate` so that we don't put stale values into the `state`.
View react-logger.js
// put this at the top of your app
const setState = Component.prototype.setState
Component.prototype.setState = function(nextState) {
if (this.shouldComponentUpdate) {
console.log('shouldComponentUpdate', (
this.shouldComponentUpdate(this.props, nextState)


  • /src/parser/ The type definitions for the AST. Tries to stay very close to ESTree
  • /src/parser/lexer_flow.mll: The ocamllex lexer logic
  • /src/parser/ The recursive descent JS parser


  • /src/typing/ Contains the "entry point" for inference (Function called infer_ast).
  • /src/typing/ Most of the inference logic (runs through the AST and generates the initial constraints)
ryanbrainard / PromiseStateContainer.jsx
Last active Jun 21, 2019
Example PromiseStateContainer
View PromiseStateContainer.jsx
import React, { Component, PropTypes } from 'react'
import { connect, PromiseState } from 'react-refetch'
import LoadingAnimation from './LoadingAnimation'
import ErrorBox from './ErrorBox'
class PromiseStateContainer extends Component {
static propTypes = {
ps: PropTypes.instanceOf(PromiseState).isRequired,
onPending: PropTypes.func,
onNoResults: PropTypes.func,
View angular-ios9-uiwebview.patch.js
* ================== angular-ios9-uiwebview.patch.js v1.1.1 ==================
* This patch works around iOS9 UIWebView regression that causes infinite digest
* errors in Angular.
* The patch can be applied to Angular 1.2.0 1.4.5. Newer versions of Angular
* have the workaround baked in.
* To apply this patch load/bundle this file with your application and add a
xjamundx /
Last active Jul 7, 2020
From Require.js to Webpack - Part 2 (the how)

This is the follow up to a post I wrote recently called From Require.js to Webpack - Party 1 (the why) which was published in my personal blog.

In that post I talked about 3 main reasons for moving from require.js to webpack:

  1. Common JS support
  2. NPM support
  3. a healthy loader/plugin ecosystem.

Here I'll instead talk about some of the technical challenges that we faced during the migration. Despite the clear benefits in developer experience (DX) the setup was fairly difficult and I'd like to cover some of the challanges we faced to make the transition a bit easier.

robertjpayne / RCTSwiftBridgeModule.h
Last active May 18, 2020
React Native - Swift Native Modules
View RCTSwiftBridgeModule.h
#import <Foundation/Foundation.h>
#import "RCTBridgeModule.h"
#define RCT_EXTERN_MODULE(objc_name, objc_supername) \
RCT_EXTERN_REMAP_MODULE(objc_name, objc_name, objc_supername)
#define RCT_EXTERN_REMAP_MODULE(js_name, objc_name, objc_supername) \
objc_name : objc_supername \
@end \
@interface objc_name (RCTExternModule) <RCTBridgeModule> \
omegahm /
Created Apr 7, 2015
Create Gtihub labels from Bash
#!/usr/bin/env bash
# Colours picked from
# Label definitions
declare -A LABELS
# Platform
You can’t perform that action at this time.