Skip to content

Instantly share code, notes, and snippets.

View brunos3d's full-sized avatar
:shipit:
hunting bytes 🏹

Bruno Silva brunos3d

:shipit:
hunting bytes 🏹
View GitHub Profile
@brunos3d
brunos3d / _readme.md
Last active September 20, 2022 14:04
arrayComplement and arrayIntersection

image

@brunos3d
brunos3d / diffArrayByKey.ts
Last active September 20, 2022 13:49
Returns an array with only the unique values from given array of values that match with the specified key from the objects in the first array
export function diffArrayByKey<T, K1 extends keyof T, K2 extends T[K1]>(
one: T[],
key: K1,
two: K2[]
) {
if (!Array.isArray(two)) {
return one.slice();
}
const tlen = two.length;
@brunos3d
brunos3d / sample.mjs
Last active September 16, 2022 15:54
How to use autocomplete with zx without import statement
#!/usr/bin/env zx
/** @type {import('zx/globals')} */
@brunos3d
brunos3d / Gradient.js
Created September 3, 2022 23:05 — forked from jordienr/Gradient.js
Stripe Mesh Gradient WebGL
/*
* Stripe WebGl Gradient Animation
* All Credits to Stripe.com
* ScrollObserver functionality to disable animation when not scrolled into view has been disabled and
* commented out for now.
* https://kevinhufnagl.com
*/
@brunos3d
brunos3d / readme.md
Last active August 31, 2022 21:18
How to enable Nx template files (__tmpl__) syntax highlight for vscode

How to enable Nx template files (tmpl) syntax highlight for vscode

This gist demonstrate how to enable syntax highlight on vscode for nx template files.

The Nx template files uses EJS syntax

To enable the syntax hightlight for EJS just install this extension and add the config below to your vscode settings.json file

Addtionally you can add *__tmpl__ your .prettierignore file

@brunos3d
brunos3d / consumed-mfe.d.ts
Created August 29, 2022 21:11
How to declare federated components types with typescript module declaration
declare module 'remoteA/componentA' {
function Component(props: unknown): JSX.Element;
export default Component;
}
declare module 'remoteB/componentB' {
export type ComponentProps = {
foo: boolean;
bar?: () => void;
};
import { ComponentProps, JSXElementConstructor } from 'react';
export const provider = <C extends JSXElementConstructor<unknown>>(
provider: C,
props: Partial<ComponentProps<C>> = {}
) => [provider, props];
export const ProviderComposer = ({ providers, children }) => {
for (let i = providers.length - 1; i >= 0; --i) {
const [Provider, props] = providers[i];
import App, { AppProps, AppContext } from 'next/app';
function MyApp({ Component, pageProps }: AppProps) {
return (
<Component {...pageProps} />
);
}
MyApp.getInitialProps = async (context: AppContext) => {
return await App.getInitialProps(context); // Retrieves page's `getInitialProps`
@brunos3d
brunos3d / react-version.js
Created August 3, 2022 18:03
Inspect/Find the React version of a website
__REACT_DEVTOOLS_GLOBAL_HOOK__.renderers.forEach(r => console.log(`${r.rendererPackageName}: ${r.version}`))
/*
{
"compilerOptions": {
"baseUrl": ".",
"outDir": "build/dist",
"module": "esnext",
"target": "es6",
"lib": [
"es2019",
"dom",