Skip to content

Instantly share code, notes, and snippets.

View ms-fadaei's full-sized avatar
🏠
Working from home

Mohammad Saleh Fadaei ms-fadaei

🏠
Working from home
View GitHub Profile
@ms-fadaei
ms-fadaei / EasingFunctions.json
Created January 11, 2023 10:28 — forked from gre/EasingFunctions.json
DEPRECATED Please use http://github.com/gre/bezier-easing for latest vrrsion.
{
"ease": [0.25, 0.1, 0.25, 1.0],
"linear": [0.00, 0.0, 1.00, 1.0],
"ease-in": [0.42, 0.0, 1.00, 1.0],
"ease-out": [0.00, 0.0, 0.58, 1.0],
"ease-in-out": [0.42, 0.0, 0.58, 1.0]
}
@ms-fadaei
ms-fadaei / web-vital-composable.mjs
Created April 6, 2022 09:13
A custom Vue composables to measure Web Vital metrics anywhere in your app in less than 20 lines of code.
import { ref } from 'vue'
import { getFCP, getLCP, getFID, getCLS } from "web-vitals"
export default function useWebVital() {
const fcp = ref(null)
const lcp = ref(null)
const fid = ref(null)
const cls = ref(null)
getFCP(({delta}) => fcp.value = delta)
@ms-fadaei
ms-fadaei / getTheMostRepetitiveItem.js
Created January 27, 2022 04:56
Get get The Most Repetitive Item In Array
function getTheMostRepetitiveItem(items) {
const itemCounts = items.reduce((storageObj, item) => {
storageObj[item] = storageObj[item] || 0;
storageObj[item] += 1;
return storageObj;
}, {});
const sortedItems = Object.entries(itemCounts).sort(([keyA, valA], [keyB, valB]) => valB - valA);
return sortedItems[0]?.[0];
}
@ms-fadaei
ms-fadaei / v8-help.md
Last active December 30, 2023 08:56
V8 JavaScript engine options and flags v9.9.47

If you want to run V8 on your local machine, please use jsvu

interpreters/compilers

  • Ignition: V8 features an interpreter called Ignition. Ignition is optimized to make code run as soon as possible. Ignition converts js code to bytecode
  • Liftoff: V8 has a streaming Wasm compiler called Liftoff which, like Ignition, is geared to get your code running quickly, at the cost of generating potentially suboptimal execution speed.
  • Sparkplug: Sparkplug takes Ignition’s output (the infamous “bytecode”) and turns it into non-optimized machine code, yielding better performance at the cost of increased memory footprint.
  • TurboFan: TurboFan is one of V8’s optimizing compilers leveraging a concept called “Sea of Nodes”. Once sufficient data has been collected, TurboFan kicks in and generates low-level machine code that
@ms-fadaei
ms-fadaei / debug-ttfb.js
Created June 22, 2021 13:10
Debug TTFB Like Google
/*
//
// With this file, you can debug the TTFB
// and figure out what's going on
//
// Install dependecies: npm i web-vitals
//
// Use it like this:
// Import {getRDT, getBC, getDNS, getHS, getREQ} from "./debug-ttfb.js";
// getDNS(console.log); // see: https://github.com/GoogleChrome/web-vitals#usage