A Pen by Nikolay Debroh on CodePen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import axios, { InternalAxiosRequestConfig } from 'axios' | |
| type MockData = { | |
| [x: string]: any | |
| } | |
| class MockError extends Error { | |
| mockData?: MockData | |
| config?: InternalAxiosRequestConfig<any> | |
| code?: number |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Options = { | |
| page: number | |
| perPage: number | |
| } | |
| export class Paginator { | |
| private page: number | |
| private perPage: number | |
| constructor(readonly options: Options) { | |
| Object.assign(this, options) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
Step - 1: install reflect-metadata
npm install reflect-metadatapnpm add reflect-metadatayarn add reflect-metadataCódigo que acompaña al video Ejecutar Python desde Node.js
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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); | |
| }; |
OlderNewer