Skip to content

Instantly share code, notes, and snippets.

View thangtv611's full-sized avatar

Thang Tran Viet thangtv611

  • Ho Chi Minh
  • 03:11 (UTC +07:00)
View GitHub Profile
@thangtv611
thangtv611 / settings.json
Last active February 3, 2024 10:35
VSCode setting with VIM
{
"editor.suggest.insertMode": "replace",
"terminal.integrated.fontFamily": "Menlo",
"editor.linkedEditing": true,
"javascript.updateImportsOnFileMove.enabled": "always",
"launch": {},
"[json]": {},
"editor.minimap.enabled": false,
"update.showReleaseNotes": false,
"zenMode.hideLineNumbers": false,
@thangtv611
thangtv611 / configure.md
Created October 19, 2023 16:09 — forked from jherax/configure.md
VS Code: Debugging with Jest

VS Code: Debugging Jest

Sometimes, debugging with console.log is not enough to find out what is happening in the code, as console.log prints only plain objects but neither functions nor objects with circular references. Besides, it's possible you may need to know the context and flow of the code.

Read more about debugging with VS Code in VS Code: Debugging.

sudo apt-get install stress-ng
stress-ng --cpu 4 --vm 2 --fork 8 --switch 4 --timeout 1m
##stress-ng: info: [32254] dispatching hogs: 4 cpu, 8 fork, 4 switch, 2 vm
##stress-ng: info: [32254] cache allocate: default cache size: 8192K
@thangtv611
thangtv611 / vagrant-cheat-sheet.md
Created October 17, 2022 07:00 — forked from wpscholar/vagrant-cheat-sheet.md
Vagrant Cheat Sheet

Typing vagrant from the command line will display a list of all available commands.

Be sure that you are in the same directory as the Vagrantfile when running these commands!

Creating a VM

  • vagrant init -- Initialize Vagrant with a Vagrantfile and ./.vagrant directory, using no specified base image. Before you can do vagrant up, you'll need to specify a base image in the Vagrantfile.
  • vagrant init <boxpath> -- Initialize Vagrant with a specific box. To find a box, go to the public Vagrant box catalog. When you find one you like, just replace it's name with boxpath. For example, vagrant init ubuntu/trusty64.

Starting a VM

  • vagrant up -- starts vagrant environment (also provisions only on the FIRST vagrant up)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
source ~/.nvm/nvm.sh
nvm install --lts
@thangtv611
thangtv611 / grafana_telegram_bot.md
Created February 22, 2022 04:50 — forked from ilap/grafana_telegram_bot.md
Grafana Telegram Alert

Config Telegrambot for grafana's alerts.

1. Create bot

Open Telegram and search for @BotFather user and message them the following:

You
/newbot 

BotFather
@thangtv611
thangtv611 / git_tricks.md
Last active November 26, 2021 02:20
Some tricks about git

Move to new remote

git clone --mirror <old-repo-url>
cd <repo-name>
git remote add new-origin <new-repo-url>
git push new-origin --mirror

Convert subfolder to a git repo:

@thangtv611
thangtv611 / clean_code.md
Created October 14, 2021 06:47 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

MYSQL

use native password

SET GLOBAL validate_password.LENGTH = 4;
SET GLOBAL validate_password.policy = 0;
SET GLOBAL validate_password.mixed_case_count = 0;
SET GLOBAL validate_password.number_count = 0;
SET GLOBAL validate_password.special_char_count = 0;
SET GLOBAL validate_password.check_user_name = 0;
ALTER USER 'user'@'localhost' IDENTIFIED BY 'pass';
@thangtv611
thangtv611 / rsa.js
Created July 5, 2021 04:39 — forked from sohamkamani/rsa.js
An example of RSA Encryption implemented in Node.js
const crypto = require("crypto")
// The `generateKeyPairSync` method accepts two arguments:
// 1. The type ok keys we want, which in this case is "rsa"
// 2. An object with the properties of the key
const { publicKey, privateKey } = crypto.generateKeyPairSync("rsa", {
// The standard secure default length for RSA keys is 2048 bits
modulusLength: 2048,
})