Skip to content

Instantly share code, notes, and snippets.

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

Rod Kisten (Costa) oirodolfo

🏳️‍🌈
View GitHub Profile
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 / 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
@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 / 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>
// 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 / types.ts
Created November 11, 2021 19:14 — forked from ClickerMonkey/types.ts
Typescript Helper Types
// when T is any|unknown, Y is returned, otherwise N
type IsAnyUnknown<T, Y, N> = unknown extends T ? Y : N;
// when T is never, Y is returned, otherwise N
type IsNever<T, Y = true, N = false> = [T] extends [never] ? Y : N;
// when T is a tuple, Y is returned, otherwise N
// valid tuples = [string], [string, boolean],
// invalid tuples = [], string[], (string | number)[]
@oirodolfo
oirodolfo / github-metrics.svg
Created November 16, 2021 21:01 — forked from bokub/github-metrics.svg
Github Metrics
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
const text = css({
color: '$gray12',
variants: {
size: {
// corrective letter-spacing and text-indent styles
// should go here too, because they're determined by font-size.
// You could also put line-height here too, if your devs prefer
// a default line-height that works in some cases. But understand
// that line-height is also a function of line-length, so the
@oirodolfo
oirodolfo / .zshrc
Created February 10, 2022 16:43 — forked from markmur/.zshrc
Add script to package.json via command line
# Reusable bash function you can add to your ~/.zshrc or ~/.bashrc file
#
# Usage: pkg-script start "node index.js"
#
function pkg-script () {
echo $(jq --arg key "${1}" --arg val "${2}" '.scripts[$key]=$val' package.json) | jq . | > package.json
}
@oirodolfo
oirodolfo / retry-action.ts
Created February 10, 2022 16:43 — forked from markmur/retry-action.ts
TypeScript retry util helper
export interface RetryConfig {
timeout: number
max: number
}
export const retryAction = (
fn: (...args: any[]) => Promise<any>,
{ timeout, max }: RetryConfig
): Promise<any | void> => {
// Keep a count of the retries