Skip to content

Instantly share code, notes, and snippets.

View diegorodriguesvieira's full-sized avatar
🏠
Working from home

Diego Rodrigues Vieira diegorodriguesvieira

🏠
Working from home
View GitHub Profile
@diegorodriguesvieira
diegorodriguesvieira / forwardref-generics-18.ts
Created April 22, 2024 21:57 — forked from IrvingArmenta/forwardref-generics-18.ts
Example of a forward ref generic component in React 18
import React, { ForwardedRef, forwardRef, MouseEvent } from 'react';
type ClickableListProps<T> = {
items: T[];
onSelect: (
item: T,
event: MouseEvent<HTMLButtonElement, globalThis.MouseEvent>,
) => void;
};
@diegorodriguesvieira
diegorodriguesvieira / botprofile.db
Created February 16, 2022 04:12
bot profile hard mode for csgo
//----------------------------------------------------------------------------
// BotProfile.db
// Author: Justin A. Boney
// Arranged by: Chance Aldous "King" Lepatan
// This database defines bot "personalities".
// (WARNING)Dont change this bot profile or bots many not work.
//
// 2018: BOT EDITS, PROFILES, NAMES and SKILLS V2.2 BY tNzxX
// New bot names, skill and weapon trees. Aim and movement for bots should now simulate keyboard and mouse and not a controller.
// EasyBots are the Hardest bots Example Easy>Normal>Hard>Expert.
import React, { Component } from 'react';
import Typography from '@components/Typography';
import { withTranslation } from '@i18n';
class MyComponent extends Component {
render() {
const { $t } = this.props;
return(<Typography>{$t('name')}</Typography>);
}
}
import React from 'react';
import Typography from '@components/Typography';
import useTranslation from '@i18n';
function MyComponent() {
const $t = useTranslation();
return <Typography>{$t('name')}</Typography>
}
birth_date: Yup.string()
.required('Campo obrigatório')
.test('valid-date', 'Data inválida', (value) => {
return moment(value, 'DD/MM/YYYY', true).isValid();
})
import axios from 'axios';
import cloneDeep from 'lodash/cloneDeep';
const baseURL = 'http://api.heavymotors.luby.com.br/api/';
const commonConfigs = { timeout: 120000 };
const apiPublic = axios.create({
baseURL,
...commonConfigs,
});
import { DELAY_TIME } from '@constants/';
import { call, delay, fork, put, select, takeLatest } from 'redux-saga/effects';
import * as api from './api';
export const ADS_FETCH_ACTIVE_REQUEST = 'app/ads/ADS_FETCH_ACTIVE_REQUEST';
export const ADS_FETCH_ACTIVE_LOADING = 'app/ads/ADS_FETCH_ACTIVE_LOADING';
export const ADS_FETCH_ACTIVE_SUCCESS = 'app/ads/ADS_FETCH_ACTIVE_SUCCESS';
export const ADS_FETCH_INACTIVE_REQUEST = 'app/ads/ADS_FETCH_INACTIVE_REQUEST';
export const ADS_FETCH_INACTIVE_LOADING = 'app/ads/ADS_FETCH_INACTIVE_LOADING';
@diegorodriguesvieira
diegorodriguesvieira / get-initials-by-name.js
Last active July 1, 2020 22:58
Get initials from full name
export function getNameInitials(name) {
if (!name) {
return '';
}
const initials = name.split(' ').map((item) => item[0]);
if (Array.isArray(initials)) {
if (initials.length > 2) {
return `${initials[0]}${initials[initials.length - 1]}`;
@diegorodriguesvieira
diegorodriguesvieira / flatlist-hooks-pagination.js
Last active May 17, 2023 18:23
React Native Flatlist hooks pagination example
import ActivityIndicator from '@components/ActivityIndicator';
import Box from '@components/Box';
import { useNavigation } from '@react-navigation/native';
import React, { useEffect, useState } from 'react';
import { FlatList, RefreshControl } from 'react-native';
import { useDispatch, useSelector } from 'react-redux';
import * as Ducks from '../../ducks';
import Item from '../components/Item';
const VIEWABILITY_CONFIG = {
@diegorodriguesvieira
diegorodriguesvieira / CustomSlider.jsx
Created June 6, 2020 01:18 — forked from hbarcelos/CustomSlider.jsx
`react-hook-form` wrapper for Material UI Slider component
import React, { useEffect, useCallback, useState, useMemo } from 'react';
import t from 'prop-types';
import clsx from 'clsx';
import { makeStyles } from '@material-ui/core/styles';
import Box from '@material-ui/core/Box';
import Slider from '@material-ui/core/Slider';
const useStyles = makeStyles(theme => ({
sliderWrapper: {},
sliderLabel: {