Skip to content

Instantly share code, notes, and snippets.

View khanhney's full-sized avatar
🎼
https://www.facebook.com/KhanhNey

Khanh Ney khanhney

🎼
https://www.facebook.com/KhanhNey
View GitHub Profile
@khanhney
khanhney / node-profiling-and-good-practises-links.txt
Created April 4, 2021 12:00 — forked from ketanghumatkar/node-profiling-and-good-practises-links.txt
NodeJS: Garbage Collector, profiling and best practices links
@khanhney
khanhney / moleculer-k8.md
Created March 11, 2021 15:21
Moleculer k8 depoyment

Create a cluster on GKE:

gcloud container clusters create backend --num-nodes=2 --machine-type n1-standard-4

Get credentials:

gcloud container clusters get-credentials backend

Build the docker image:

--log_gc (Log heap samples on garbage collection for the hp2ps tool.)
type: bool default: false
--expose_gc (expose gc extension)
type: bool default: false
--max_new_space_size (max size of the new generation (in kBytes))
type: int default: 0
--max_old_space_size (max size of the old generation (in Mbytes))
type: int default: 0
--max_executable_size (max size of executable memory (in Mbytes))
type: int default: 0
@khanhney
khanhney / redis_cheatsheet.bash
Created September 22, 2020 10:24 — forked from LeCoupa/redis_cheatsheet.bash
Redis Cheatsheet - Basic Commands You Must Know --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.
@khanhney
khanhney / mongoose-recursive
Created December 2, 2019 08:12
mongoose recursive without support op mongoose
const mongoose = require('mongoose');
const bluebird = require('bluebird');
const User = require('./model');
mongoose.Promise = bluebird;
constructPopulateConfigObj = (level, path) => {
const oneLevel = () => ({ path });
let obj = oneLevel();
function (str) {
str = str.toLowerCase();
str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g, 'a');
str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g, 'e');
str = str.replace(/ì|í|ị|ỉ|ĩ/g, 'i');
str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g, 'o');
str = str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g, 'u');
str = str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g, 'y');
str = str.replace(/đ/g, 'd');
// str = str.replace(/\W+/g, ' ');