Skip to content

Instantly share code, notes, and snippets.

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

Matheus matheus1lva

😃
set yourself free
View GitHub Profile
import { CfnOutput } from 'aws-cdk-lib'
import * as codebuild from 'aws-cdk-lib/aws-codebuild'
import * as codepipeline_actions from 'aws-cdk-lib/aws-codepipeline-actions'
import { StackContext } from 'sst/constructs'
import { BasePipeline } from './base-pipeline'
export interface PipelineStackConfig {
readonly bitbucketOwner: string
readonly bitbucketRepo: string
readonly bitbucketConnectionArn?: string
}
/**
* “Using Javascript or Typescript, please write runnable code to solve this challenge.
You are given an array of integers of arbitrary size. The numbers in the array are in sorted order.
The numbers are incremented sequentially by one, somewhere in the sequence there is a missing number.
Write code, complete functions, that can parse such an arbitrary size array and return the missing number.
number 15 is missing here
An example array could be: [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20]
import { Visitor, Program, ImportDeclaration, ExportDeclaration, ModuleItem, ModuleDeclaration } from "@swc/core";
import { parse } from "@swc/core";
import * as path from "path";
import * as fs from "fs";
interface DebarrelPluginOptions {
include?: RegExp[];
possibleBarrelFiles?: RegExp[];
}
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":[