Skip to content

Instantly share code, notes, and snippets.

View henrique502's full-sized avatar

Henrique Schmidt henrique502

View GitHub Profile
@henrique502
henrique502 / index.tsx
Created September 11, 2022 22:10
Demo index.tx
import React from "react";
import ReactDOM from "react-dom/client";
import { ThemeProvider } from "@mui/material/styles";
import { BrowserRouter } from "react-router-dom";
import CssBaseline from "@mui/material/CssBaseline";
import { Auth0Provider } from "@auth0/auth0-react";
import { AUTHZERO_CLIENT_ID, AUTHZERO_DOMAIN } from "./env";
import theme from "./theme";
import App from "./App";
@henrique502
henrique502 / pooling.ts
Last active August 18, 2022 16:39
helpers.ts
export interface PoolParam<T> {
fn: () => Promise<T>
validate: (data: T) => boolean;
interval: number;
maxAttempts: number;
backoff?: boolean;
}
const poll = async <T>({
fn,
@henrique502
henrique502 / pagination.md
Last active June 10, 2022 18:10
Pagination Patterns

Pagination Patterns

When making an API request to a node or edge, you usually don't receive all of the results of that request in a single response. This is because some responses could contain thousands of objects so most responses are paginated by default.

Cursor-based Pagination

Cursor-based pagination is the most efficient method of paging and should always be used when possible. A cursor refers to a random string of characters which marks a specific item in a list of data. The cursor will always point to the item, however it will be invalidated if the item is deleted or removed. Therefore, your app shouldn't store cursors or assume that they will be valid in the future.

When reading an edge that supports cursor pagination, you see the following JSON response:

@henrique502
henrique502 / sonar-project.properties
Created September 24, 2021 13:06
sonar-project.properties
sonar.projectKey=demo-client-service
sonar.projectName=demo-client-service
sonar.organization=demo
sonar.projectVersion=1.0.0
sonar.host.url=https://sonarcloud.io
sonar.sources=./internal
sonar.exclusions=**/*_test.go, **/mocks/*.go
sonar.test.inclusions=**/*_test.go
sonar.go.tests.reportPaths=report.json
sonar.go.coverage.reportPaths=coverage.out
@henrique502
henrique502 / .editorconfig
Last active October 6, 2022 18:44
.editorconfig
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# http://editorconfig.org
root = true
[*]
# Change these settings to your own preference
indent_style = space
@henrique502
henrique502 / links.md
Last active August 15, 2022 22:00
newsletter base
@henrique502
henrique502 / IdentifyID.js
Created September 12, 2019 20:02
IdentifyID
const BIGINT = 20;
const INT = 10;
const SMALLINT = 5;
const BIGINT_LENGTH = 18446744073709551615;
const INT_LENGTH = 4294967295;
const SMALLINT_LENGTH = 65535;
/**
* @typedef SetIdentifyID
@henrique502
henrique502 / knex.js
Created May 8, 2019 15:31
WIP: Wallet 2.0 SQL ideia
const { knexHelper } = require('../src/helpers');
/**
* @param {import('knex')} knex
*/
const up = async (knex) => {
await knex.schema.createTable('entity', (table) => {
table.bigIncrements('id').unsigned();
table.string('name', 350).notNullable();
table.specificType('documentNumber', 'CHAR(14)').notNullable();