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 } = require("worker_threads"); | |
if (isMainThread) { | |
console.log("Main thread started."); | |
// Create a new worker thread | |
const worker = new Worker(__filename); | |
// Listen for messages from the worker thread | |
worker.on("message", (result) => { |
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
/ ES5 | |
const worker = require('node:worker_threads'); | |
// ES6 | |
import worker from 'node:worker_threads'; |
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 express = require("express"); | |
const app = express(); | |
// Function to check if a number is prime. | |
function isPrime(num) { | |
if (num <= 1) return false; | |
if (num <= 3) return true; | |
if (num % 2 === 0 || num % 3 === 0) return false; | |
for (let i = 5; i * i <= num; i += 6) { | |
if (num % i === 0 || num % (i + 2) === 0) return false; |
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 crypto = require('crypto'); | |
process.on('message', (password) => { | |
crypto.randomBytes(32, (err, salt) => { | |
if (err) { | |
process.send({ error: err.message }); | |
} else { | |
crypto.pbkdf2(password, salt, 10000, 64, 'sha512', (err, derivedKey) => { | |
if (err) { | |
process.send({ error: err.message }); |
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
import sys | |
def add_numbers(number1, number2): | |
try: | |
result = float(number1) + float(number2) | |
print(result) | |
except ValueError: | |
print("Invalid input. Please provide valid numbers!!!") | |
if __name__ == "__main__": |
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 { exec } = require('child_process'); | |
exec('ls -l -a', { cwd: process.env.HOME }, (error, stdout, stderr) => { | |
if (error) { | |
console.error(`exec error: ${error}`); | |
return; | |
} | |
if (stderr) { | |
console.error(`stderr: ${stderr}`); |
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 { spawn } = require('child_process'); | |
const shellProcess = spawn('ls', ['-l', '-a']); | |
shellProcess.stdout.on('data', (data) => { | |
console.log(`Shell Output: ${data}`); | |
}); | |
shellProcess.stderr.on('data', (data) => { | |
console.log(`Shell Error: ${data}`); | |
}); |
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
/* | |
Before running the program below, please ensure that you have set up Sequelize on your local system. | |
You can follow the instructions provided in this link: | |
https://github.com/sequelize/sequelize/blob/main/CONTRIBUTING.md#how-to-prepare-a-development-environment-for-sequelize | |
Alternatively, you can run the following commands to set up Sequelize: | |
git clone https://github.com/sequelize/sequelize.git | |
cd sequelize | |
yarn install | |
yarn start-postgres-latest |