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 / adjascent_state.js
Last active September 16, 2023 00:39
adjascent_state.js
const estados = [
{ name: 'Alabama', abbreviation: 'AL', id: 1 },
{ name: 'Alaska', abbreviation: 'AK', id: 2 },
{ name: 'American Samoa', abbreviation: 'AS', id: 3 },
{ name: 'Arizona', abbreviation: 'AZ', id: 4 },
{ name: 'Arkansas', abbreviation: 'AR', id: 5 },
{ name: 'California', abbreviation: 'CA', id: 6 },
{ name: 'Colorado', abbreviation: 'CO', id: 7 },
{ name: 'Connecticut', abbreviation: 'CT', id: 8 },
{ name: 'Delaware', abbreviation: 'DE', id: 9 },
-- SHIFT 1
-- Inserir o turno (shift)
INSERT INTO shifts (facility_id, certification_id, recurring_type_id, start_date, end_date, is_active, shift_timecode_id, shift_incentive_hourly, shift_bonus, shift_assignment_type, created_by, first_occurrence_starts, first_occurrence_ends, created_at, updated_at, deleted_at, shift_type, state_id)
VALUES
(213, 3, 1, '2023-08-01 14:00:00-04', '2023-08-01 22:00:00-04', true, 6, NULL, 0.0, 1, 1612, '2023-07-30 06:00:00-04', '2023-07-30 06:00:00-04', '2023-07-30 06:00:00-04','2023-07-30 06:00:00-04', NULL, 1, 51)
RETURNING id;
-- Inserir a inst芒ncia de turno (shift_instance)
module.exports = {
up: function (queryInterface, Sequelize) {
return Promise.all([
queryInterface.addColumn('User', 'name', {
type: Sequelize.STRING
}),
queryInterface.addColumn('User', 'nickname', {
type: Sequelize.STRING,
})
]);
@tgmarinho
tgmarinho / settings.json
Last active February 7, 2024 12:32
vscode settings
{
"emmet.syntaxProfiles": {
"javascript": "jsx"
},
"workbench.startupEditor": "newUntitledFile",
"editor.fontSize": 16,
"javascript.suggest.autoImports": true,
"javascript.updateImportsOnFileMove.enabled": "always",
"editor.rulers": [
80,
@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
},
{