From b47df2a02fe8da4b50dbb6448f75e5a027a77729 Mon Sep 17 00:00:00 2001 From: Hau Nguyen Date: Sat, 26 Nov 2022 12:03:16 +0700 Subject: [PATCH] chore: add rel=me to mastodon --- docs/2022-06-08-backup.html | 3 ++- docs/2022-06-08-dockerfile-go.html | 3 ++- docs/2022-07-10-bootstrap-go.html | 3 ++- docs/2022-07-12-uuid-or-else.html | 3 ++- docs/2022-07-19-migrate-to-buf.html | 3 ++- docs/2022-07-31-experiment-go.html | 3 ++- docs/2022-07-31-sql.html | 3 ++- docs/2022-08-10-gitignore.html | 3 ++- docs/2022-10-26-reload-config.html | 3 ++- docs/index.html | 3 ++- templates/post.html | 1 + 11 files changed, 21 insertions(+), 10 deletions(-) diff --git a/docs/2022-06-08-backup.html b/docs/2022-06-08-backup.html index df3ca3c..e83dc27 100644 --- a/docs/2022-06-08-backup.html +++ b/docs/2022-06-08-backup.html @@ -11,4 +11,5 @@ restic -r rclone:remote:PrivateData backup PrivateData # Cleanup old backups restic -r rclone:remote:PrivateData forget --keep-last 1 --prune -

The next data is my passwords and my OTPs.
These are the things which I'm scare to lose the most.
First thing first, I enable 2-Step Verification for all of my important accounts, should use both OTP and phone method.

I use Bitwarden for passwords (That is a long story, coming from Google Password manager to Firefox Lockwise and then settle down with Bitwarden) and Aegis for OTPs.
The reason I choose Aegis, not Authy (I use Authy for so long but Aegis is definitely better) is because Aegis allows me to extract all the OTPs to a single file (Can be encrypted), which I use to transfer or backup easily.

As long as Bitwarden provides free passwords stored, I use all of its apps, extensions so that I can easily sync passwords between laptops and phones.
The thing I need to remember is the master password of Bitwarden in my head.

With Aegis, I export the data, then sync it to Google Drive, also store it locally in my phone.

The main problem here is the OTP, I can not store all of my OTPs in the cloud completely.
Because if I want to access my OTPs in the cloud, I should log in, and then input my OTP, this is a circle, my friends.

Recovery strategy

There are many strategies that I process to react as if something strange is happening to my devices.

If I lost my laptops, single laptop or all, do not panic as long as I have my phones.
The OTPs are in there, the passwords are in Bitwarden cloud, other data is in Google Drive so nothing is lost here.

If I lost my phone, but not my laptops, I use the OTPs which are stored locally in my laptops.

In the worst situation, I lost everything, my laptops, my phone.
The first step is to recover my SIM, then log in to Google account using the password and SMS OTP.
After that, log in to Bitwarden account using the master password and OTP from Gmail, which I open previously.

The end

This guide will be updated regularly I promise.

Feel free to ask me via email \ No newline at end of file +

The next data is my passwords and my OTPs.
These are the things which I'm scare to lose the most.
First thing first, I enable 2-Step Verification for all of my important accounts, should use both OTP and phone method.

I use Bitwarden for passwords (That is a long story, coming from Google Password manager to Firefox Lockwise and then settle down with Bitwarden) and Aegis for OTPs.
The reason I choose Aegis, not Authy (I use Authy for so long but Aegis is definitely better) is because Aegis allows me to extract all the OTPs to a single file (Can be encrypted), which I use to transfer or backup easily.

As long as Bitwarden provides free passwords stored, I use all of its apps, extensions so that I can easily sync passwords between laptops and phones.
The thing I need to remember is the master password of Bitwarden in my head.

With Aegis, I export the data, then sync it to Google Drive, also store it locally in my phone.

The main problem here is the OTP, I can not store all of my OTPs in the cloud completely.
Because if I want to access my OTPs in the cloud, I should log in, and then input my OTP, this is a circle, my friends.

Recovery strategy

There are many strategies that I process to react as if something strange is happening to my devices.

If I lost my laptops, single laptop or all, do not panic as long as I have my phones.
The OTPs are in there, the passwords are in Bitwarden cloud, other data is in Google Drive so nothing is lost here.

If I lost my phone, but not my laptops, I use the OTPs which are stored locally in my laptops.

In the worst situation, I lost everything, my laptops, my phone.
The first step is to recover my SIM, then log in to Google account using the password and SMS OTP.
After that, log in to Bitwarden account using the master password and OTP from Gmail, which I open previously.

The end

This guide will be updated regularly I promise.

Feel free to ask me via email +Mastodon \ No newline at end of file diff --git a/docs/2022-06-08-dockerfile-go.html b/docs/2022-06-08-dockerfile-go.html index a17c58f..7a1486a 100644 --- a/docs/2022-06-08-dockerfile-go.html +++ b/docs/2022-06-08-dockerfile-go.html @@ -32,4 +32,5 @@ COPY . . COPY --from=builder /build/app /app ENTRYPOINT ["/app"] -

