Skip to content

Instantly share code, notes, and snippets.

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

Carmelo Ricarte Rocamora CarmeloRicarte

🏠
Working from home
  • Murcia, Spain
  • 20:40 (UTC +01:00)
View GitHub Profile
@CarmeloRicarte
CarmeloRicarte / configurar-node-ts.md
Created September 26, 2023 07:20 — forked from Klerith/configurar-node-ts.md
Node con TypeScript - TS-Node-dev simplificado

Node con TypeScript - TS-Node-dev (preferido)

  1. Instalar TypeScript y demás dependencias
npm i -D typescript @types/node ts-node-dev rimraf
  1. Inicializar el archivo de configuración de TypeScript ( Se puede configurar al gusto)
npx tsc --init --outDir dist/ --rootDir src
@CarmeloRicarte
CarmeloRicarte / time-since.ts
Created January 23, 2023 16:48 — forked from Klerith/time-since.ts
Fecha de creación humana
export const timeSince = ( date: string ) => {
const baseDate = new Date(date)
const seconds = Math.floor(( new Date().getTime() - baseDate.getTime() ) / 1000);
let interval = seconds / 31536000;
@CarmeloRicarte
CarmeloRicarte / renderWithProviders.js
Created December 20, 2022 10:44 — forked from hjumeau/renderWithProviders.js
A simple test helper - store provider for react-testing-library
import { render, RenderOptions } from '@testing-library/react';
import React from 'react';
import { Provider } from 'react-redux';
import { store } from '../../store';
const Providers: React.FC = ({ children }) => {
return (
<Provider store={store}>
{children}
</Provider>
@CarmeloRicarte
CarmeloRicarte / vite-testing-config.md
Created November 3, 2022 08:14 — forked from Klerith/vite-testing-config.md
Vite + Jest + React Testing Library - Configuraciones a seguir

Instalación y configuracion de Jest + React Testing Library

En proyectos de React + Vite

  1. Instalaciones:
yarn add --dev jest babel-jest @babel/preset-env @babel/preset-react 
yarn add --dev @testing-library/react @types/jest jest-environment-jsdom
  1. Opcional: Si usamos Fetch API en el proyecto:
@CarmeloRicarte
CarmeloRicarte / parse-jwt.js
Created August 6, 2019 09:40 — forked from Klerith/parse-jwt.js
Parse - JWT - Obtener Payload y fecha de creación y expiración
function parseJwt (token) {
var base64Url = token.split('.')[1];
var base64 = base64Url.replace('-', '+').replace('_', '/');
return JSON.parse(window.atob(base64));
};