pm2 start --name "dev react" --time npm -- start
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 nodeRSA = require('node-rsa'); | |
/** | |
* return the decrypted Data (RSA OAEP Encryption) | |
* @param {string} RSAPrivateKey | |
* @param {string} EncrypteDataBuffer | |
* @returns {string} Data decrypted data | |
*/ | |
var RSA_OAEP_Decrypt = function(RSAPrivateKey, EncrypteDataBuffer){ | |
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
#!/bin/bash | |
## Author : Jasti Sri Radhe Shyam (https://jastisriradheshyam.github.io) | |
function printHelp() { | |
cat <<EOL | |
Usage: | |
npm_login.sh [Flags] | |
Flags: | |
-h print help |
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
'use strict'; | |
var pool = require('./connection'); | |
const mysql = require('mysql'); | |
/** | |
* Executes SQL query and returns data. | |
* @constructor | |
* @param {string} queryText - SQL query string. | |
*/ |
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
/* | |
Usage: | |
------------------------------------------------- | |
var syn_timeout = require('synchronous_timeout'); | |
//some code | |
await syn_timeout.pause(300); | |
//some code | |
------------------------------------------------- | |
if defined and used in a same file: | |
------------------------------------------------- |
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
Promise.allSettled = function (promises) { | |
const mappedPromises = promises.map(promise => ( | |
promise | |
.then(value => ({ status: 'fulfilled', value })) | |
.catch(reason => ({ status: 'rejected', reason })) | |
)); | |
return Promise.all(mappedPromises); | |
}; |
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
// Node.js Time measure for benchmarking | |
// Way One : in microseconds | |
var hrTime1 = process.hrtime(); | |
// code | |
var hrTime1 = process.hrtime(); | |
startP = hrTime[0] * 1000000 + hrTime[1] / 1000; | |
endP = hrTime1[0] * 1000000 + hrTime1[1] / 1000; | |
// Shows the time difference in micro second | |
console.log(endP - startP); |
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 path = require('path'); | |
// here after the dirname just make it to the root path of your choice | |
// all the path.resolve() will resolve from the process current directrory | |
// and chdir change that directory | |
const val = path.resolve(path.dirname(require.main.filename)+"/../..") | |
process.chdir(val); | |
/* | |
use case: |
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
// node.js error object to string | |
const util = require('util') | |
var fullErrorObjectString = ""; | |
try { | |
k++ | |
} catch (error) { | |
console.log(util.inspect(error, false, null, false /* enable colors */)) | |
fullErrorObjectString = util.inspect(error, false, null, false /* enable colors */).toString() | |
} |
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
// response for error handling | |
let response = { | |
success: Boolean, | |
errorType: Number, // 1 - Programmer or config, 2 - Operational | |
responseCode: String, | |
message: String | |
}; |
NewerOlder