Skip to content

Instantly share code, notes, and snippets.

View kanelv's full-sized avatar
🎯
Focusing

Cuong Le kanelv

🎯
Focusing
View GitHub Profile
@kanelv
kanelv / Spring-Boot-Clean-Architecture-DDD
Created April 14, 2024 17:51
Project Folder Structure Diagram for Spring-boot Clean Architecture Demo
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ └── example
│ │ │ ├── adapters
│ │ │ │ ├── controllers
│ │ │ │ │── database
│ │ │ │ │ ├── postgresql # Implementation for PostgreSQL
│ │ │ │ │ │ ├── entities # PostgreSQL entity classes
@kanelv
kanelv / gist:10b94ccbe25a6a99101bc3590c7a3233
Last active March 27, 2024 05:10
REST API Naming Guidelines
# REST API Naming Guidelines
API routes should typically be named using nouns rather than verbs.
This aligns with the principle of using HTTP methods (verbs) like GET, POST, PUT, DELETE, etc., to perform actions on the resources represented by the nouns.
## Some guidelines for naming API routes
1. Use nouns: Name your API routes after the resources they represent. For example, if you have a resource representing users, the route could be /users.
2. Use plural nouns for collections: When dealing with collections of resources, it's a convention to use plural nouns. For example, /users for a collection of users, /posts for a collection of posts, etc.
@kanelv
kanelv / gist:2753135e8cd35c5e0e26dedfec461b58
Created March 22, 2024 15:24
Running Docker Without sudo
sudo groupadd docker
sudo usermod -aG docker $USER
su - $USER
# log out and log in again to make these changes effective
@kanelv
kanelv / nvmCommands.js
Created October 7, 2023 08:11 — forked from chranderson/nvmCommands.js
Useful NVM commands
// check version
node -v || node --version
// list locally installed versions of node
nvm ls
// list remove available versions of node
nvm ls-remote
// install specific version of node
@kanelv
kanelv / GitConfigCommand.md
Created June 29, 2023 13:37
Git Config Command

Git Config Command

  • ~/.gitconfig file stores git global config
  • .git/config file local configuration will be in your repository's

The command below will show the combination information of the 2 files above

git config --list
git config --list --global
git config --list --local
git config --list --system
### STEP 1. Generate a new SSH key by the command below
```bash
ssh-keygen -t ed25519 -C "your_email@example.com"
```
### STEP 2. Copy the SSH public key to your clipboard by the command below
```bash
# macOS
pbcopy < ~/.ssh/id_ed25519.pub
```
@kanelv
kanelv / clean_code.md
Created May 7, 2023 15:43 — 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

@kanelv
kanelv / openssl.md
Created May 7, 2023 11:43 — forked from roustem/openssl.md
Common OpenSSL Commands with Keys and Certificates

Common OpenSSL Commands with Keys and Certificates

SSL Info

Generate RSA private key with certificate in a single command

openssl req -x509 -newkey rsa:4096 -sha256 -keyout example.key -out example.crt -subj "/CN=example.com" -days 3650 -passout pass:foobar

Generate Certificate Signing Request (CSR) from private key with passphrase

openssl x509 -x509toreq -in example.crt -out example.csr -signkey example.key -passin pass:foobar

@kanelv
kanelv / generate.js
Created May 7, 2023 10:22 — forked from dehamzah/generate.js
Generate secret key in NodeJS
require('crypto').randomBytes(48, function(err, buffer) { var token = buffer.toString('hex'); console.log(token); });
@kanelv
kanelv / BinaryGap.js
Created March 8, 2023 13:12
BinaryGap
const solution = (N) => {
const binary = N.toString(2);
let count = 0;
let answer = 0;
for(let b of binary) {
if (b === "0") {
count++
} else {