Skip to content

Instantly share code, notes, and snippets.

View huanvb's full-sized avatar

Vũ Bá Huấn huanvb

  • CMC Global
  • Hanoi, Vietnam
View GitHub Profile
@huanvb
huanvb / clean_code.md
Created April 5, 2022 07:14 — 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

@huanvb
huanvb / sh
Created December 26, 2019 11:20
install sonar-scanner
#!/bin/bash
cd /tmp || exit
echo "Downloading sonar-scanner....."
if [ -d "/tmp/sonar-scanner-cli-4.2.0.1873-linux.zip" ];then
rm /tmp/sonar-scanner-cli-4.2.0.1873-linux.zip
fi
wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.2.0.1873-linux.zip
echo "Download completed."
@huanvb
huanvb / sh
Last active December 5, 2019 08:09
git commands
# Delete all local git branches
git branch --merged | grep -v \* | xargs git branch -D
# Squash commits in feature branch
## show commits of feature branch
git cherry -v develop
## rebase 5 last commits
git rebase -i HEAD~5
## keep pick in the first and change pick to squash
@huanvb
huanvb / sonar-project.properties
Created December 5, 2019 03:16
Sonar properties for Java project
sonar.projectKey=project-key
sonar.projectName=project-name
sonar.projectVersion=6.0.0
sonar.sourceEncoding=UTF-8
# create a folder with name as compiled in same folder
sonar.java.binaries=compiled
sonar.sources=.
sonar.language=java
# Change the host.url to point to the
@huanvb
huanvb / sonar-project.properties
Created December 5, 2019 03:14
Sonar properties for Front-end project
sonar.projectKey=project-key
sonar.projectName=project-name
sonar.projectVersion=6.0.0
sonar.sourceEncoding=UTF-8
sonar.sources=src/
sonar.exclusions=**/node_modules/**,**/*.spec.ts
sonar.report.export.path=sonar-report.json
# Change the host.url to point to the
# sonarcube server (default localhost)
@huanvb
huanvb / sh
Created December 5, 2019 03:09
Copy ssh key to clipboard
pbcopy < ~/.ssh/id_rsa.pub
@huanvb
huanvb / js
Created December 5, 2019 03:06
Get base url of script
function beforeSecondLastSlash(url) {
return url.substr(0, url.lastIndexOf('/', url.lastIndexOf('/') - 1));
}
function getBaseUrlFromCommon() {
return beforeSecondLastSlash(document.currentScript.src);
}
var basedUrl = getBaseUrlFromCommon();