Skip to content

Instantly share code, notes, and snippets.

View matheus1lva's full-sized avatar
😃
set yourself free

Matheus Gonçalves da Silva matheus1lva

😃
set yourself free
View GitHub Profile
const baseName = "SOME_CONSTANT_NAME_FOR_THIS"
const repository = new Repository(this, `${baseName}Repository`, {
repositoryName: snakeCase(`${baseName}Repository`),
});
const logGroup = new LogGroup(this, `${baseName}LogGroup`, {
retention: 90,
logGroupName: '/aws/ecs/graphql-api',
});
QUERY PLAN |
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Aggregate (cost=6806492.29..6806492.30 rows=1 width=32) (actual time=4573.820..4573.837 rows=1 loops=1) |
Output: COALESCE(json_agg(row_to_json((SubPlan 2))), '[]'::json)
module.exports = {
// ...
resolve: {
alias: {
'react-router': path.resolve(__dirname, './node_modules/react-router'),
},
},
}
@matheus1lva
matheus1lva / gist:2efb09a9bffe2b0998acdee0168c0340
Created September 10, 2021 18:53
find files and run lint and tests based on only files that changed
#!/usr/bin/node
/* eslint-disable @typescript-eslint/no-unused-expressions */
// eslint-disable-next-line import/no-extraneous-dependencies
const sh = require('shell-tag');
const detectChangedFiles = () => {
const appFolders = ['routes', 'pages', 'modules', 'hooks'];
const changedFiles = sh`git diff develop --name-only`;
return changedFiles.split(/\n/g).filter((file) => {
/**
* 1. Fetch on render - render on useEffect/constructor
* 2. Not using a fetch which is suspense ready/has suspense features (swr, react-query, or even a wrapper on top of fetch)
* 3. Not using fallback for loading state on wrappers for the request
* 4. Error handling > create a custom error boundary to catch problems when we are rendering and while fetching!
*/
const fetcher = (url) => fetch(url).then((r) => r.json());
const SuspensefulUserProfile = ({ userId }) => {
const { data } = someSuspenseReadyFetcher(userId);
@matheus1lva
matheus1lva / index.js
Created February 11, 2021 14:45
webpack-polyfilling
// 1.:
module.exports = {
entry: './src/index.js'
}
// index.js
fetch = myFetch
{
"jsonstream":[
"examples",
"tests"
],
"agent-base":[
"tests"
],
"ansicolors":[
module.exports = {
...
plugins: [
new webpack.DefinePlugin({
__DEV__: JSON.stringify(process.MY_ENV_VARIABLE)
}),
]
}
@matheus1lva
matheus1lva / index.js
Created January 22, 2019 12:04
code splitting/dynamic import
// generates a single file for your component.js
// only when used.
// This returns a promise, which needs to be resolved.
import('./components/component.js')
// creates a chunk for each file inside your components folder
// This is called require context (which require.context is used under the hood)
// Webpack is smart enough to do that for you!
const myComponents = (componentName) => import(`./components/${componentName}.js`)
@matheus1lva
matheus1lva / webpack.config.js
Created January 22, 2019 11:52
webpack future Emit strategy
module.exports = {
// ...
output: {
futureEmitAssets: true
}
}