From 68582e14b7c490c9368a4f0c2fa4335e88aefcaa Mon Sep 17 00:00:00 2001 From: Hau Nguyen Date: Fri, 22 Sep 2023 23:40:26 +0700 Subject: [PATCH] feat: re gen --- docs/2022-06-08-backup.html | 90 ++--- docs/2022-06-08-dockerfile-go.html | 29 +- docs/2022-07-10-bootstrap-go.html | 492 ++++++++++--------------- docs/2022-07-12-uuid-or-else.html | 70 ++-- docs/2022-07-19-migrate-to-buf.html | 53 +-- docs/2022-07-31-experiment-go.html | 60 ++- docs/2022-07-31-sql.html | 174 ++++----- docs/2022-08-10-gitignore.html | 52 +-- docs/2022-10-26-reload-config.html | 16 +- docs/2022-12-25-archlinux.html | 454 ++++++++--------------- docs/2022-12-25-go-test-asap.html | 48 ++- docs/2023-03-05-incident.html | 48 ++- docs/2023-03-08-ekyc.html | 16 +- docs/2023-03-30-fonts.html | 133 +++---- docs/2023-04-01-games.html | 131 +++---- docs/2023-04-17-keeb.html | 348 +++++++---------- docs/2023-04-17-naming.html | 48 ++- docs/2023-05-03-neovim.html | 87 ++--- docs/2023-05-08-things-i-like.html | 48 ++- docs/2023-05-23-swagger.html | 29 +- docs/2023-06-06-terminal-workflow.html | 72 ++-- docs/2023-06-10-incident-context.html | 58 ++- docs/2023-06-24-khoan-cat-be-tong.html | 16 +- docs/2023-06-25-useful-tools.html | 249 +++++-------- docs/2023-07-01-pastebin.html | 154 +++----- docs/2023-07-02-fandroid.html | 29 +- docs/2023-07-06-redis.html | 29 +- docs/2023-07-30-cache-shenanigan.html | 29 +- docs/2023-08-09-vscode.html | 13 +- docs/2023-08-20-hardware.html | 16 +- docs/2023-08-23-real-world-crypto.html | 48 +-- docs/2023-09-14-vietnam-survivor.html | 16 +- docs/index.html | 13 +- posts/2023-06-25-useful-tools.md | 6 + 34 files changed, 1214 insertions(+), 1960 deletions(-) diff --git a/docs/2022-06-08-backup.html b/docs/2022-06-08-backup.html index a438845..aa1fe6f 100644 --- a/docs/2022-06-08-backup.html +++ b/docs/2022-06-08-backup.html @@ -28,15 +28,13 @@

~

-

- Backup my way +

+ Backup my way

First thing first, I want to list my own devices, which I have through the @@ -153,15 +151,13 @@ How to backup, the second is Recovery strategy.

-

- How to backup +

+ How to backup

