Skip to content

Instantly share code, notes, and snippets.

View nduyhai's full-sized avatar
🎯
Focusing

Hai Nguyen nduyhai

🎯
Focusing
View GitHub Profile
@nduyhai
nduyhai / go_clean_architect.txt
Last active September 8, 2025 03:41
go_clean_architect.md
your-service/
├─ cmd/
│ └─ api/
│ └─ main.go
├─ internal/
│ ├─ domain/ # Pure enterprise rules (no frameworks)
│ │ └─ payment/
│ │ ├─ entity.go
│ │ ├─ errors.go
│ │ └─ ports.go # Repository ports (interfaces)
APP_NAME := myapp
OUTPUT := bin/$(APP_NAME)
GOFLAGS := -trimpath
LDFLAGS := -s -w
.PHONY: all build clean upx cross
all: build
@nduyhai
nduyhai / architecture.md
Last active November 13, 2024 07:36
architecture.md

Architecture

Choosing the Right Architecture

  • For applications with significant domain logic: Clean or Onion Architecture can be beneficial because they both emphasize the importance of domain logic at the center.
  • When integrating with multiple external systems or where adaptability is important: Hexagonal Architecture is an excellent choice.
  • If clarity and purpose are the priority: Screaming Architecture can help make the application's business intent obvious, especially for domain-driven projects.

Hexagonal Architecture (Ports and Adapters)

@nduyhai
nduyhai / sync_git.sh
Created July 1, 2023 14:28
create github repository and push all to remote
repo=`basename "$PWD"` && hub create -p nduyhai/$repo && git remote set-url origin [email protected]:nduyhai/$repo.git && git push -f
@nduyhai
nduyhai / Dockerfile
Created September 4, 2022 06:48
tidb. docker build -t tidb-lightning . docker run -t -i -v /tmp/data-export:/tmp/data-export tidb-lightning
FROM alpine:3.14
RUN apk update && apk add curl
RUN curl -LJO https://download.pingcap.org/tidb-community-toolkit-v4.0.14-linux-amd64.tar.gz
RUN tar -xzf tidb-community-toolkit-v4.0.14-linux-amd64.tar.gz -C /opt
RUN chmod +x /opt/tidb-community-toolkit-v4.0.14-linux-amd64/bin/tidb-lightning
RUN curl -LJO https://download.pingcap.org/tidb-enterprise-tools-nightly-linux-amd64.tar.gz
RUN tar -xzf tidb-enterprise-tools-nightly-linux-amd64.tar.gz -C /opt

Em copy file libcoccoc_tokenizer_jni.so vào một trong những thư mục /usr/java/packages/lib, /usr/lib64, /lib64, /lib, /usr/lib rồi start lại ES nhé.

Copy the following files into directory /usr/local/share/tokenizer/dicts of container:

acronyms alphabetic chemical_comp d_and_gi.txt Freq2NontoneUniFile i_and_y.txt keyword.freq multiterm_trie.dump nontone_pair_freq nontone_pair_freq_map.dump numeric special_token.strong special_token.weak syllable_trie.dump vndic_multiterm

#kill port
sudo lsof -i :3000
kill -9 <pid>
#!/bin/sh
set -e
git config -f .gitmodules --get-regexp '^submodule\..*\.path$' |
while read path_key path
do
name=$(echo $path_key | sed 's/\submodule\.\(.*\)\.path/\1/')
url_key=$(echo $path_key | sed 's/\.path/.url/')
branch_key=$(echo $path_key | sed 's/\.path/.branch/')
@nduyhai
nduyhai / ffmpeg.md
Created August 25, 2020 14:23 — forked from protrolium/ffmpeg.md
ffmpeg guide

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz:

<plugin>
<groupId>io.spring.javaformat</groupId>
<artifactId>spring-javaformat-maven-plugin</artifactId>
<version>0.0.21</version>
<executions>
<execution>
<phase>validate</phase>
<inherited>true</inherited>
<goals>
<goal>validate</goal>