ngrok http https://localhost:8080 -bind-tls=true -host-header="localhost:8080"
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
/** | |
* Get all documents of collection | |
* @param db {Object} - MongoDB connection | |
* @param collectionName {String} - Collection name | |
* @returns {Promise<Array>} | |
*/ | |
async function getDocs(db, collectionName) { | |
const collection = db.collection(collectionName); | |
const cursor = await collection.find(); | |
return cursor.toArray(); |
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
function toDots(object, array = []) { | |
const deepValue = (obj, path) => path.replace(/\[|\]\.?/g, '.').split('.').filter(s => s).reduce((acc, val) => acc && acc[val], obj); | |
function parseToDots(obj, key) { | |
const value = deepValue(obj, key); | |
array.push(key); // Add if you want add only certains fields | |
if (typeof value === 'object') Object.keys(value).forEach(key2 => parseToDots(obj, `${key}.${key2}`)); | |
} | |
Object.keys(object).forEach(key => parseToDots(object, key)); |
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
/** | |
* Get FQDN from a string | |
* @name FQDN | |
* @param URL {String} - String you want get FQDN | |
* @return {String} | |
**/ | |
function FQDN(URL = '') { | |
URL = URL.subtring(0, 50); // This will avoid evaluate long malicious fqdn | |
const regex = /[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9](?:\.[a-zA-Z]{2,})+/i; | |
const filtered = regex.exec(URL); |
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
/** | |
* Search number of times a character/string exist in DOM element | |
* | |
* @name countCharacter | |
* @param DOMElement {String|Object} - DOM element you want count characters inside | |
* @param character {String} - String you want count | |
* @param caseSensitive {Boolean} - Option to set sensitive to uppercase or lowercase | |
* @return {Number} - Total of times character match in DOM element | |
**/ | |
function countCharacter(DOMElement = 'body', character = '', caseSensitive = 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
upstream app_server { | |
ip_hash; | |
server app_react:3000 max_fails=3 fail_timeout=30s; | |
} | |
upstream api_server { | |
ip_hash; | |
server api_feathers:3040 max_fails=3 fail_timeout=30s; | |
} |
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 fetch = require('node-fetch'); | |
/** | |
* Responds to any HTTP request. | |
* | |
* @param {!express:Request} req HTTP request context. | |
* @param {!express:Response} res HTTP response context. | |
*/ | |
exports.hubspot = async (req, res) => { | |
res.set('Access-Control-Allow-Origin', '*'); | |
if (req.method === 'OPTIONS') { |
To solve the problem when execute npm install
and get node-gyp error access permission:
EACCES current user ("$user") does not have permission to access the dev dir "/root/.cache/node-gyp/12.16.1"
Execute the follow commands:
sudo npm -g install node-gyp --unsafe-perm
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 myHeaders = { | |
get: function getHeader(url = window.location, obj = {}) { | |
return new Promise((resolve) => { | |
function checkWhichSplit(string = '') { | |
if (string.includes(',')) return ','; | |
else if (string.includes(';')) return ';'; | |
else return undefined; | |
} | |
function parseHeader(string = '') { |
First need open file with sudo nano /etc/mongod.conf
And edit
# network interfaces
net:
port: 27017