git branch
git clone repo_location
git pull origin branch_name
git push origin branch_name
git commit -S[GPG key]
git merge brach_to_merge --no-commit --no-ff
git status
git stash
git stash apply
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
// Gives the current Date Time in this format --> ddmmyyyy hh:mm:ss | |
var getLCurrentDateFormated = function () { | |
let date_now = new Date(); | |
return date_now.toLocaleString('en-IN', { day: "2-digit", month: "2-digit", year: "numeric", hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false, timeZone: 'Asia/Kolkata' }).replace(/[\/\,]/g, ""); | |
} |
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
// Reference - https://www.w3resource.com/javascript-exercises/javascript-date-exercise-8.php | |
var date_diff_inseconds = function (date1, date2) { | |
let dt1 = new Date(date1); | |
let dt2 = new Date(date2); | |
return Math.floor((Date.UTC(dt2.getFullYear(), dt2.getMonth(), dt2.getDate(), dt2.getHours(), dt2.getMinutes(), dt2.getSeconds()) - Date.UTC(dt1.getFullYear(), dt1.getMonth(), dt1.getDate(), dt1.getHours(), dt1.getMinutes(), dt1.getSeconds())) / (1000)); | |
}; | |
var date_diff_inminutes = function (date1, date2) { | |
let dt1 = new Date(date1); | |
let dt2 = new Date(date2); |
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 | |
}; |
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
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 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
Promise.allSettled = function (promises) { | |
const mappedPromises = promises.map(promise => ( | |
promise | |
.then(value => ({ status: 'fulfilled', value })) | |
.catch(reason => ({ status: 'rejected', reason })) | |
)); | |
return Promise.all(mappedPromises); | |
}; |
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
/* | |
Usage: | |
------------------------------------------------- | |
var syn_timeout = require('synchronous_timeout'); | |
//some code | |
await syn_timeout.pause(300); | |
//some code | |
------------------------------------------------- | |
if defined and used in a same file: | |
------------------------------------------------- |