Skip to content

Instantly share code, notes, and snippets.

View David200197's full-sized avatar

David David200197

View GitHub Profile
@David200197
David200197 / randomInt.ts
Last active August 9, 2024 16:58 — forked from rodrigograca31/randomInt.ts
Random Integer generator (Typescript)
/**
* Generates a random integer between min and max (inclusive)
* @param {number} min
* @param {number} max
* @returns randomly generated integer
*/
const randomInt = (min: number, max: number): number => {
return Math.floor(Math.random() * (max - min + 1) + min);
};
@David200197
David200197 / README.md
Created February 7, 2024 01:10 — forked from backendi/README.md
Ejecutar Python desde Node.js

Ejecutar un script de Python desde Node.js

Código que acompaña al video Ejecutar Python desde Node.js

Descripción

Script de Node.js que ejecuta un script de Python. script_node.js invoca a script_python.py como un subproceso utilizando la función spawn. Se establece una comunicación mediante stdin/stdout donde script_node.js envía un texto simple a script_python.py

Pre-requisitos

@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'
@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