Skip to content

Instantly share code, notes, and snippets.

View diegomais's full-sized avatar
💭
The only way to go fast, is to go well.

Diego Mais diegomais

💭
The only way to go fast, is to go well.
View GitHub Profile
@diegomais
diegomais / .gitconfig
Last active February 20, 2023 20:47
Set Git global options
[color]
ui = true
[color "branch"]
current = white
remote = red
[color "diff"]
meta = yellow
old = red
new = green
[color "status"]
@diegomais
diegomais / cursorPagination.ts
Created November 17, 2022 14:05 — forked from VojtaSim/cursorPagination.ts
TypeORM + TypeGraphQL cursor pagination
import { ObjectType, Field, ClassType, Int, ArgsType } from 'type-graphql';
import { SelectQueryBuilder } from 'typeorm';
import Cursor, { TCursor } from 'scalar/cursor';
@ArgsType()
export class CursorPaginationArgs {
@Field({ nullable: true })
after?: TCursor;
@diegomais
diegomais / page-info.ts
Created June 29, 2022 21:55 — forked from tumainimosha/page-info.ts
NestJS Graphql Cursor Based pagination
import { ObjectType, Field } from "@nestjs/graphql";
@ObjectType()
export class PageInfo {
@Field({ nullable: true })
startCursor: string;
@Field({ nullable: true })
endCursor: string;
@diegomais
diegomais / SearchBar.js
Created April 15, 2021 21:00
SearchBar with onChangeDebounce
import React from 'react';
import PropTypes from 'prop-types';
let timeout;
const SearchBar = ({placeholder, buttonLabel, inputDelay, onChange, onButtonClick}) => {
const onChangeDebounce = (evt) => {
timeout && clearTimeout(timeout);
const target = evt.target;
timeout = setTimeout(() => onChange({target}), inputDelay);
@diegomais
diegomais / script.js
Created January 31, 2021 20:43
Reverse the formatting by Intl.NumberFormat in JavaScript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Intl.NumberFormat</title>
<script type="text/javascript" charset="UTF-8" src="script.js"></script>
</head>
<body>
<output id=output></output>
@diegomais
diegomais / filterArraysByKey.js
Created January 22, 2021 17:39
Filter by object key an array containing objects based on another array containing objects in JavaScript without ES6
function filterArraysByKey (arr1, arr2, key) {
var result = [];
result = arr1.filter(function (el) {
var res = true;
for (var i = arr2.length - 1; i >= 0; i--) {
if (arr2[i][key] === el[key]) {
res = false;
break;
}
}
@diegomais
diegomais / UnsplashFeed.jsx
Created January 8, 2021 18:26
Infinite scroll/Paginating Flatlist by @diegomais
import Unsplash, { toJson } from 'unsplash-js'
const unsplashInstance = new Unsplash({
secret: 'Your secret here',
accessKey: 'Your accessKey here',
})
const UnsplashFeed = () => {
const [error, setError] = useState()
const [isFetching, setIsFetching] = useState(true)
@diegomais
diegomais / fetchPhotos.js
Created January 8, 2021 17:02
Infinite scroll/Paginating Flatlist by @srbkrishnan
import Unsplash, { toJson } from 'unsplash-js';
const unsplashInstance = new Unsplash({
secret: 'Your secret here',
accessKey: 'Your accessKey here',
});
async function fetchPhotos(keyword, page, limit = 10) {
const photoResult = await unsplashInstance.search
.photos(keyword, page, limit)
@diegomais
diegomais / metatags.html
Created October 9, 2020 21:04 — forked from diego3g/metatags.html
Meta tags do curso de Next.js
<meta httpEquiv="x-ua-compatible" content="IE=edge,chrome=1" />
<meta name="MobileOptimized" content="320" />
<meta name="HandheldFriendly" content="True" />
<meta name="theme-color" content="#121214" />
<meta name="msapplication-TileColor" content="#121214" />
<meta name="referrer" content="no-referrer-when-downgrade" />
<meta name="google" content="notranslate" />
<meta property="og:title" content={pageTitle} />
<meta property="og:description" content={description} />
@diegomais
diegomais / Dockerfile
Created September 13, 2020 23:57
React
FROM node:12 AS build
WORKDIR /app
COPY package* yarn.lock ./
RUN yarn install
COPY public ./public
COPY src ./src
RUN yarn run build
FROM nginx:alpine
COPY --from=build /app/build /usr/share/nginx/html