Finally, I copy app to Distroless base image.

Feel free to ask me via email \ No newline at end of file +

Finally, I copy app to Distroless base image.

Feel free to ask me via email +Mastodon \ No newline at end of file diff --git a/docs/2022-07-10-bootstrap-go.html b/docs/2022-07-10-bootstrap-go.html index 7c61f4b..700dbfa 100644 --- a/docs/2022-07-10-bootstrap-go.html +++ b/docs/2022-07-10-bootstrap-go.html @@ -95,4 +95,5 @@ go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignme # Fix fieldalignment -fix ./internal/business/*.go -

Thanks

Feel free to ask me via email \ No newline at end of file +

Thanks

Feel free to ask me via email +Mastodon \ No newline at end of file diff --git a/docs/2022-07-12-uuid-or-else.html b/docs/2022-07-12-uuid-or-else.html index 93e097a..a612303 100644 --- a/docs/2022-07-12-uuid-or-else.html +++ b/docs/2022-07-12-uuid-or-else.html @@ -1 +1,2 @@ -Index

UUID or else

There are many use cases where we need to use a unique ID.
In my experience, I only encouter 2 cases:

In my Go universe, there are some libs to help us with this:

First use case is trace ID, or context aware ID

The ID is used only for trace and log.
If same ID is generated twice (because maybe the possibilty is too small but not 0), honestly I don't care.
When I use that ID to search log , if it pops more than things I care for, it is still no harm to me.

My choice for this use case is rs/xid.
Because it is small (not span too much on log line) and copy friendly.

Second use case is primary key, also hard choice

Why I don't use auto increment key for primary key?
The answer is simple, I don't want to write database specific SQL.
SQLite has some different syntax from MySQL, and PostgreSQL and so on.
Every logic I can move to application layer from database layer, I will.

In the past and present, I use google/uuid, specificially I use UUID v4.
In the future I will look to use segmentio/ksuid and oklog/ulid (trial and error of course).
Both are sortable, but google/uuid is not.
The reason I'm afraid because the database is sensitive subject, and I need more testing and battle test proof to trust those libs.

What else?

I think about adding prefix to ID to identify which resource that ID represents.

Thanks

Feel free to ask me via email \ No newline at end of file +Index

UUID or else

There are many use cases where we need to use a unique ID.
In my experience, I only encouter 2 cases:

In my Go universe, there are some libs to help us with this:

First use case is trace ID, or context aware ID

The ID is used only for trace and log.
If same ID is generated twice (because maybe the possibilty is too small but not 0), honestly I don't care.
When I use that ID to search log , if it pops more than things I care for, it is still no harm to me.

My choice for this use case is rs/xid.
Because it is small (not span too much on log line) and copy friendly.

Second use case is primary key, also hard choice

Why I don't use auto increment key for primary key?
The answer is simple, I don't want to write database specific SQL.
SQLite has some different syntax from MySQL, and PostgreSQL and so on.
Every logic I can move to application layer from database layer, I will.

In the past and present, I use google/uuid, specificially I use UUID v4.
In the future I will look to use segmentio/ksuid and oklog/ulid (trial and error of course).
Both are sortable, but google/uuid is not.
The reason I'm afraid because the database is sensitive subject, and I need more testing and battle test proof to trust those libs.

What else?

I think about adding prefix to ID to identify which resource that ID represents.

Thanks

Feel free to ask me via email +Mastodon \ No newline at end of file diff --git a/docs/2022-07-19-migrate-to-buf.html b/docs/2022-07-19-migrate-to-buf.html index 012feaa..28e0fed 100644 --- a/docs/2022-07-19-migrate-to-buf.html +++ b/docs/2022-07-19-migrate-to-buf.html @@ -50,4 +50,5 @@ plugins: buf mod update buf format -w buf generate -

Run make gen to have fun of course.

FAQ

Remember grpc-ecosystem/grpc-gateway, envoyproxy/protoc-gen-validate, kei2100/protoc-gen-marshal-zap is optional, so feel free to delete if you don't use theme.

If use vendor:

If you use grpc-gateway:

The last step is delete prototool.yaml.

If you are not migrate but start from scratch:

Thanks

Feel free to ask me via email \ No newline at end of file +

Run make gen to have fun of course.

FAQ

Remember grpc-ecosystem/grpc-gateway, envoyproxy/protoc-gen-validate, kei2100/protoc-gen-marshal-zap is optional, so feel free to delete if you don't use theme.

If use vendor:

If you use grpc-gateway:

The last step is delete prototool.yaml.

If you are not migrate but start from scratch:

Thanks

