Skip to content

Instantly share code, notes, and snippets.

View simonkberg's full-sized avatar
:shipit:

Simon Kjellberg simonkberg

:shipit:
View GitHub Profile
export const flatten = list => list.reduce(
(a, b) => a.concat(Array.isArray(b) ? flatten(b) : b), []
)
@simonkberg
simonkberg / reactiflux-qa.md
Last active April 4, 2018 20:25
Q&A with Sophie Alpert (@sophiebits) on Reactiflux 2016-06-09

Q: Are there plans to support a web worker based rendered in React Core ? Angular2 has support for it in core - axemclion
A: right now we're not considering web workers in depth because it's difficult to carve off pieces that can be parallelized independently -- simply moving React to a separate thread while executing DOM operations on the main thread would free up the main thread but likely wouldn't improve responsiveness overall. so instead we're looking more at how we can do concurrent work on the main thread and cancel in-progress updates if new high-priority input arrives
we might experiment a little more with threads/workers on React Native, but that would likely be more along the lines of running parts of Relay in a separate thread since it's still hard to split up the component tree

Q: did you ever think you’d be learning about fibers and coroutines to implement a JavaScript UI library? 😃 - iamdustan
A: can't say I ever considered it, but I suppose I didn't expect that I wou

Keybase proof

I hereby claim:

  • I am simonkberg on github.
  • I am simonkberg (https://keybase.io/simonkberg) on keybase.
  • I have a public key ASBwCZYmdNaMl6HEZd6yo-X8Oclvru7nz9TKVlzSqVCMugo

To claim this, I am signing this object:

@simonkberg
simonkberg / RouterContainer.js
Last active June 21, 2016 10:29
`withRouter` as a Container Component
import React from 'react'
import { routerShape } from 'react-router'
import PresentationalComponent from './PresentationalComponent'
const RouterContainer = (props, context) =>
<PresentationalComponent router={context.router} />
RouterContainer.contextTypes = {
router: routerShape
}
@simonkberg
simonkberg / animationFrame.js
Created July 22, 2016 13:59
Simple helper for working with requestAnimationFrame
import raf from 'raf'
export default function animationFrame (fn) {
let frame = {
id: 0,
cancel () {
raf.cancel(this.id)
},
}
class BinaryTree {}
class EmptyBinaryTree extends BinaryTree {
isEmpty () { return true }
depth () { return 0 }
count () { return 0 }
inorder (fn) {}
preorder (fn) {}
postorder (fn) {}
contains (x) { return false }
fallocate -l 1G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
sysctl vm.swappiness=10
sysctl vm.vfs_cache_pressure=50
echo 'vm.swappiness = 10' | sudo tee -a /etc/sysctl.conf
echo 'vm.vfs_cache_pressure = 50' | sudo tee -a /etc/sysctl.conf
import React, { Component } from 'react'
import classNames from 'classnames'
import styles from './Styles.css'
// Constant with scroll offset to trigger sticky
const SCROLL_OFFSET = 100
class ComponentThatNeedsScrollHandling extends Component {
state = { sticky: false }
ticking = false
// @flow strict
class Node<K> {
key: K
next: Node<K> | null
prev: Node<K> | null
constructor(key: K) {
this.key = key
}
(function(win, doc, version, onError, onUnhandledRejection, sentry) {
var SENTRY_SDK = win.SENTRY_SDK;
var queue = function(exception) {
queue.data.push(exception);
};
queue.data = [];
win[sentry] = function() {
var SDK = win.Sentry;