Skip to content

Instantly share code, notes, and snippets.

View mtsknn's full-sized avatar
😎

Matias Kinnunen mtsknn

😎
View GitHub Profile
@jkumara
jkumara / move0.js
Created August 31, 2023 08:46
Move all zeros of the array to the end while maintaining the relative order of all non-zeros.
/**
* Given an array of integers, move all zeros of the array to the end while
* maintaining the relative order of all non-zeros.
*
* Example:
*
* $ move0([1,3,0,111,57,0,5,0,9])
* $ [1,3,111,57,5,9,0,0,0]
*/
@peerreynders
peerreynders / reactIsAFramework.md
Last active August 22, 2024 08:46
React is a (view component) framework

"Art prior" to React:

Martin Fowler: InversionOfControl (2005-Jun-26)

Inversion of Control is a key part of what makes a framework different to a library. A library is essentially a set of functions that you can call, these days usually organized into classes. Each call does some work and returns control to the client.

A framework embodies some abstract design, with more behavior built in. In order to use it you need to insert your behavior into various places in the framework either by subclassing or by plugging in your own classes. The framework's code then calls your code at these points.

The litmus test:

  • If your code calls it, it's a library.
@paulirish
paulirish / what-forces-layout.md
Last active October 21, 2025 12:35
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