Skip to content

Instantly share code, notes, and snippets.

View cytronn's full-sized avatar

Arnaud Villani cytronn

View GitHub Profile
@chranderson
chranderson / nvmCommands.js
Last active March 13, 2025 14:42
Useful NVM commands
// check version
node -v || node --version
// list locally installed versions of node
nvm ls
// list remove available versions of node
nvm ls-remote
// install specific version of node
@ahem
ahem / loadimage.js
Created October 18, 2016 12:59
Load and decode images with webworker
/* global createImageBitmap */
function loadImageWithImageTag(src) {
return new Promise((resolve, reject) => {
const img = new Image;
img.crossOrigin = '';
img.src = src;
img.onload = () => { resolve(img); };
img.onerror = () => { reject(img); };
});
@beaucharman
beaucharman / git-rebase.notes.md
Last active November 1, 2017 17:52
Notes: Git rebase process
  1. git checkout <master>
  2. git merge origin <master>
  3. git checkout <feature>
  4. git rebase <master>
  5. deal with any conflicts
  6. git add .
  7. git rebase --continue
  8. git push origin <feature> --force
  9. 😎
@philbirnie
philbirnie / throttle.js
Created June 5, 2016 15:27
Throttling Function, based heavily on Underscore's but updated for ES6.
// Returns a function, that, when invoked, will only be triggered at most once
// during a given window of time. Normally, the throttled function will run
// as much as it can, without ever going more than once per `wait` duration;
// but if you'd like to disable the execution on the leading edge, pass
// `{leading: false}`. To disable execution on the trailing edge, ditto.
const throttle = function(func, wait, options) {
let timeout, context, args, result;
let previous = 0;
@paulirish
paulirish / what-forces-layout.md
Last active March 15, 2025 16:10
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.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@eligrey
eligrey / object-watch.js
Created April 30, 2010 01:38
object.watch polyfill in ES5
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/