Skip to content

Instantly share code, notes, and snippets.

View OscarGM40's full-sized avatar
😑
Too much to study :((

Oscar OscarGM40

😑
Too much to study :((
View GitHub Profile
@OscarGM40
OscarGM40 / index.ts
Created April 3, 2023 10:15 — forked from Klerith/index.ts
Vuex + TypeScript - Store Structure Strongly Typed
import { createStore } from 'vuex';
// My custom modules
import exampleModule from './module-template';
import { ExampleStateInterface } from './module-template/state';
export interface StateInterface {
// Define your own store structure, using submodules if needed
// example: ExampleStateInterface;
@OscarGM40
OscarGM40 / time-since.ts
Created December 2, 2022 16:02 — 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;
@OscarGM40
OscarGM40 / password-property-dto.ts
Created August 25, 2022 16:00 — forked from Klerith/password-property-dto.ts
Password validation - DTO
@IsString()
@MinLength(6)
@MaxLength(50)
@Matches(
/(?:(?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/, {
message: 'The password must have a Uppercase, lowercase letter and a number'
})
password: string;
@OscarGM40
OscarGM40 / git-alias.md
Created August 20, 2022 10:28 — forked from Klerith/git-alias.md
Useful Git Alias

Log

git config --global alias.lg "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all"

Status

git config --global alias.s status --short

Alternativa útil de status

git config --global alias.s status -sb

@OscarGM40
OscarGM40 / recomendada.Dockerfile
Created March 27, 2022 19:03 — forked from Klerith/recomendada.Dockerfile
NextJS - Dockerfile - Configuración simple y recomendada
# Fuente: https://github.com/vercel/next.js/blob/canary/examples/with-docker/README.md
# Install dependencies only when needed
FROM node:16-alpine AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
@OscarGM40
OscarGM40 / ContextAPIShell.txt
Last active December 2, 2022 07:56
React ContextAPI(ejemplo con Typescript)
VIDEO 212-213 INICIO - CREANDO EL CONTEXTO DE LUGARES
Se sugiere usar tres archivos por cada Contexto que use(context/places,context/auth,context/ui,...):
* Uno para el createContext(PlacesContext.ts):
import { createContext } from "react";
export interface PlacesContextProps {
isLoading: boolean
userLocation?: [number, number]
@OscarGM40
OscarGM40 / is-valid-email.ts
Created February 13, 2022 16:50 — forked from Klerith/is-valid-email.ts
Email validation - customHook
const isValidEmail = ( email: string ) => {
const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}