Skip to content

Instantly share code, notes, and snippets.

@Risto-Stevcev
Risto-Stevcev / what-forces-layout.md
Created June 22, 2018 07:16 — 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()
@Risto-Stevcev
Risto-Stevcev / test.ml
Created July 31, 2018 15:51 — forked from infinity0/test.ml
OCaml GADTs and avoiding "type constructor would escape its scope" errors
(* GADT list that exposes the type of the head element *)
type _ hlist =
| Nil: 'a hlist
| Cons: ('a * 'b hlist) -> 'a hlist
(* let rec len = function *)
(* let rec len (type a) (l: a hlist): int = match l with *)
(* both of the above result in a "type constructor would escape its scope" error *)
(* correct version: *)
let rec len : type a. a hlist -> int = function
@Risto-Stevcev
Risto-Stevcev / categories.hs
Created March 13, 2019 21:02
Is everything just a monoid in the category of something?
(.) :: (b -> c) -> (a -> b) -> (a -> c) -- functions
(.) :: cat b c -> cat a b -> cat a c -- categories
(++) :: String -> String -> String -- strings
(<>) :: a -> a -> a -- monoids
(<>) :: cat a a -> cat a a -> a a -- categories
(++) :: [a] -> [a] -> [a] -- lists
(<|>) :: f a -> f a -> f a -- alternatives
(<|>) :: cat a a -> cat a a -> a a -- categories
@Risto-Stevcev
Risto-Stevcev / esm-package.md
Created June 2, 2023 03:36 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@Risto-Stevcev
Risto-Stevcev / ANSI.md
Last active June 2, 2023 03:43 — forked from fnky/ANSI.md
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@Risto-Stevcev
Risto-Stevcev / suckless-st-sixel.diff
Created June 19, 2023 13:48 — forked from saitoha/suckless-st-sixel.diff
Add SIXEL graphics support for suckless st. (sixel.c/sixel_hls.c come from mintty, licensed under GPL)
commit ea830e03d4d4562b1ff225940f65bceddd9cad6c
Author: Hayaki Saito <[email protected]>
Date: Sun Jun 11 23:46:45 2017 +0900
Add sixel graphics support
Signed-off-by: Hayaki Saito <[email protected]>
diff --git a/Makefile b/Makefile
index d8595fe..a25d040 100644