Skip to content

Instantly share code, notes, and snippets.

View iamdustan's full-sized avatar

Dustan Kasten iamdustan

View GitHub Profile
@iamdustan
iamdustan / restore-form.js
Created November 21, 2018 17:24
Automatically saves and restores form data on a page. Written for Webflow.com custom code integration.
<script>
(() => {
const debounce = (fn) => {
let timeout;
let arg;
const later = () => {
timeout = null;
fn(arg);
arg = null;
};

Setup

Array length of 131,027 items.

let videos = [{
  "id": 65432445,
  "title": "The Chamber"
}, {
60,61c60,61
< "size": 86759,
< "gzip": 21976
---
> "size": 84835,
> "gzip": 21152
64,65c64,65
< "size": 15163,
< "gzip": 4972
---
@iamdustan
iamdustan / rollup.config.js
Created April 4, 2017 22:02
rollup with react-reason starter repo
var rollup = require('rollup').rollup;
var commonjs = require('rollup-plugin-commonjs');
var nodeResolve = require('rollup-plugin-node-resolve');
var replace = require('rollup-plugin-replace');
const entry = 'simple/simpleRoot';
const results = [];
const dest = 'bundle.js';
const ENV = 'development';
// const ENV = 'production';
@iamdustan
iamdustan / error.log
Last active December 19, 2016 18:35
Flow union functions?
result.js:17
17: callback(null, {value: Math.random()});
^^^^ null. This type is incompatible with the expected param type of
14: callback : ResultCallback<V, E>
^ Error
result.js:19
19: callback(new Error('Lolnope'));
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function call
19: callback(new Error('Lolnope'));
import scriptjs from 'scriptjs';
const scripts = {};
const withScript = (script, Comp) => {
class WithScript extends React.Component {
state = {
ready: !!scripts[script]
};
componentDidMount() {
#!/usr/bin/env node
/**
* This script will generate a JavaScript program to interact with the IBM
* Watson API. Try it out yourself!
*
* ```
* $ git clone https://gist.github.com/2e36a440b5702e14376bfba56d303427.git watson
* $ cd watson
* $ chmod +x watson.sh
* $ ./watson.sh > output.js
/* Converting https://github.com/rgrinberg/opium#hello-world to Reason */
open Opium.Std;
type person = {
name: string,
age: int,
};
let json_of_person {name, age} => Ezjsonm.(dict [("name", string name), ("age", int age)]);

Half-baked thoughts on React’s Incremental Reconciler

Both React’s incremental reconciler and Angular’s digest cycle have the property that additional work will be scheduled outside of the consumers control.

Arguably with React this has always been true and the incremental reconciler is simply another layer for scheduling work.

To date, React’s reconciler has been an implementation detail that I’ve never had to consider while developing applications. Neither have I ever heard someone

Half-baked thoughts on React’s Incremental Reconciler

Both React’s incremental reconciler and Angular’s digest cycle have the property that additional work will be scheduled outside of the consumers control.

Arguably with React this has always been true and the incremental reconciler is simply another layer for scheduling work.

To date, React’s reconciler has been an implementation detail that I’ve never had to consider while developing applications. Neither have I ever heard someone