Skip to content

Instantly share code, notes, and snippets.

View camsong's full-sized avatar
🤖
GPTing

Cam Song camsong

🤖
GPTing
View GitHub Profile
@camsong
camsong / what-forces-layout.md
Created October 25, 2017 16:00 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@camsong
camsong / cloudSettings
Created October 22, 2017 14:07
Visual Studio Code Settings Sync Gist
{"lastUpload":"2017-10-22T14:07:53.099Z","extensionVersion":"v2.8.3"}
function createStore(reducer, initialState) {
let currentState = initialState;
let listeners = [];
function subscribe(listener) {
listeners.push(listener);
const isSubscribed = true;
return function unsubscribe() {
if (!isSubscribed) return
isSubscribed = false
@camsong
camsong / frp.md
Created January 12, 2016 06:11 — forked from ohanhi/frp.md
Learning FP the hard way: Experiences on the Elm language

Learning FP the hard way: Experiences on the Elm language

by Ossi Hanhinen, @ohanhi

with the support of Futurice 💚.

Licensed under CC BY 4.0.

Foreword

@camsong
camsong / gist:c129c670fc8911065df5
Created December 28, 2015 08:22 — forked from chenglou/gist:40b75d820123a9ed53d8
Thoughts on Animation

Interesting part (unmounting & API) is at the end if you're not interested in the rest =).

Stress Tests

This animation proposal is just an attempt. In case it doesn't work out, I've gathered a few examples that can test the power of a future animation system.

  1. Parent is an infinitely spinning ball, and has a child ball that is also spinning. Clicking on the parent causes child to reverse spinning direction. This tests the ability of the animation system to compose animation, not in the sense of applying multiple interpolations to one or more variables passed onto the child (this should be trivial), but in the sense that the parent's constantly updating at the same time as the child, and has to ensure that it passes the animation commands correctly to it. This also tests that we can still intercept these animations (the clicking) and immediately change their configuration instead of queueing them.

  2. Typing letters and let them fly in concurrently. This tests concurrency, coordination of an array of ch

@camsong
camsong / Snowfall.markdown
Created December 21, 2015 07:08
Snowfall

Snowfall

Just trying to create a snowfall effect using SVG and CSS animations. JavaScript is used to simply randomize the location of the snowflakes. Full warning: works in Chrome, Safari, Firefox and later versions of Opera. Internet Explorer (up to and including 11) doesn't seem to like it.

A Pen by Chip Cullen on CodePen.

License.

// require 'css'
{
submit: "_957ii",
disabledSubmit: "_1F9px"
}
/* style.css */
.className {
color: green;
}
/* form.css */
.submit {
}
@camsong
camsong / moment-immutable.js
Created October 25, 2015 03:17 — forked from timrwood/moment-immutable.js
Immutable Moments
(function (root, factory) {
"use strict";
if (typeof define === 'function' && define.amd) {
define(['moment'], factory);
} else if (typeof exports === 'object') {
module.exports = factory(require('moment'));
} else {
factory(root.moment);
}
}(this, function (moment) {
@camsong
camsong / immutable-libraries.md
Created October 6, 2015 03:05 — forked from jlongster/immutable-libraries.md
List of immutable libraries

A lot of people mentioned other immutable JS libraries after reading my post. I thought it would be good to make a list of available ones.

There are two types of immutable libraries: simple helpers for copying JavaScript objects, and actual persistent data structure implementations. My post generally analyzed the tradeoffs between both kinds of libraries and everything applies to the below libraries in either category.

Libraries are sorted by github popularity.

Persistent Data Structures w/structural sharing