Before I talk about backup, I want to talk about data. In specifically, @@ -262,15 +258,13 @@ restic -r rclone:remote:PrivateData restore latest --target ~

  • Store locally in my laptop
  • Don't store locally in phone (can not keep track easily)
  • -

    - Backup work related data +

    APIs tools:

    -

    - Misc +

    + Misc

    To backup everything is hard, so keep it simple and only backup important @@ -334,15 +321,10 @@ restic -r rclone:remote:PrivateData restore latest --target ~

  • TODOis, Evernote, ... -> Google Keep / Notion
  • Dropbox, OneDrive, ... -> Google Drive
  • -

    - The end +

    + The end

    This guide will be updated regularly I promise.

    diff --git a/docs/2022-06-08-dockerfile-go.html b/docs/2022-06-08-dockerfile-go.html index 440fc91..86defc5 100644 --- a/docs/2022-06-08-dockerfile-go.html +++ b/docs/2022-06-08-dockerfile-go.html @@ -28,15 +28,13 @@

    ~

    -

    - Dockerfile for Go +

    + Dockerfile for Go

    Each time I start a new Go project, I repeat many steps. Like set up @@ -165,15 +163,10 @@ ENTRYPOINT ["/app"]

    Finally, I copy app to Distroless base image.

    -

    - Thanks +

    + Thanks

    -

    - Do not repeat! +

    + Do not repeat!

    If we have too many services, some of the logic will be overlapped.

    @@ -157,25 +148,21 @@ internal Another bad practice is adapter service. No need to write a new service if what we need is just common pkg libs.

    -

    - Taste on style guide +

    + Taste on style guide

    -

    - Stop using global var +

    + Stop using global var

    If I see someone using global var, I swear I will shoot them twice in the @@ -186,15 +173,13 @@ internal

  • Can not write unit test.
  • Is not thread safe.
  • -

    - Use functional options, but don't overuse it! +

    + Use functional options, but don't overuse it!

    For simple struct with 1 or 2 fields, no need to use functional options. @@ -240,19 +225,15 @@ internal WithB option. No need to pass direct field inside s.

    -

    - Use - + Use errgroup - as much as possible + as much as possible

    If business logic involves calling too many APIs, but they are not depend @@ -285,35 +266,33 @@ internal // Handle error } -

    +

    Use - Use semaphore - when need to implement WorkerPool + when need to implement WorkerPool

    Please don't use external libs for WorkerPool, I don't want to deal with dependency hell.

    -

    +

    Use - sync.Pool when + >Use sync.Pool when need to reuse object, mainly for bytes.Buffer +

    Example:

    @@ -343,39 +322,33 @@ internal return result, nil }
    -

    - External libs +

    + External libs

    -

    - No need vendor +

    + No need vendor +

    Only need if you need something from vendor, to generate mock or something else.

    -

    +

    Use build.go to include build tools in go.mod + >Use build.go to include build tools in go.mod

    To easily control version of build tools.

    For example build.go:

    @@ -398,18 +371,16 @@ internal We always get the version of build tools in go.mod each time we install it. Future contributors will not cry anymore.

    -

    +

    Don't use cli libs (spf13/cobra, urfave/cli) just for Go - service + >Don't use cli libs (spf13/cobra, + urfave/cli) just for Go + service

    What is the point to pass many params (do-it, @@ -422,18 +393,13 @@ internal The Twelve Factors guide.

    -

    - Don't use - + Don't use grpc-ecosystem/grpc-gateway +

    Just don't.

    @@ -446,31 +412,21 @@ internal Write 1 for both gRPC, REST sounds good, but in the end, it is not worth it.

    -

    - Don't use uber/prototool, - use bufbuild/buf +

    + Don't use uber/prototool, use + bufbuild/buf +

    prototool is deprecated, and buf can generate, lint, format as good as prototool.

    -

    - Use gin-gonic/gin for - REST. +

    + Use gin-gonic/gin for + REST.

    With c *gin.Context:

    -

    - Heathcheck +

    + Heathcheck

    Use SELECT 1 to check if database failed yet.

    -

    - Tools +

    + Tools

    -

    - Thanks +

    + Thanks

    -

    - Let the fun (writing test) begin +

    + Let the fun (writing test) begin

    If you code Go long enough, you know table driven tests and how is that so diff --git a/docs/2023-03-05-incident.html b/docs/2023-03-05-incident.html index f80ed5b..c8fad2f 100644 --- a/docs/2023-03-05-incident.html +++ b/docs/2023-03-05-incident.html @@ -28,26 +28,22 @@

    ~

    -

    - Incident come and go +

    + Incident come and go

    This is collect of all incidents I created in the past :(

    -

    - Service starts with empty port +

    + Service starts with empty port

    Because all configs is read from file.

    @@ -58,15 +54,13 @@ Solution: For some configs, make sure to failed first if it's empty.

    -

    - Race condition of series of APIs +

    + Race condition of series of APIs

    For example I have 2 APIs: