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 / 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 / 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 / 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 / _readme.md
Last active September 20, 2022 14:04
arrayComplement and arrayIntersection

image

@brunos3d
brunos3d / readme.md
Last active January 6, 2023 14:42
How to declare types of federated components without the need to re-write the types of the components

How to declare types of federated components without the need to re-write the types

Given that you have the following component (ComponentA) exported from remote (remote-a) in your Webpack config:

// ...
new ModuleFederationPlugin(
  {
    name: 'remoteA',
 exposes: {
@brunos3d
brunos3d / generateCalendarUrl.ts
Last active December 5, 2022 18:57
Generate Add to Google Calendar URL
// this file is just to set the name of the gist, use just one of the functions below
export * as withLuxon from './withLuxon'
export * as withMoment from './withMoment'
export * as withDateFns from './withDateFns'
@brunos3d
brunos3d / falsy-filter(Boolean)-trick.js
Created December 13, 2022 14:38
How to quickly filter out falsy values from an array
arrayWithFalsyItems.filter(Boolean)
useEffect(() => {
// componentDidMount
}, [])
useEffect(() => {
// componentDidUpdate
}, [something, anotherThing])
useEffect(() => {
return () => {
@brunos3d
brunos3d / copy-all-envs.sh
Created January 19, 2023 20:50
A shell script that make a backup for your env files keeping the same directory structure
#!/bin/bash
input_path=$1
output_path=$2
# Find all .env files in the input path
for file in $(find "$input_path" -name "*.env"); do
# Get the file path relative to the input path
relative_path="${file#$input_path/}"
@brunos3d
brunos3d / readme-light-dark-image.md
Last active May 2, 2023 18:38
Dynamic Images for your Readme files based on GitHub theme

Your Alt Description

Images based on GitHub Theme