This file contains 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 { MongoClient } = require('mongodb'); | |
class MongoDBClient { | |
constructor(uri, dbName) { | |
this.uri = uri; | |
this.dbName = dbName; | |
this.client = new MongoClient(uri, { useNewUrlParser: true, useUnifiedTopology: true }); | |
} | |
async connect() { |
This file contains 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 fastify = require('fastify')({ logger: true }); | |
const MongoDBClient = require('./MongoDBClient'); | |
const uri = process.env.DB_URI; | |
const dbName = 'bancoDeDadosDaAPI'; | |
const dbClient = new MongoDBClient(uri, dbName); | |
async function setupRoutes() { | |
// Pré-cadastro de clientes | |
await dbClient.insertClientes([ |
This file contains 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 { | |
Worker, | |
isMainThread, | |
parentPort, | |
workerData } = require('worker_threads'); | |
const { performance } = require('perf_hooks'); | |
// Função para encontrar números primos em um intervalo | |
const findPrimes = (start, end) => { | |
const primes = []; |
This file contains 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 { performance } = require('perf_hooks'); | |
// Generate a list of products | |
const productArray = Array.from({ length: 1000000 }, (_, i) => ({ | |
id: i, | |
name: `product${i}`, | |
price: i * 0.5 | |
})); | |
// Convert the product list to a Map for faster lookups |
This file contains 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 { entity, field } = require('@herbsjs/herbs') | |
const required = { validation: { presence: true } } | |
const requiredString = { | |
validation: { | |
...required.validation, | |
length: { minimum: 3, maximum: 255 }, | |
} | |
} |
This file contains 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 { entity, field } = require('@herbsjs/herbs') | |
const required = { validation: { presence: true } } | |
module.exports = entity('Sale', { | |
id: field(Number, { | |
// Optional option | |
validation: { | |
presence: true, | |
numericality: { |
This file contains 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 { entity, field } = require('@herbsjs/herbs') | |
const requiredString = { | |
validation: { | |
presence: true, | |
length: { minimum: 3, maximum: 255 }, | |
} | |
} | |
const Customer = entity('Customer', { |
This file contains 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
checkpoint = ModelCheckpoint("best_model.hdf5", monitor='loss', verbose=1, | |
save_best_only=True, mode='auto', period=1) | |
model.fit(x_train, y_train, | |
batch_size=batch_size, | |
epochs=epochs, | |
verbose=1, | |
validation_data=(x_test, y_test), | |
callbacks=[checkpoint]) |
This file contains 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
checkpoint = ModelCheckpoint("best_model.hdf5", monitor='loss', verbose=1, | |
save_best_only=True, mode='auto', period=1) | |
model.fit(x_train, y_train, | |
batch_size=batch_size, | |
epochs=epochs, | |
verbose=1, | |
validation_data=(x_test, y_test), | |
callbacks=[checkpoint]) |
This file contains 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
# [...] | |
from keras.layers import Conv2D, MaxPooling2D | |
from keras import backend as K | |
from keras.callbacks import ModelCheckpoint |
NewerOlder