Feel free to ask me via email +Mastodon \ No newline at end of file diff --git a/docs/2022-07-31-experiment-go.html b/docs/2022-07-31-experiment-go.html index b78e0fd..0e33884 100644 --- a/docs/2022-07-31-experiment-go.html +++ b/docs/2022-07-31-experiment-go.html @@ -26,4 +26,5 @@ type ClientAccount interface { // c is Client c.User.Get() c.Account.Remove() -

The difference is c.GetUser() -> c.User.Get().

For example we have client which connect to bank.
There are many functions like GetUser, GetTransaction, VerifyAccount, ...
So split big client to many children, each child handle single aspect, like user or transaction.

My concert is we replace an interface with a struct which contains multiple interfaces aka children.
I don't know if this is the right call.

This pattern is used by google/go-github.

Find alternative to grpc/grpc-go

Why?
See for yourself

Currently there are 2:

Thanks

Feel free to ask me via email \ No newline at end of file +

The difference is c.GetUser() -> c.User.Get().

For example we have client which connect to bank.
There are many functions like GetUser, GetTransaction, VerifyAccount, ...
So split big client to many children, each child handle single aspect, like user or transaction.

My concert is we replace an interface with a struct which contains multiple interfaces aka children.
I don't know if this is the right call.

This pattern is used by google/go-github.

Find alternative to grpc/grpc-go

Why?
See for yourself

Currently there are 2:

Thanks

Feel free to ask me via email +Mastodon \ No newline at end of file diff --git a/docs/2022-07-31-sql.html b/docs/2022-07-31-sql.html index 8992829..7703781 100644 --- a/docs/2022-07-31-sql.html +++ b/docs/2022-07-31-sql.html @@ -12,4 +12,5 @@ WHERE field_something != 1 SELECT * FROM table WHERE (field_something IS NULL OR field_something != 1) -

Need clarify why this happpen? Idk :(

VARCHAR or TEXT

Prefer VARCHAR if you need to query and of course use index, and make sure size of value will never hit the limit.
Prefer TEXT if you don't care, just want to store something.

Be super careful when migrate, update database on production and online!!!

Plase read docs about online ddl operations before do anything online (keep database running the same time update it, for example create index, ...)

Tools

Thanks

Feel free to ask me via email \ No newline at end of file +

Need clarify why this happpen? Idk :(

VARCHAR or TEXT

Prefer VARCHAR if you need to query and of course use index, and make sure size of value will never hit the limit.
Prefer TEXT if you don't care, just want to store something.

Be super careful when migrate, update database on production and online!!!

Plase read docs about online ddl operations before do anything online (keep database running the same time update it, for example create index, ...)

Tools

Thanks

Feel free to ask me via email +Mastodon \ No newline at end of file diff --git a/docs/2022-08-10-gitignore.html b/docs/2022-08-10-gitignore.html index 54344a7..7567a39 100644 --- a/docs/2022-08-10-gitignore.html +++ b/docs/2022-08-10-gitignore.html @@ -16,4 +16,5 @@ coverage.out # Should ignore vendor vendor

Python

venv
-
Feel free to ask me via email \ No newline at end of file +Feel free to ask me via email +Mastodon \ No newline at end of file diff --git a/docs/2022-10-26-reload-config.html b/docs/2022-10-26-reload-config.html index b90d6fa..eaa79f1 100644 --- a/docs/2022-10-26-reload-config.html +++ b/docs/2022-10-26-reload-config.html @@ -42,4 +42,5 @@ other_service -> other_service: do other business deactivate other_service @enduml -

Config storage can be any key value storage or database like etcd, Consul, mySQL, ...

If storage is key value storage, maybe there is API to listen on config change.
Otherwise we should create a loop to get all config from storage for some interval, for example each 5 minute.

Each other_service need to get config from its memory, not hit storage.
So there is some delay between upstream config (config in storage) and downstream config (config in other_service), but maybe we can forgive that delay (???).

Pros:

Cons:

Feel free to ask me via email \ No newline at end of file +

Config storage can be any key value storage or database like etcd, Consul, mySQL, ...

If storage is key value storage, maybe there is API to listen on config change.
Otherwise we should create a loop to get all config from storage for some interval, for example each 5 minute.

Each other_service need to get config from its memory, not hit storage.
So there is some delay between upstream config (config in storage) and downstream config (config in other_service), but maybe we can forgive that delay (???).

Pros:

Cons:

Feel free to ask me via email +Mastodon \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index f1cca0b..394e457 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1 +1,2 @@ -Index

Index

This is where I dump my thoughts.

Feel free to ask me via email \ No newline at end of file +Index

Index

This is where I dump my thoughts.

Feel free to ask me via email +Mastodon \ No newline at end of file diff --git a/templates/post.html b/templates/post.html index 26028a6..47ee178 100644 --- a/templates/post.html +++ b/templates/post.html @@ -21,5 +21,6 @@ Feel free to ask me via email + Mastodon