Skip to content

Instantly share code, notes, and snippets.

View oirodolfo's full-sized avatar
🏳️‍🌈
working from home

Rod Kisten (Costa) oirodolfo

🏳️‍🌈
working from home
View GitHub Profile
// Simplistic (probably most common) approach.
// This approach assumes either that:
// 1) passive effects are always run synchronously, after paint, or
// 2) passive effects never attach handlers for bubbling events
// If both of the above are wrong (as can be the case) then problems might occur!
useEffect(() => {
const handleDocumentClick = (event: MouseEvent) => {
// It's possible that a "click" event rendered the component with this effect,
// in which case this event handler might be called for the same event (as it bubbles).
// In most scenarios, this is not desirable.
@oirodolfo
oirodolfo / index.html
Created August 20, 2021 19:44 — forked from awestbro/index.html
Highlighting margin, border, and padding with Javascript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Highlighting elements example</title>
</head>
<body>
@oirodolfo
oirodolfo / dom-to-json.js
Created August 5, 2021 17:51 — forked from sstur/dom-to-json.js
Stringify DOM nodes using JSON (and revive again)
function toJSON(node) {
let propFix = { for: 'htmlFor', class: 'className' };
let specialGetters = {
style: (node) => node.style.cssText,
};
let attrDefaultValues = { style: '' };
let obj = {
nodeType: node.nodeType,
};
if (node.tagName) {
@oirodolfo
oirodolfo / ultimate-ut-cheat-sheet.md
Created July 1, 2021 18:00 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai, Sinon, and Jest
declare module 'react-table' {
// TypeScript Version: 3.5
import { ReactNode, ComponentType, MouseEvent } from 'react';
/**
* The empty definitions of below provides a base definition for the parts used by useTable, that can then be extended in the users code.
*
* @example
* export interface TableOptions<D extends object = {}}>
@oirodolfo
oirodolfo / instagram.js
Created June 18, 2021 20:26 — forked from muminy/instagram.js
Violentmonkey instagram addition
// ==UserScript==
// @name İnstagram ext
// @namespace Violentmonkey Scripts
// @match https://www.instagram.com/*
// @grant none
// @version 1.2
// @grant GM_addStyle
// @author @mmnyldrm
// @description İnstagram yardımcı eklenti
// ==/UserScript==
@oirodolfo
oirodolfo / ig-denoiser.user.js
Created June 18, 2021 20:25 — forked from noromanba/ig-denoiser.user.js
hidden user comments on instagram.com for UserScript
// ==UserScript==
// @name IG denoiser
// @namespace https://noromanba.github.com
// @description hidden user comments on instagram.com for UserScript
// @include https://www.instagram.com/*
// @grant none
// @noframes
// @run-at document-start
// @version 2019.5.28.1
// @homepage https://gist.github.com/noromanba/1f369b316c1b43bdf0e337c6c5af1c80
@oirodolfo
oirodolfo / react-app-s3-sync.sh
Created June 15, 2021 18:06 — forked from kevindice/react-app-s3-sync.sh
A shell script for uploading a React app build to S3 + CloudFront for deployment
#!/bin/bash
S3_BUCKET_NAME=$1
CF_ID=$2
# Sync all files except for service-worker and index
echo "Uploading files to $S3_BUCKET_NAME..."
aws s3 sync build s3://$S3_BUCKET_NAME/ \
--acl public-read \
--exclude service-worker.js \
@oirodolfo
oirodolfo / useGlobalMemo.js
Created May 17, 2021 19:32 — forked from tannerlinsley/useGlobalMemo.js
useGlobalMemo is a React hook that lets you share memoizations across an entire app using a unique key.
const cache = {}
export default function useGlobalMemo (key, fn, deps) {
if (!cache[key]) {
cache[key] = {
subs: 0,
deps,
value: fn(),
}
@oirodolfo
oirodolfo / createCrudHooks.js
Created May 17, 2021 19:31 — forked from tannerlinsley/createCrudHooks.js
A naive, but efficient starter to generate crud hooks for React Query
export default function createCrudHooks({
baseKey,
indexFn,
singleFn,
createFn,
updateFn,
deleteFn,
}) {
const useIndex = (config) => useQuery([baseKey], indexFn, config)
const useSingle = (id, config) =>