From 6c4262a7dc4fa6ebd37fb3752e657b7ee176d7fc Mon Sep 17 00:00:00 2001 From: Hau Nguyen Date: Thu, 29 Feb 2024 19:29:26 +0700 Subject: [PATCH] feat: add pyright --- docs/2022-06-08-backup.html | 84 ++-- docs/2022-06-08-dockerfile-go.html | 28 +- docs/2022-07-10-bootstrap-go.html | 601 ++++++++++++++----------- docs/2022-07-12-uuid-or-else.html | 74 +-- docs/2022-07-19-migrate-to-buf.html | 58 +-- docs/2022-07-31-experiment-go.html | 62 +-- docs/2022-07-31-sql.html | 183 ++++---- docs/2022-08-10-gitignore.html | 56 +-- docs/2022-10-26-reload-config.html | 14 +- docs/2022-12-25-archlinux.html | 548 +++++++++++----------- docs/2022-12-25-go-test-asap.html | 44 +- docs/2023-03-05-incident.html | 42 +- docs/2023-03-08-ekyc.html | 14 +- docs/2023-03-30-fonts.html | 223 ++++----- docs/2023-04-01-games.html | 146 +++--- docs/2023-04-17-keeb.html | 294 ++++++------ docs/2023-04-17-naming.html | 42 +- docs/2023-05-03-neovim.html | 84 ++-- docs/2023-05-08-things-i-like.html | 42 +- docs/2023-05-23-swagger.html | 28 +- docs/2023-06-06-terminal-workflow.html | 50 +- docs/2023-06-10-incident-context.html | 56 +-- docs/2023-06-24-khoan-cat-be-tong.html | 14 +- docs/2023-06-25-useful-tools.html | 229 +++++----- docs/2023-07-01-pastebin.html | 212 +++++---- docs/2023-07-02-fandroid.html | 28 +- docs/2023-07-06-redis.html | 30 +- docs/2023-07-30-cache-shenanigan.html | 28 +- docs/2023-08-09-vscode.html | 14 +- docs/2023-08-20-hardware.html | 14 +- docs/2023-08-23-real-world-crypto.html | 114 ++--- docs/2023-09-14-vietnam-survivor.html | 84 ++-- docs/2023-09-23-bloguru.html | 14 +- docs/2023-10-02-unrelated.html | 58 +-- docs/2023-12-16-debounce.html | 28 +- docs/2024-01-20-backend-thinking.html | 196 ++++---- docs/index.html | 14 +- posts/2023-06-25-useful-tools.md | 1 + 38 files changed, 1998 insertions(+), 1853 deletions(-) diff --git a/docs/2022-06-08-backup.html b/docs/2022-06-08-backup.html index 5ab5b6b..39cdd8c 100644 --- a/docs/2022-06-08-backup.html +++ b/docs/2022-06-08-backup.html @@ -28,16 +28,16 @@

~

-

+
+

Backup my way

Backup my way -

+ > +

First thing first, I want to list my own devices, which I have through the years: @@ -151,16 +151,16 @@ 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, which data should I backup? @@ -260,16 +260,16 @@ 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

    Backup work related data -

    + > +

    APIs tools:

    -

    +
    +

    Misc

    Misc -

    + > +

    To backup everything is hard, so keep it simple and only backup important things. Pick one then stay away from other cloud services: @@ -332,16 +332,16 @@ 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 dc793a0..6f8365b 100644 --- a/docs/2022-06-08-dockerfile-go.html +++ b/docs/2022-06-08-dockerfile-go.html @@ -28,16 +28,16 @@

    ~

    -

    +
    +

    Dockerfile for Go

    Dockerfile for Go -

    + > +

    Each time I start a new Go project, I repeat many steps. Like set up .gitignore, CI configs, Dockerfile, ... @@ -165,16 +165,16 @@ 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.

    For example, service A and service B both need to make POST call API to @@ -157,26 +157,26 @@ 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 face. @@ -186,16 +186,18 @@ 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,20 +242,22 @@ internal WithB option. No need to pass direct field inside s.

    -

    +
    +

    + Use + errgroup + as much as possible +

    Use - errgroup - as much as possible -

    + > +

    If business logic involves calling too many APIs, but they are not depend on each other. We can fire them parallel :) @@ -285,36 +289,40 @@ internal // Handle error } -

    +
    +

    + Use + semaphore + when need to implement WorkerPool +

    Use - semaphore - 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 + need to reuse object, mainly for bytes.Buffer +

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

    + > +

    Example:

    var bufPool = sync.Pool{
    @@ -343,18 +351,21 @@ internal
     	return result, nil
     }
    -

    +
    +

    + Generics + with some tricks +

    - Generics - with some tricks -

    +

    Take value then return pointer, useful with database struct full of pointers: @@ -372,40 +383,42 @@ internal return zero } -

    +
    +

    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:

    @@ -427,19 +440,21 @@ 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, --abc, --xyz) when what we only need is start @@ -451,19 +466,21 @@ internal The Twelve Factors guide.

    -

    +

    + > +

    Just don't.

    Use @@ -475,32 +492,37 @@ 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:

    -

    +
    +

    Keycap

    Keycap -

    + > +

    Currently, I use Akko 9009 Cherry Profile and EnjoyPBT 9009 Cherry Profile. The space of EnjoyPBT 9009 is not straight so I use Akko 9009 @@ -633,16 +633,16 @@

  • Check is keycap is tight on switch or not.
  • -

    +
    +

    EnjoyPBT 9009

    EnjoyPBT 9009 -

    + > +

    I buy vim kit first then base later.

    -

    +
    +

    PBTfans BOW

    PBTfans BOW -

    + > +

    I only buy 40s kit.

    -

    +
    +

    JTK iKey

    JTK iKey -

    + > +

    I bought Blue version with Base, Novel, Space kit from bidding.

    -

    +
    +

    GMK Mecha-01

    GMK Mecha-01 -

    + > +

    I only bought Base kit.

    -

    +
    +

    Color I love

    Color I love -

    + > + -

    +
    +

    Tools

    Tools -

    + > + -

    +
    +

    Buy history

    Buy history -

    + > + @@ -1036,16 +1036,16 @@
    -

    +
    +

    Thanks

    Thanks -

    + > + -

    +
    +

    Fold

    Fold -

    + > + -

    +
    +

    Keymap

    Keymap -

    + > +

    Use both \ and ; as leader key:

    vim.keymap.set("n", ";", "<Leader>", { remap = true })
    @@ -324,16 +324,16 @@ vim.keymap.set(
           
         
    -    

    +
    +

    References / Thanks

    References / Thanks -

    + > +