Skip to content

Instantly share code, notes, and snippets.

View David200197's full-sized avatar

David David200197

View GitHub Profile
@David200197
David200197 / is-deeply-equal.ts
Last active December 20, 2023 19:22 — forked from jsdevtom/deep-equals.ts
fast deep equals in TypeScript
const isArray = Array.isArray;
const keyList = Object.keys;
const hasProp = Object.prototype.hasOwnProperty;
export const isDeeplyEqual = <T = any>(a: T, b: T): boolean => {
if (a === b) return true;
if (typeof a === 'function' && typeof b === 'function') return true;
if (!a || !b || typeof a !== 'object' || typeof b !== 'object')
return a !== a && b !== b;
@David200197
David200197 / authentication-1.controller.ts
Created October 16, 2023 23:27 — forked from jengel3/authentication-1.controller.ts
NestJS - Implementing Access & Refresh Token Authentication
// app/modules/authentication/authentication.controller.ts
import { Body, Controller, Post } from '@nestjs/common'
import { RegisterRequest } from './requests'
import { User } from '../../modules/user'
import { UsersService } from '../users/users.service'
// Inspirado en el video de Bettatech https://www.youtube.com/watch?v=K--Lmy8qUCQ
// Esta es mi propia solución sobre una máquina de estado pero eliminando los posibles problemas referentes al consumo de memoria
interface DisconnectSocket {
connect(): ConnectSocket;
}
interface ConnectSocket {
emit(event: string): void;
}
@David200197
David200197 / paginator.ts
Last active May 30, 2024 21:07
Helper Paginator
type Options = {
page: number
perPage: number
}
export class Paginator {
private page: number
private perPage: number
constructor(readonly options: Options) {
Object.assign(this, options)
@David200197
David200197 / start-ngrok.mjs
Last active August 25, 2023 16:16
Auto Reconnect Ngrok with Telegram Notification
/**
* npm install axios dotenv ngrok
* or
* yarn add axios dotenv ngrok
*/
import axios from 'axios'
import dotenv from 'dotenv'
import ngrok from 'ngrok'
dotenv.config()
@David200197
David200197 / mock-axios.ts
Last active August 8, 2023 05:35 — forked from cowboy/mock-axios.js
axios mocking via interceptors
import axios, { InternalAxiosRequestConfig } from 'axios'
type MockData = {
[x: string]: any
}
class MockError extends Error {
mockData?: MockData
config?: InternalAxiosRequestConfig<any>
code?: number