Skip to content

Instantly share code, notes, and snippets.

View kibebr's full-sized avatar

Vitor Leal kibebr

  • Insurance Revolution
View GitHub Profile
@paulirish
paulirish / what-forces-layout.md
Last active July 27, 2024 18:06
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
@EtienneR
EtienneR / user.js
Created January 7, 2016 23:39
XMLHttpRequest RESTful (GET, POST, PUT, DELETE)
// Get all users
var url = "http://localhost:8080/api/v1/users";
var xhr = new XMLHttpRequest()
xhr.open('GET', url, true)
xhr.onload = function () {
var users = JSON.parse(xhr.responseText);
if (xhr.readyState == 4 && xhr.status == "200") {
console.table(users);
} else {
console.error(users);
@ralfw
ralfw / layered.cs
Last active July 22, 2022 07:14
Layered design vs stratified design
using System;
using System.Linq;
namespace layered
{
class MainClass
{
public static void Main(string[] args) {
var data = new DataLayer();
var business = new BusinessLayer(data);
@andrevdm
andrevdm / Lib.hs
Created September 8, 2018 08:44
Haskell MTL and classy lenses example (ReaderT, ExceptT)
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Lib where
import Protolude
import Control.Lens.TH (makeClassy, makeClassyPrisms)
@dannypage
dannypage / twitter_font_adblock.txt
Created August 24, 2021 21:44
How to block Twitter's terrible font
# Go to uBlock's options and paste in the following under the "My Filters" tab
https://abs.twimg.com/fonts/chirp-bold-web.woff
https://abs.twimg.com/fonts/chirp-heavy-web.woff
https://abs.twimg.com/fonts/chirp-regular-web.woff
https://abs.twimg.com/fonts/v2/chirp-bold-web.woff
https://abs.twimg.com/fonts/v2/chirp-heavy-web.woff
https://abs.twimg.com/fonts/v2/chirp-medium-web.woff
https://abs.twimg.com/fonts/v2/chirp-regular-web.woff
@nsadeh
nsadeh / EventSubscription.scala
Last active February 5, 2022 23:33
Subscribing to events from another aggregate
// defining the parent entity
object Parent {
sealed trait Command
sealed trait Event
final case class State(...)
val empty: State = ???
def apply(parentId: String) = EventSourcedBehavior(
persistenceId = PersistenceId(parentId),
emptyState = empty,