Skip to content

Instantly share code, notes, and snippets.

@rl4debug
rl4debug / wire.md
Created August 26, 2020 12:33
[wire error message explaining] #wire
Warning: /Users/lap00828/projects/ops-delivery/lastmile/driverbee/location_query_lazy.go:16:6: using struct literal to inject github.com/tikivn/ops-delivery/lastmile/driverbee.LocationQueryLazy is deprecated and will be removed in the next release; use wire.Struct instead, see https://godoc.org/github.com/google/wire#Struct for more information.
Warning: /Users/lap00828/projects/ops-delivery/internal/infra/app/app.go:39:6: using struct literal to inject github.com/tikivn/ops-delivery/internal/infra/app.ApplicationContext is deprecated and will be removed in the next release; use wire.Struct instead, see https://godoc.org/github.com/google/wire#Struct for more information.
wire: /Users/lap00828/projects/ops-delivery/internal/infra/infra.go:37:22: cycle for github.com/looplab/eventhorizon.CommandHandler:
	github.com/looplab/eventhorizon.CommandHandler (github.com/tikivn/ops-delivery/internal/infra.ProvideCommandBus) ->
	github.com/tikivn/ops-delivery/internal/infra.MasterboxHandler (github.com/tikivn/ops-de
@rl4debug
rl4debug / chrome-headless-cheatsheet.md
Last active May 1, 2024 20:52
[chrome headless] #chrome #headless

Để start chrome headless trên ubuntu

# this script will start chrome headless that hold state of your real browser (cookie, session...)
# note that user-data-dir "/home/debug/.config/google-chrome/Default" is wrong (remove /Default)
/opt/google/chrome/chrome --headless \
    --remote-debugging-port=9222 \
  --user-agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36" \
  --user-data-dir="/home/debug/.config/google-chrome"
@rl4debug
rl4debug / mongo-cheatsheet.md
Created August 2, 2020 09:47
[mongo cheatsheet] #mongo
# restore mongo
@rl4debug
rl4debug / rabbitmq.md
Created April 27, 2020 15:05
[rabbitmq] #message-broker #architectural-pattern

Rabbitmq is a message broker

@rl4debug
rl4debug / understanding-diff-output
Created April 15, 2020 15:59
[diff output] #diff
- `<` file 1
- `>` file 2
@rl4debug
rl4debug / math.md
Last active April 10, 2020 18:18
[math] #math
@rl4debug
rl4debug / design-grpc-gateway-error.md
Last active April 10, 2020 12:36
[design grpc gateway error] #grpc

Việc viết document cho API rất quan trọng.

Ta cần viết ra các trường hợp có thể xảy của http response:

  • Trường hợp không thể kết nối tới server, việc xử lý nằm ở client. Nếu đã kết nối được tới server, mọi response trả về phải có định nghĩa schema rõ ràng

Vấn đề phát sinh khi dùng grpc-gateway đó là làm sao để thông báo error message tới user rõ ràng nhất.

Thông thường khi làm việc với GRPC, ta sẽ dùng grpc-gateway làm công cụ để sinh ra client, và server stuff.

Việc xử lý logic của API sẽ nằm trong GRPC handlers, nó có dạng như sau:

@rl4debug
rl4debug / makefile-cheatsheet.md
Created April 3, 2020 15:17
[makefile] #makefile

Special macros:

  • $@ is the name of the file to be made
  • $? is the name of changed depandents
  • $< the name of related file that caused the action
  • $* the prefix shared by target and dependent files
@rl4debug
rl4debug / tdd-references.md
Created March 21, 2020 17:53
[TDD reference]
  • 8k: https://blog.usejournal.com/lean-testing-or-why-unit-tests-are-worse-than-you-think-b6500139a009

  • >1k: https://medium.com/pacroy/why-most-unit-testing-is-waste-tests-dont-improve-quality-developers-do-47a8584f79ab