Skip to content

Instantly share code, notes, and snippets.

View tgmarinho's full-sized avatar
💻
read my blog: tgmarinho.com

Thiago Marinho tgmarinho

💻
read my blog: tgmarinho.com
View GitHub Profile
@tgmarinho
tgmarinho / useDeviceDetect.ts
Created May 11, 2023 14:23
react hook useDeviceDetect
const getMobileDetect = (userAgent: string) => {
const isAndroid = (): boolean => Boolean(userAgent.match(/Android/i))
const isIos = (): boolean => Boolean(userAgent.match(/iPhone|iPad|iPod/i))
const isOpera = (): boolean => Boolean(userAgent.match(/Opera Mini/i))
const isWindows = (): boolean => Boolean(userAgent.match(/IEMobile/i))
const isSSR = (): boolean => Boolean(userAgent.match(/SSR/i))
const isMobile = (): boolean => Boolean(isAndroid() || isIos() || isOpera() || isWindows())
const isDesktop = (): boolean => Boolean(!isMobile() && !isSSR())
return {

Senior Frontend Interview Questions

Some questions about frontend development that might be in your next job interview. The questions were formulated by @mauvieira, a super senior fullstack developer

General Frontend

  • What are the strategies we can use to optimize the performance of web applications?

    • CDNs, GraphQL (maybe) to reduce overfetching, improve backend performance, use SSR and/or SSG, lazy loading for loading assets only when it's needed, minimize and compress HTML, CSS and JS files, and optimize images by compressing and resizing them.
  • What are Web Vitals (LCP, FID, CLS)? And how are they applied in the real world?

@tgmarinho
tgmarinho / some-component.js
Created May 4, 2023 15:47
prevent memory leak using useEffect and fetch external api
import React, { useState, useEffect } from 'react';
function FetchData() {
const [data, setData] = useState(null);
const [error, setError] = useState(null);
useEffect(() => {
// Create a new AbortController instance
const abortController = new AbortController();
const signal = abortController.signal;
@tgmarinho
tgmarinho / index.js
Created April 11, 2023 12:36 — forked from ann0nip/index.js
Automate accept LinkedIn invitations 🤖
(async () => {
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
const acceptButtons = document.querySelectorAll('[aria-label*="Accept"]');
for (const acceptButton of acceptButtons) {
acceptButton.click()
await sleep(2000);
@tgmarinho
tgmarinho / arbitrumTokens.json
Created March 16, 2023 14:36
arbitrumTokens JSON
{
"name": "Arb Whitelist Era",
"timestamp": "2022-03-01T22:44:18.339Z",
"version": {
"major": 4,
"minor": 2,
"patch": 0
},
"tokens": [
{
@tgmarinho
tgmarinho / arbitrumTokens.js
Created March 16, 2023 14:35
arbitrumTokens
export const arbitrumTokens = [
{
"logoURI": "https://assets.coingecko.com/coins/images/279/thumb/ethereum.png?1595348880",
"chainId": 1,
"name": "Ethereum",
"address": "0x0000000000000000000000000000000000000000",
"symbol": "ETH",
"decimals": 18
},
{
import { gql } from "graphql-request";
// import { returningValues as genericValues } from "./payload";
import { returningValues as genericValues } from "./payload";
export interface IPage {
/** How many records should be returned on the page */
limit: number;
/** Which page should be displayed (starts with 1) */
page: number;
@tgmarinho
tgmarinho / git_submodules.md
Created January 9, 2023 18:45 — forked from gitaarik/git_submodules.md
Git Submodules basic explanation

Git Submodules basic explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of advantages of using submodules:

  • You can separate the code into different repositories.
@tgmarinho
tgmarinho / private-npm-in-gh-actions.md
Created December 22, 2022 13:01 — forked from nandorojo/private-npm-in-gh-actions.md
Use private NPM packages in your GitHub actions

1 NPM_TOKEN

Add an NPM_TOKEN secret on GitHub. Get your secret key from the NPM dashboard.

2 Add a step to your action

- name: Authenticate with private NPM package
  run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
@tgmarinho
tgmarinho / generateTokenAddressMaping.js
Created November 18, 2022 18:03
generateTokenAddressMaping
const https = require("https");
const fs = require("fs");
const SKIP_PLATFORMS = [
"tron",
"sora",
"factom",
"elrond",
"osmosis",
"cosmos",