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
@oirodolfo
oirodolfo / listAllEventListeners.js
Created March 24, 2023 15:20 — forked from tkafka/listAllEventListeners.js
List all event listeners in a document
console.table((function listAllEventListeners() {
const allElements = Array.prototype.slice.call(document.querySelectorAll('*'));
allElements.push(document); // we also want document events
const types = [];
for (let ev in window) {
if (/^on/.test(ev)) types[types.length] = ev;
}
let elements = [];
for (let i = 0; i < allElements.length; i++) {
@oirodolfo
oirodolfo / listAllEventListeners.js
Created March 24, 2023 15:20 — forked from dmnsgn/listAllEventListeners.js
List all event listeners in a document
const listeners = (function listAllEventListeners() {
let elements = [];
const allElements = document.querySelectorAll('*');
const types = [];
for (let ev in window) {
if (/^on/.test(ev)) types[types.length] = ev;
}
for (let i = 0; i < allElements.length; i++) {
const currentElement = allElements[i];
@oirodolfo
oirodolfo / tailwind-plugin-patcher.py
Created December 21, 2022 15:17 — forked from liautaud/tailwind-plugin-patcher.py
Small Python script to patch the IntelliJ TailwindCSS plugin.
import re
from zipfile import ZipFile, Path
"""
TailwindCSS plugin patcher for IntelliJ IDEA
--------------------------------------------
1. Download the latest ZIP of the plugin compatible with your version of IntelliJ here:
https://plugins.jetbrains.com/plugin/15321-tailwind-css/versions
2. Fill `CLASS_ATTRIBUTES` to specify which XML attributes can contain Tailwind classes.
@oirodolfo
oirodolfo / ListEvents.md
Created August 7, 2022 22:24 — forked from cmbaughman/ListEvents.md
List all events on element with vanilla Javascript
  Element.prototype._addEventListener = Element.prototype.addEventListener;
  Element.prototype.addEventListener = function(a,b,c) {
    if(c==undefined)
      c=false;
    this._addEventListener(a,b,c);
    if(!this.eventListenerList)
      this.eventListenerList = {};
    if(!this.eventListenerList[a])
function useCachedAbortiveQuery<T>(
query: DocumentNode,
variables: Record<string, unknown>,
deps: Array<any>
) {
const apolloClient = useApolloClient();
const [data, setData] = useState<T>();
const [error, setError] = useState<Error | null>(null);
const [loading, setLoading] = useState<boolean>(true);
@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
@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
}
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 / 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.
@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)[]