Skip to content

Instantly share code, notes, and snippets.

View jhesgodi's full-sized avatar

Jhonatan Gonzalez jhesgodi

  • THE ICONIC
  • Sydney, Australia
View GitHub Profile
@jhesgodi
jhesgodi / Readme.md
Last active October 7, 2022 10:00
Variant Selector Lib

Variant Selector

Given a list of properties with values (aka Props), and

Given a list of conditions derivated from evaluating properties values (aka variants),

Then compute and output of the properties values that match given conditions (aka Variants that match Props values)

Example: Compute conditional classes use in TSX (tailwindcss)

Given a Button component with props

@jhesgodi
jhesgodi / vx.ts
Created September 16, 2022 09:01
Variant class names typing
// Playground Link
// https://www.typescriptlang.org/play?#code/C4TwDgpgBAaghgJwJZwHbAM4HkBmAeAFQBooAFKAXigAkB7WgawzywFslgDwI8AlCAI4BXJAggATQgD4SAMSGoAxsCS1UMqABIAggBtdUqZSgBvAFBRLUANoMoSVFAYQQtHGQC6AfgBcZWx5QEAAewBCo4hhQAJIRIVBephZWKdZI9o6kAd5+8MhomLh4dIzMbBx4pCQMhkYAPlAYwMioAOYA3MmWAL5QDU0trVB+WQyBIWERUQQIQsAAFiAJUNoYAEL0uhBoeSjoeAMOQw27Bdj4JUws7MCV1bVGfqgQAG4QCJ3dZmagkFAzc0WxgARptto4GrRgQArCDKPpQeRKFRqb6-aCxcTxKiHNoIjAgVig3QI1BCInvTo-bgrdZgnaIPa3UhGKgmKAAcmaQggHJGUF6DXZHJwcF0GF5-MFjWaRzRNJ0+mM7M0Yt0flxrRIqt0AHc4CAMBrZXivtS-poACKiKJURUkgBkUAAohx5u88CrUGoIMbBgKSF6kOqZYNtd7gKhg36jgKpPK-pdmMQoJbjFabaz-lAnZaE9BypxuIQSCzlV0bHYHE4XG5s3BpgEgqFwpEyMtnm8EMMnB4-AQAmYzeioFhULoQCWyFn2bYMjXXO4CH3-gF2gKc6ZK-PnIvPL4oJ3KQLOiPXQsPSmy1QxxOp2WGrfJ1V-lIqWYAPQfqAAOVoYT8aIoEUWghF0cRUC5KBWDgZwoAvKBxFEOEVDeKJgWgaEhCaUMjhIDBaHsYAoFcIR4IQJZgEImC4IvVgoDQKAoVheEQNYMBg3eKBdTUYi2LAXQ4AcEgFloCVP2-DhuN4picBwLi4DmQj+K2FFHAgN13gAOigABlQj0nEGSJWgKSGwYqBgSQIYsTFLTvm+L9vwAWlc5z-ggJpYzc1yHJHXSkAAL2gKgACJggwUKEVCjBWCihpQtYcR4qgULdFaFLwt0UKqRHNY5

Keybase proof

I hereby claim:

  • I am jhesgodi on github.
  • I am jhesg (https://keybase.io/jhesg) on keybase.
  • I have a public key ASBLVXOnX_JpCtIMwRbUC8RF9Rx1Ysw23Cq1_AjpMvUBCQo

To claim this, I am signing this object:

import { ApolloClient, QueryOptions, MutationOptions } from 'apollo-client';
import { DocumentNode } from 'graphql';
import { getSdk, Requester } from '.generated/schema-typedefs';
import { ApolloRequestError } from './ApolloRequestError';
export type ApolloRequesterOptions<V, R> =
| Omit<QueryOptions<V>, 'variables' | 'query'>
| Omit<MutationOptions<R, V>, 'variables' | 'mutation'>;
@jhesgodi
jhesgodi / README.md
Created June 22, 2021 01:53 — forked from exupero/README.md
Alias a domain to a local port (Mac)

I run a lot of web servers for different projects, all of them on different ports. Generally I start with port 8000 and increment from there as I spin up new servers, but it became tiresome to remember what projects were running on which ports and what the next available port was.

/etc/hosts won't let you specify a port, but a combination of aliasing 127.0.0.1 to 127.0.0.X, forwarding ports from 8000 to 80, and adding the 127.0.0.X IP under an alias in /etc/hosts did work.

This script finds the next available value of X, aliases it with ifconfig, forwards the given port to port 80 with ipfw, and adds a new entry to /etc/hosts that aliases the IP to the domain you want.

Now I can add a server alias with sudo domain-alias funproject 8000, run the web server at 127.0.0.X:8000, and load up http://funproject/ in my browser.

(Because I needed it to work on a Mac, I couldn't use iptables. ipfw seems to work, though its manpage claims it's deprecated and pfctl is the way to go. I wasn't able to figure

@jhesgodi
jhesgodi / machine.js
Last active February 26, 2021 01:43
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@jhesgodi
jhesgodi / machine.js
Last active February 25, 2021 05:04
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@jhesgodi
jhesgodi / machine.js
Last active February 25, 2021 04:11
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@jhesgodi
jhesgodi / README.md
Last active February 25, 2022 10:15
Nx Plugin - nx-watch | Run given 'commands' on every change on a watched 'sources' directory

Nx Plugin - nx-watch

Given a list of watched directories run given commands everytime there are changes.

Handy in cases when needed to run an app in watch mode to build direct/implicit dependencies on changes.

Options

  • @sources = string[] List of directories to watch
@jhesgodi
jhesgodi / zsh_to_fish.py
Created January 28, 2021 11:37 — forked from dvdbng/zsh_to_fish.py
Migrate zsh history to fish
import os
import re
def zsh_to_fish(cmd):
return (cmd.replace('&&', '; and ')
.replace('||', '; or '))
def is_valid_fish(cmd):