Skip to content

Instantly share code, notes, and snippets.

View jastisriradheshyam's full-sized avatar
🪀
((~~~))

Jasti Sri Radhe Shyam jastisriradheshyam

🪀
((~~~))
View GitHub Profile
@jastisriradheshyam
jastisriradheshyam / npm_login.sh
Last active August 23, 2021 16:51
NPM Login with Verdaccio having "max_users: -1" and solves error "user registration disabled"
#!/bin/bash
## Author : Jasti Sri Radhe Shyam (https://jastisriradheshyam.github.io)
function printHelp() {
cat <<EOL
Usage:
npm_login.sh [Flags]
Flags:
-h print help
@jastisriradheshyam
jastisriradheshyam / allSettled.js
Created September 7, 2020 08:02
allSettled polyfill
Promise.allSettled = function (promises) {
const mappedPromises = promises.map(promise => (
promise
.then(value => ({ status: 'fulfilled', value }))
.catch(reason => ({ status: 'rejected', reason }))
));
return Promise.all(mappedPromises);
};
@jastisriradheshyam
jastisriradheshyam / cwd_change_nodejs.js
Created April 17, 2020 20:59
Change nodejs process current working directory
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:
@jastisriradheshyam
jastisriradheshyam / error_to_string.js
Last active April 14, 2020 11:17
Node JS, full error object to string
// 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()
}
@jastisriradheshyam
jastisriradheshyam / RowDataPacket_removal.js
Created October 8, 2019 15:16
removal of RowDataPacket from the results of mysql query in node js
'use strict';
var pool = require('./connection');
const mysql = require('mysql');
/**
* Executes SQL query and returns data.
* @constructor
* @param {string} queryText - SQL query string.
*/
@jastisriradheshyam
jastisriradheshyam / pm2.md
Last active September 14, 2020 09:09
PM2 Start for NPM start script based projects

pm2 start --name "dev react" --time npm -- start

@jastisriradheshyam
jastisriradheshyam / response.js
Created August 19, 2019 21:02
Error handling Javascript
// response for error handling
let response = {
success: Boolean,
errorType: Number, // 1 - Programmer or config, 2 - Operational
responseCode: String,
message: String
};
@jastisriradheshyam
jastisriradheshyam / rsa_oaep_decrypt.js
Created August 17, 2019 19:06
RSA OAEP, encryption with Golang and decryption with NodeJS (node-rsa)
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){
@jastisriradheshyam
jastisriradheshyam / git.md
Last active February 12, 2019 14:18
Git commands and info

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

@jastisriradheshyam
jastisriradheshyam / cmdline
Last active December 1, 2018 20:52
Linux (Solus) V sync issue (Screen Tearing) with NVIDIA card solution
modprobe.blacklist=nouveau i915.enable_rc6=0 i915.enable_psr=0 i915.preliminary_hw_support=1 i915.enable_hd_vgaarb=1 intel_idle.max_cstate=1 nvidia-drm.modeset=1