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 / next.config.js
Last active April 2, 2025 19:15
How to copy/use node_modules assets in Next.js public folder with copy-webpack-plugin
const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
/**
*
* @param {import('webpack').Configuration} config
* @returns {import('webpack').Configuration}
@brunos3d
brunos3d / webpack.config.js
Last active July 4, 2023 05:20
Webpack load env-file using Dotenv Plugin using Nx pattern (webpack.config.js)
const { composePlugins, withNx } = require('@nx/webpack');
const Dotenv = require('dotenv-webpack');
const fs = require('fs');
const path = require('path');
// check for available env file using Nx conventions and return the path
function resolveEnvFile(basePath = __dirname) {
const envFiles = [
`.env.${process.env.NX_TASK_TARGET_CONFIGURATION}.${process.env.NX_TASK_TARGET_TARGET}`,
@brunos3d
brunos3d / wait-for-task.ts
Created July 2, 2023 22:55
Wait for Meilisearch Task
import MeiliSearch from 'meilisearch';
export type WaitForTaskOptions = {
client: MeiliSearch;
taskUid: number;
retries?: number;
retryDelay?: number;
customErrorMessage?: string;
};
const hrefMonkeyPatch = () => {
const originalCreateElement = React.createElement;
React.createElement = function createElement () {
const args = Array.prototype.slice.call(arguments);
if (!args[1]) {
args[1] = {};
}
@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

@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/}"
useEffect(() => {
// componentDidMount
}, [])
useEffect(() => {
// componentDidUpdate
}, [something, anotherThing])
useEffect(() => {
return () => {
@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)
@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 / 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: {