Skip to content

Instantly share code, notes, and snippets.

View StoneCypher's full-sized avatar

John Haugeland StoneCypher

View GitHub Profile
#!/usr/bin/env bash
#
# Copyright (c) 2016-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
set -e
@maccesch
maccesch / CytoscapeDotLayout.ts
Created November 7, 2018 11:11
cytoscape.js dot layout using viz.js
import Viz from 'viz.js';
import {Module, render} from 'viz.js/full.js.opaque';
function CytoscapeDotLayout(options) {
this.options = options;
}
CytoscapeDotLayout.prototype.run = function () {
let dotStr = 'digraph G {';
@StoneCypher
StoneCypher / Toy react bootstrap from CDN.html
Last active January 8, 2018 05:57
Toy react bootstrap from CDN for Francisco
<!doctype html>
<html>
<head>
<script src="https://fb.me/react-15.0.0.js"></script>
<script src="https://fb.me/react-dom-15.0.0.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.34/browser.min.js"></script>
<script type="text/babel">
@StoneCypher
StoneCypher / .babelrc
Created October 13, 2017 17:32
fuller build setup
{
"plugins" : ["transform-flow-strip-types"],
"presets" : ["es2015", "react"],
"sourceMaps" : "inline"
}
@Rich-Harris
Rich-Harris / imperative-v-declarative-imports.md
Last active May 6, 2024 10:23
Why imperative imports are slower than declarative imports

Why imperative imports are slower than declarative imports

A lot of people misunderstood Top-level await is a footgun, including me. I thought the primary danger was that people would be able to put things like AJAX requests in their top-level await expressions, and that this was terrible because await strongly encourages sequential operations even though a lot of the asynchronous activity we're talking about should actually happen concurrently.

But that's not the worst of it. Imperative module loading is intrinsically bad for app startup performance, in ways that are quite subtle.

Consider an app like this:

// main.js
'use strict';
const theGlobal = typeof window === 'object' ? window : global;
const realPromiseConstructor = theGlobal.Promise;
const wrappedPromiseConstructor = function (resolve, reject, progress) {
const originalPromiseInstance = new realPromiseConstructor(resolve, reject, progress);
// Who called us? Let's store it.
@Gaafar
Gaafar / curryExample.js
Last active January 7, 2018 23:24
ES6 Currying Example
function add (x, y) {return x+y}
let curry = (f, ...args) => f.bind.apply(f,[null, ...args])
let add4 = curry(add,4)
console.log(add4(5)) //9
let add4n6 = curry(add4,6)
console.log(add4n6()) //10
// this is the react app. it knows nothing of the vanilla app, other than that the information
// will come in in props, and that it should call this hook when this button is pressed, or etc
var Spinner = (props) =>
<div>
{this.props.data}
<button value="↑" onclick={this.props.hooks.inc}/>
<button value="↓" onclick={this.props.hooks.dec}/>
</div>;
@mondain
mondain / public-stun-list.txt
Last active July 22, 2024 14:09
Public STUN server list
23.21.150.121:3478
iphone-stun.strato-iphone.de:3478
numb.viagenie.ca:3478
s1.taraba.net:3478
s2.taraba.net:3478
stun.12connect.com:3478
stun.12voip.com:3478
stun.1und1.de:3478
stun.2talk.co.nz:3478
stun.2talk.com:3478
var counter = 0,
repaint = () => React.render(document.body, <Spinner data={counter}/>),
inc = () => { counter += 1, repaint() },
dec = () => { counter -= 1, repaint() },
Spinner = React.createClass({
render: function() {