Skip to content

Instantly share code, notes, and snippets.

View cyan33's full-sized avatar
🖤
EqualityMatters

Chang Yan cyan33

🖤
EqualityMatters
View GitHub Profile
@sebmarkbage
sebmarkbage / WhyReact.md
Created September 4, 2019 20:33
Why is React doing this?

I heard some points of criticism to how React deals with reactivity and it's focus on "purity". It's interesting because there are really two approaches evolving. There's a mutable + change tracking approach and there's an immutability + referential equality testing approach. It's difficult to mix and match them when you build new features on top. So that's why React has been pushing a bit harder on immutability lately to be able to build on top of it. Both have various tradeoffs but others are doing good research in other areas, so we've decided to focus on this direction and see where it leads us.

I did want to address a few points that I didn't see get enough consideration around the tradeoffs. So here's a small brain dump.

"Compiled output results in smaller apps" - E.g. Svelte apps start smaller but the compiler output is 3-4x larger per component than the equivalent VDOM approach. This is mostly due to the code that is usually shared in the VDOM "VM" needs to be inlined into each component. The tr

The Challenge

Compare two (or more) tools that are trying to solve a similar set of problems, without discussing any of the following:

  • Community
  • Programming Language
  • Documentation/Examples/Demos/etc
  • Stars/Forks/Downloads/Issues/PRs/Stack Overflow Answers/etc
  • Age/Maturity of tool
const createLogger = (backgroundColor, color) => {
const logger = (message, ...args) => {
if (logger.enabled === false) {
return;
}
console.groupCollapsed(
`%c${message}`,
`background-color: ${backgroundColor}; color: ${color}; padding: 2px 4px;`,
...args
@EnixCoda
EnixCoda / NodeJS.v.10.7.0.md
Last active November 1, 2018 19:16
safe-touch benchmark, MacBookPro 2015 15'
***********************************************************
try...catch VS safe-touch
Will run 100,000 times for each test case.

Will test with these retrieve methods:
  function impossibleRetrieve(_) { return _[Math.random()][Math.random()] }
  function shallowRetrieve(_) { return _.key }
  function deepRetrieve(_) { return _.a.b.c.d.e.f.g.h.i }
@gaearon
gaearon / prepack-gentle-intro-1.md
Last active May 3, 2024 12:56
A Gentle Introduction to Prepack, Part 1

Note:

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.
@treyhuffine
treyhuffine / PromiseSimpleExample.js
Last active March 27, 2021 19:44
An example using a simple promise implementation
class PromiseSimple {
constructor(executionFunction) {
this.promiseChain = [];
this.handleError = () => {};
this.onResolve = this.onResolve.bind(this);
this.onReject = this.onReject.bind(this);
executionFunction(this.onResolve, this.onReject);
}
@schabluk
schabluk / indexOfNode.js
Created May 16, 2017 12:37
Getting index of node in HTMLCollection
const children = [].slice.call(this.snippetsList.node.children)
console.log(
data.node,
children.indexOf(data.node)
)
@yossorion
yossorion / what-i-wish-id-known-about-equity-before-joining-a-unicorn.md
Last active April 7, 2024 22:55
What I Wish I'd Known About Equity Before Joining A Unicorn

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

Thanks everyone for participating in the quiz!
Many of you have posted correct answers.

What we know:

A top-level App component returns <Button /> from its render() method.

Question:

>What is the relationship between `` and this in that `Button`’s `render()`?

@giacomorebonato
giacomorebonato / server.js
Created September 29, 2016 11:55
simple ExpressJS spa
const express = require('express')
const bodyParser = require('body-parser')
const path = require('path')
const app = express()
// assets. Static JS, CSS, fonts
app.use('/public', express.static(path.join(__dirname, '../public')))
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())