Skip to content

Instantly share code, notes, and snippets.

View ra-kesh's full-sized avatar

Rakesh ra-kesh

View GitHub Profile
@ra-kesh
ra-kesh / react-performance.md
Created September 4, 2023 04:58 — forked from mathesond2/react-performance.md
Notes From Steve Kinney's "React Performance" Frontend Masters Course

React Performance

Notes From Steve Kinney's "React Performance" Frontend Masters Course

General

re: optimizations: "Start with a problem first, then solve it. dont go looking for problems."

"measure first before you optimize for performance. And then measure again."

import type { ComponentType } from "react"
import styled from "@emotion/styled"
const GradientBlur = styled.div`
user-select: none;
pointer-events: none;
position: fixed;
top: 0px;
left: 0px;
function walkDOMTree(
root,
whatToShow = NodeFilter.SHOW_ALL,
{ inspect, collect, callback } = {}
) {
const walker = document.createTreeWalker(root, whatToShow, {
acceptNode(node) {
if (inspect && !inspect(node)) {
return NodeFilter.FILTER_REJECT;
}
@ra-kesh
ra-kesh / backendgist.md
Last active December 12, 2022 08:02
Backend Must To know things
  • Relational Databases
    • Creating, Altering, Dropping Tables
      • Primary and Secondary Keys
      • Adding Relationships Between Two Tables using Foreign Key
      • UNIQUE, DEFAULT, NOT NULL constraints
    • Inserting, Updating, Deleting Rows in a Table
    • Fetching data with SELECT queries
      • Filtering and Sorting
      • Aggregations
  • Optimizations using *
@ra-kesh
ra-kesh / useCarousel.ts
Created June 10, 2022 11:34 — forked from FlorianRappl/useCarousel.ts
The generic useCarousel hook.
import { useReducer, useEffect } from 'react';
import { useSwipeable, SwipeableHandlers, EventData } from 'react-swipeable';
function previous(length: number, current: number) {
return (current - 1 + length) % length;
}
function next(length: number, current: number) {
return (current + 1) % length;
}
@ra-kesh
ra-kesh / getDates.js
Created March 27, 2022 09:20 — forked from miguelmota/getDates.js
Get dates in between two dates with JavaScript.
// Returns an array of dates between the two dates
function getDates (startDate, endDate) {
const dates = []
let currentDate = startDate
const addDays = function (days) {
const date = new Date(this.valueOf())
date.setDate(date.getDate() + days)
return date
}
while (currentDate <= endDate) {
@ra-kesh
ra-kesh / what-forces-layout.md
Created March 10, 2022 06:48 — 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.

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
@ra-kesh
ra-kesh / composing-software.md
Created November 12, 2021 04:44 — forked from Geoff-Ford/composing-software.md
Eric Elliott's Composing Software Series

Eric Elliott's "Composing Software" Series

A collection of links to the excellent "Composing Software" series of medium stories by Eric Elliott.

Edit: I see that each post in the series now has index, previous and next links. However, they don't follow a linear flow through all the articles with some pointing back to previous posts effectively locking you in a loop.

@ra-kesh
ra-kesh / master-javascript-interview.md
Created November 12, 2021 04:40 — forked from Geoff-Ford/master-javascript-interview.md
Eric Elliott's Master the JavaScript Interview Series
@ra-kesh
ra-kesh / hbqc.py
Created July 25, 2021 03:37 — forked from iexa/hbqc.py
Python script to create a handbrake encoding queue for a tree of files using a built-in json template
#!/usr/bin/env python3
"""
Handbrake (json) Queue Creator
last updated: 2021/jul/15 iexa
changelog:
- 21/jul/15: added rotation check
- 21/jun/23: added ffmpeg automatic resolution sniffing
"""
import argparse