Skip to content

Instantly share code, notes, and snippets.

View js2me's full-sized avatar
🚙
I may be slow to respond.

Sergey S. Volkov js2me

🚙
I may be slow to respond.
View GitHub Profile
import { useEffect, useRef } from 'react';
export const useWhatCausedRender = (name, props) => {
const prevPropsRef = useRef({});
useEffect(() => {
const changes = [];
const prevProps = prevPropsRef.current;
const keySet = new Set([...Object.keys(prevProps), ...Object.keys(props)]);
keySet.forEach((key) => {
@js2me
js2me / utils.d.ts
Last active March 1, 2023 10:05
My used TypeScript advanced types
type Maybe<T> = T | null | undefined;
/**
* Позволяет переопределить тип свойства {PropertyName} у типа {T} на новое значение {NewValue}
*/
type Override<T, PropertyName extends keyof T, NewValue> = Omit<T, PropertyName> &
{ [K in keyof T]: K extends PropertyName ? NewValue : T[K] };
interface FixedLengthArray<T extends unknown, L extends number> extends Array<T> {
@js2me
js2me / copy.ts
Last active December 17, 2021 09:40
deep copy js
export const clone = <O extends unknown | unknown[]>(value: O, history?: Set<unknown>): O => {
if (value == null || typeof value !== "object") return value;
const stack = history || new WeakSet();
if (stack.has(value)) {
return value;
}
stack.add(value);
@irfaan008
irfaan008 / deepClone.js
Created August 17, 2018 20:44
Deep Copying javascript objects/properties
// Problem Statement :
// Write a function called deepClone which takes an object and creates a copy of it.
// e.g. {name: "Paddy", address: {town: "Lerum", country: "Sweden"}} -> {name: "Paddy", address: {town: "Lerum", country: "Sweden"}}
// Solution
// This file shows ability of multiple approach with their advantages and disadvantages and 2 fully tested and working approach.
// One has been written by me and another has been received from community to showcase that self written code is more concise and readable.
// Just run this file in Node Js environment to get the result.
// To run test cases, un comment method named test() in the bottom of file
# Amazon
13.125.0.0/16
13.56.0.0/14
13.230.0.0/15
18.130.0.0/16
18.144.0.0/16
18.184.0.0/15
18.194.0.0/15
18.196.0.0/15
@cecilemuller
cecilemuller / launch.json
Last active May 2, 2024 00:55
Run ts-node in VSCode Debugger
{
"version": "0.2.0",
"configurations": [
{
"name": "Example",
"type": "node",
"request": "launch",
"runtimeExecutable": "node",
"runtimeArgs": ["--nolazy", "-r", "ts-node/register/transpile-only"],
@milankorsos
milankorsos / redux-actions.ts
Last active November 10, 2022 10:58
Correct TypeScript typing example for Redux Thunk actions
import {Action, ActionCreator, Dispatch} from 'redux';
import {ThunkAction} from 'redux-thunk';
// Redux action
const reduxAction: ActionCreator<Action> = (text: string) => {
return {
type: SET_TEXT,
text
};
};
@devjin0617
devjin0617 / .manifest
Created May 19, 2017 15:15
chrome extension using a content script to access the `window` object
{
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*"],
"js": ["inject.js"],
"all_frames": true
}
],
"web_accessible_resources": [
"content.js"
@roachhd
roachhd / README.md
Last active May 7, 2024 09:08
EMOJI cheatsheet 😛😳😗😓🙉😸🙈🙊😽💀💢💥✨💏👫👄👃👀👛👛🗼🔮🔮🎄🎅👻

EMOJI CHEAT SHEET

Emoji emoticons listed on this page are supported on Campfire, GitHub, Basecamp, Redbooth, Trac, Flowdock, Sprint.ly, Kandan, Textbox.io, Kippt, Redmine, JabbR, Trello, Hall, plug.dj, Qiita, Zendesk, Ruby China, Grove, Idobata, NodeBB Forums, Slack, Streamup, OrganisedMinds, Hackpad, Cryptbin, Kato, Reportedly, Cheerful Ghost, IRCCloud, Dashcube, MyVideoGameList, Subrosa, Sococo, Quip, And Bang, Bonusly, Discourse, Ello, and Twemoji Awesome. However some of the emoji codes are not super easy to remember, so here is a little cheat sheet. ✈ Got flash enabled? Click the emoji code and it will be copied to your clipboard.

People

:bowtie: 😄