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 @@
~
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.
-
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 ~
APIs tools:
-
Backup work related data
+
+ Backup work related data
@@ -285,15 +279,13 @@ restic -r rclone:remote:PrivateData restore latest --target ~
Stay away from Postman, it's lag and you can accidentally upload private
data publicly.
There are many strategies that I process to react as if something strange
@@ -316,15 +308,10 @@ restic -r rclone:remote:PrivateData restore latest --target ~
master password and OTP from Gmail, which I log in previously.
-
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 ~
This guide will be updated regularly I promise.
Each time I start a new Go project, I repeat many steps. Like set up
@@ -165,15 +163,10 @@
ENTRYPOINT ["/app"]
Finally, I copy
It is hard to write bootstrap tool to quickly create Go service. So I
@@ -44,15 +42,10 @@
I need to write a Go service from scratch. Also, this is my personal
opinion, so feel free to comment.
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.
If I see someone using global var, I swear I will shoot them twice in the
@@ -186,15 +173,13 @@ internal
For simple struct with 1 or 2 fields, no need to use functional options.
@@ -240,19 +225,15 @@ internal
If business logic involves calling too many APIs, but they are not depend
@@ -285,35 +266,33 @@ internal
// Handle error
}
Please don't use external libs for WorkerPool, I don't want to deal with
dependency hell.
Example:
Only need if you need something from To easily control version of build tools. For example
What is the point to pass many params ( 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.
prototool is deprecated, and buf can generate, lint, format as good as
prototool.
With It is fast!
Only init config in main or cmd layer. Do not use
@@ -547,15 +493,17 @@ internal
Also, be careful if config value is empty. You should decide to continue
or stop the service if there is empty config.
Each ORM libs has each different syntax. To learn and use those libs
@@ -577,16 +525,11 @@ internal
those cases. I hear that
go-gorm/gorm is good.
Be careful when use
@@ -648,16 +591,11 @@ internal
Remember to config: Remember to config:
-
Misc
+
+ Misc
-
The end
+
+ The end
- ~
-
Dockerfile for Go
+
+ Dockerfile for Go
app
to Distroless base image.
-
Thanks
+
+ Thanks
- ~
-
Bootstrap Go
+
+ Bootstrap Go
-
Structure
+
+ Structure
@@ -135,15 +128,13 @@ internal
business
.
-
-
Do not repeat!
+
+ Do not repeat!
-
Taste on style guide
+
+ Taste on style guide
-
-
Stop using global var
+
+ Stop using global var
-
Use functional options, but don't overuse it!
+
+ Use functional options, but don't overuse it!
WithB
option. No need to pass direct field inside
s
.
-
+ Use errgroup
- as much as possible
+ as much as possible
Use
-
+
Use semaphore
- when need to implement WorkerPool
+ when need to implement WorkerPool
Use
-
+
sync.Pool when
+ >Use sync.Pool when
need to reuse object, mainly for
Use
- bytes.Buffer
+
-
External libs
+
+ External libs
-
-
No need vendor
+
+ No need
vendor
+
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
build.go
:go.mod
each time
we install it. Future contributors will not cry anymore.
+
spf13/cobra, urfave/cli) just for Go
- service
+ >Don't use cli libs (spf13/cobra,
+ urfave/cli) just for Go
+ service
Don't use cli libs (do-it
,
@@ -422,18 +393,13 @@ internal
The Twelve Factors
guide.
-
+ Don't use grpc-ecosystem/grpc-gateway
+
Don't use
-
- uber/prototool,
- use bufbuild/buf
+
Don't use
+ Don't use uber/prototool, use
+ bufbuild/buf
+
- gin-gonic/gin for
- REST.
+
Use
+ Use gin-gonic/gin for
+ REST.
c *gin.Context
:
@@ -491,16 +447,11 @@ internal
}
}()
-
- uber-go/zap
+
If you want log, just use
-
+ If you want log, just use uber-go/zap
+
@@ -523,16 +474,11 @@ internal
for easily debug.
-
- spf13/viper
+
To read config, use
-
+ To read config, use spf13/viper
+
+
Don't overuse ORM libs, no need to handle another layer above SQL.
+ >Don't overuse ORM libs, no need to handle another layer above SQL.
- redis/go-redis
+
Connect Redis with
-
+ Connect Redis with redis/go-redis
+
- ReadTimeout
, WriteTimeout
- go-sql-driver/mysql
+
Connect MySQL with
-
+ Connect MySQL with go-sql-driver/mysql
+
@@ -669,18 +607,13 @@ internal
- CheckConnLiveness
to true.ReadTimeout
, WriteTimeout
-
+ Connect SQLite with modernc.org/sqlite
+
Connect SQLite with
-
@@ -694,15 +627,11 @@ internal
mattn/go-sqlite3, it's
required
CGO_ENABLED
.
Use sarama.V1_0_0_0
, because IBM decide to upgrade default
@@ -714,32 +643,26 @@ internal
>confluentinc/confluent-kafka-go, it's required CGO_ENABLED
.
It is easy to write a suite test, thanks to testify. Also, for mocking, there are many options out there. Pick 1 then sleep peacefully.
-The first is easy to use but not powerful as the later. If you want to @@ -751,15 +674,11 @@ internal // https://jonwillia.ms/2019/12/22/conditional-gomock-mockgen //go:generate sh -c "test service_mock_generated.go -nt $GOFILE && exit 0; moq -rm -out service_mock_generated.go . Service" -
Don't cast proto enum:
type Drink int
@@ -800,51 +720,40 @@ internal
# Run inside directory which contains Drink
stringer -type=Drink
rate if you want rate limiter locally in your single instance of service. redis_rate if you want rate limiter distributed across all your instances of service.
-go fmt
, goimports
with mvdan/gofumpt.
gofumpt
provides more rules when format Go codes.
No need to say more. Lint or get the f out!
@@ -863,15 +772,13 @@ go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignme # Fix fieldalignment -fix ./internal/business/*.go -
Change import:
go clean -cache -testcache -modcache -fuzzcache -x
~
There are many use cases where we need to use a unique ID. In my @@ -56,15 +54,15 @@
The ID is used only for trace and log. If same ID is generated twice @@ -76,15 +74,15 @@ My choice for this use case is rs/xid. Because it is small (not span too much on log line) and copy friendly.
-Why I don't use auto increment key for primary key? The answer is simple, @@ -101,29 +99,19 @@ database is sensitive subject, and I need more testing and battle test proof to trust those libs.
-I think about adding prefix to ID to identify which resource that ID represents.
-~
buf
from prototool
+ buf
from prototool
+
Why? Because prototool
is outdated, and can not run on M1
@@ -146,15 +142,10 @@
sed -i "" -e "s/import \"marshal-zap\.proto\";//g" ./raw/api.proto
sed -i "" -e "s/\[(marshal_zap\.mask) = true]//g" ./raw/api.proto
Remember bufbuild/protoc-gen-validate
,
@@ -204,15 +195,10 @@
compatibility.
-
Some experience I got after writing proto files for a living:
sed
to fix the damn things.
~
There come a time when you need to experiment new things, new style, new approach. So this post serves as it is named.
-Instead of:
Why? @@ -146,15 +141,10 @@
~
Previously in my fresher software developer time, I rarely write SQL, I @@ -48,29 +43,25 @@ This guide is not kind of guide which cover all cases. Just my little tricks when I work with SQL.
-Use UUID instead. If you can, and you should, choose UUID type which can be sortable.
-Stay away from all kind of database timestamp (MySQL timestmap, SQLite @@ -89,15 +80,13 @@ [Business] time, data -> convert to unix timestamp milliseconds -> [Database] int64
Create new column in database is scary, so I suggest avoid it if you can. @@ -106,15 +95,13 @@
I always use MySQL json data type for extra field.
JSON data type also used for dumping request, response data.
-You should use index for faster query, but not too much. Don't create @@ -157,15 +144,13 @@ >
If compare with field which can be NULL, remember to check NULL for @@ -185,46 +170,36 @@ WHERE (field_something IS NULL OR field_something != 1)
Need clarify why this happpen? Idk :(
-VARCHAR
or TEXT
+
- 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.
LIMIT
+ LIMIT
Prefer LIMIT 10 OFFSET 5
to LIMIT 5, 10
to avoid
misunderstanding.
Plase read docs about online ddl operations before do anything online @@ -257,26 +232,16 @@ > -
Use SELECT 1
to check if database failed yet.
~
My quick check for .gitignore
.
# macOS
@@ -62,15 +52,10 @@
# VSCode
.vscode/
# Go
@@ -80,15 +65,10 @@ coverage.out
# Should ignore vendor
vendor
venv
~
This serves as design draft of reload config system
~
Install Arch Linux is thing I always want to do for my laptop/PC since I @@ -46,29 +44,21 @@ This is not a guide for everyone, this is just save for myself in a future and for anyone who want to walk in my shoes.
-Check disks carefully:
lsblk
Check UEFI mode:
ls /sys/firmware/efi/efivars
For wifi, use iwd.
-# boot mount --mkdir /dev/extended_boot_loader_partition /mnt/boot
pacstrap -K /mnt base linux linux-firmware
@@ -268,53 +250,32 @@ pacstrap -K /mnt lvm2
# Text editor
pacstrap -K /mnt neovim
genfstab -U /mnt >> /mnt/etc/fstab
arch-chroot /mnt
@@ -323,15 +284,13 @@ ln -sf /usr/share/zoneinfo/Region/City /etc/localtime
hwclock --systohc
Edit /etc/locale.gen
:
LANG=en_US.UTF-8
Edit /etc/hostname
:
myhostname
Edit /etc/mkinitcpio.conf
:
mkinitcpio -P
passwd
pacman -Syu networkmanager dhcpcd iwd
@@ -441,56 +380,35 @@ noarp
nohook resolv.conf
pacman -Syu bluez
systemctl enable bluetooth.service
timedatectl set-ntp true
Install using XBOOTLDR:
Always remember to check dependencies when install packages.
-
Sudo
Note: Can not run homectl
when install Arch
Linux. Should run on the first boot.
Install @@ -622,17 +530,11 @@ homectl update joker --shell=/usr/bin/zsh
pacman -Syu xorg-server
pacman -Syu gnome-shell \
@@ -645,31 +547,19 @@ homectl update joker --shell=/usr/bin/zsh
pacman -Syu gdm
systemctl enable gdm.service
Uncomment in /etc/pacman.conf
:
@@ -707,34 +591,22 @@ pacman -Syu pipewire wireplumber \
pacman -Syu sof-firmware
-
- Flatpak (WIP)
+ >
+
pacman -Syu flatpak
-
- Improving performance
+ >
+
Do it at your own risk!!!
This guide is updated regularly I promise.
diff --git a/docs/2022-12-25-go-test-asap.html b/docs/2022-12-25-go-test-asap.html index 4ee3ab9..ff8f086 100644 --- a/docs/2022-12-25-go-test-asap.html +++ b/docs/2022-12-25-go-test-asap.html @@ -28,15 +28,13 @@~
Imagine your project currently have 0% unit test code coverage. And your @@ -57,15 +55,13 @@ just make sure your code is running excatly as you intent it to be. If you don't think about edge case before, unit test won't help you.
-When I learn programming, I encounter very interesting idea, which become @@ -89,15 +85,13 @@ all global var to fields inside some struct. -
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 @@
~
This is collect of all incidents I created in the past :(
-Because all configs is read from file.
@@ -58,15 +54,13 @@ Solution: For some configs, make sure to failed first if it's empty.
-For example I have 2 APIs:
~
TODO
diff --git a/docs/2023-03-30-fonts.html b/docs/2023-03-30-fonts.html index 9461ca2..61ebdfd 100644 --- a/docs/2023-03-30-fonts.html +++ b/docs/2023-03-30-fonts.html @@ -28,15 +28,10 @@~
I always want the best fonts for my terminal, my text editor, my ... But @@ -68,15 +63,10 @@ All images belows is either official images I got from fonts website or my own screenshots. I'm too lazy to screenshot anw :D
-JetBrains branding font.
cv16
, cv18
, cv19
,
cv20
.
- I often choose SS08 variant because I also love @@ -140,15 +125,10 @@ style="max-width: 100%" />
-I often choose Casual variant.
Looks unique to me, with some sharp look.
-I love its wide look, also it's feel nostalgic.
-Small fonts, saving space.
#
, looks same as 4
(I
don't like it for now).
- ~
Just a little note about apps, games, settings for next time playing :D @@ -47,15 +42,13 @@
If below links die, I will try to scrape Internet to get a new link.
-I use PCSX2. Currently it @@ -103,17 +96,11 @@ For cover art of games, please use xlenore/ps2-covers.
-I use RPCS3. Currently it diff --git a/docs/2023-04-17-keeb.html b/docs/2023-04-17-keeb.html index b3702f6..e196e7d 100644 --- a/docs/2023-04-17-keeb.html +++ b/docs/2023-04-17-keeb.html @@ -28,52 +28,38 @@
~
My collection of mechanical keyboards.
-QMK custom keymaps is here
-My first keeb.
Damn it's so loud :D
-I bought it from my friend.
@@ -114,15 +100,10 @@ style="max-width: 100%" />
-My layout is based on:
Space
7U.Things I don't like, also @@ -258,15 +229,13 @@
I choose this switch because I prefer linear (please be silent).
@@ -381,15 +338,10 @@ style="max-width: 100%" />
-I was given this switch by my friend. Currently using for alpha keys. Love @@ -459,15 +407,10 @@ style="max-width: 100%" />
-I was given this switch by my friend, full mod (lube + film).
-Currently, I use Akko 9009 Cherry Profile and EnjoyPBT 9009 Cherry @@ -577,15 +504,13 @@
~
Always have year, month, day in filename to easily sort it out.
@@ -67,15 +63,13 @@ backup (as they say, idk if true or not, but less folder mean less complicated to me).
-Add time postfix to make sense.
Instead of create_at
, use create_at_ms
.
~
Search current word: *
Search multiple words:
@@ -98,15 +94,10 @@:!column -t
Basic:
zR
: open all folds.za
, zA
: toggle foldUse both \
and ;
as leader key:
~
The way Discord naming user likeJoker#1234
is so interesting.
@@ -58,15 +54,13 @@
Why it's interesting? Each time I join a new platform, all names I want
are taken :D
~
My company currently use Swagger 2 to document API.
@@ -65,15 +63,10 @@ bunx prettier --write ./docs/swagger.yaml ./docs/swagger.json # Render locally bunx @redocly/cli preview-docs ./docs/swagger.json
~
All configs are in my dotfiles.
-CTRL-T
to fuzzy find files.ALT-C
to fuzzy find directories.
ALT-]
/ALT-[
: next/previous tab
SHIFT
and click on links, text, ...
CTRL-SHIFT-F
/CMD-F
: search modeCTRL-SHIFT-X
: copy modeCMD-SHIFT-[
/CMD-SHIFT-]
: switch tabs;-p
: preview mode~
Today's incident is all about Go context.
TLDR: context got canceled, but it shouldn't.
-Imagine a chain of APIs:
As you see both doA
and doB
are canceled.
Quick Google search leads me to
@@ -246,15 +237,10 @@ doBdoA is canceled, doB
is done
perfectly. And that what we want in this case.
~
The title is a joke.
diff --git a/docs/2023-06-25-useful-tools.html b/docs/2023-06-25-useful-tools.html index 16a242c..207748a 100644 --- a/docs/2023-06-25-useful-tools.html +++ b/docs/2023-06-25-useful-tools.html @@ -28,36 +28,24 @@
~
This just a raw list.
-Memory
MacPorts/native package manager > go/rust/pip.
Ignore HomeBrew, nix (for now).
@@ -846,26 +814,16 @@Don't enable plugin git
in ohmyzsh.
Hide Developer in Spotlight:
Fix black screen when open game in fullscreen in external monitor with @@ -892,15 +845,10 @@ xcode-select --install >kazysmaster/gnome-shell-extension-disable-unredirect
-about:config
:
~
Just a place to throw away some text.
-.gitignore
+ .gitignore
# macOS
@@ -69,15 +63,13 @@ vendor
# GoReleaser
dist
dependabot.yml
:
.golangci.yml
:
# Delete untracked
@@ -298,15 +283,11 @@ git clean -fdx
git gc
.DS_Store
+ .DS_Store
+
With @@ -319,29 +300,19 @@ git gc
fd -H '^\.DS_Store$' -tf -X rm
Remove duplicated files:
fdupes -rdN .
# Result is dst/src
@@ -371,30 +342,20 @@ rsync -avzP src/ dst
in src, useful to sync dst with src
- Rename:
# If want dry run, remove -x
f2 -r "{mtime.YYYY}{mtime.MM}{mtime.DD}.{mtime.H}{mtime.mm}{mtime.ss}{ext}" -x
args.txt
:
instaloader +login.txt +args.txt +targets.txt
grpcurl -proto path/file.proto \
diff --git a/docs/2023-07-02-fandroid.html b/docs/2023-07-02-fandroid.html
index 03634da..9918bb8 100644
--- a/docs/2023-07-02-fandroid.html
+++ b/docs/2023-07-02-fandroid.html
@@ -28,28 +28,21 @@
~
-
-
+ F(an) android
F(an) android
+ You know what I mean :D
Just a collection/checklist while using Android phone.
All Android phones are bloat.
-
-
+ Apps
Apps
+
Use F-Droid with
diff --git a/docs/2023-07-06-redis.html b/docs/2023-07-06-redis.html
index dd89189..e73cd1a 100644
--- a/docs/2023-07-06-redis.html
+++ b/docs/2023-07-06-redis.html
@@ -28,26 +28,19 @@
~
-
-
+ Redis
Redis
+ Just to save my noted for future me using Redis again.
-
-
+ Redis does not store creation time of keys
Redis does not store creation time of keys
+ Why? Because TODO
diff --git a/docs/2023-07-30-cache-shenanigan.html b/docs/2023-07-30-cache-shenanigan.html
index 45287e3..2ff87ac 100644
--- a/docs/2023-07-30-cache-shenanigan.html
+++ b/docs/2023-07-30-cache-shenanigan.html
@@ -28,15 +28,13 @@
~
-
-
+ Cache shenanigan
Cache shenanigan
+
My notes/mistakes/... when using cache (mainly Redis) from time to time
@@ -84,15 +82,10 @@
database has new value, but cache has old value Then when we read again,
we read cache first with old value, and that is disaster.
-
-
+ Thanks
-
diff --git a/docs/2023-08-09-vscode.html b/docs/2023-08-09-vscode.html
index 5708c04..72ab1a6 100644
--- a/docs/2023-08-09-vscode.html
+++ b/docs/2023-08-09-vscode.html
@@ -28,15 +28,10 @@
~
-
-
+ VSCode
VSCode
+ Favortite settings everytime I install VSCode.
diff --git a/docs/2023-08-20-hardware.html b/docs/2023-08-20-hardware.html
index d134254..34115d9 100644
--- a/docs/2023-08-20-hardware.html
+++ b/docs/2023-08-20-hardware.html
@@ -28,15 +28,13 @@
~
-
-
+ Hardware 101
Hardware 101
+
Just kidding. It's only my collect data about which hardware to use/buy.
diff --git a/docs/2023-08-23-real-world-crypto.html b/docs/2023-08-23-real-world-crypto.html
index b533986..b8e24e4 100644
--- a/docs/2023-08-23-real-world-crypto.html
+++ b/docs/2023-08-23-real-world-crypto.html
@@ -28,15 +28,13 @@
~
-
-
+ Real World Crypto 101
Real World Crypto 101
+
My notes when reading
@@ -46,16 +44,16 @@
>Real-World Cryptography
-
+
- Hash function convert from input to digest
- Pre-image resistance: Given digest, can not find input
@@ -65,17 +63,19 @@
- Collision resistance: Can not find 2 input produce same digest.
-
+
- MAC aka Message Authentication Code produce from key,
- message to authentication tag.
- A send B message with MAC (generate from message and A key).
diff --git a/docs/2023-09-14-vietnam-survivor.html b/docs/2023-09-14-vietnam-survivor.html
index 1aabea1..5d195b3 100644
--- a/docs/2023-09-14-vietnam-survivor.html
+++ b/docs/2023-09-14-vietnam-survivor.html
@@ -28,15 +28,13 @@
~
-
-
+ Vietnam survivor
Vietnam survivor
+ Written by Vietnamese for Vietnamese.
Every Vietnamese person must/should has:
diff --git a/docs/index.html b/docs/index.html
index 70ffa16..37cfa9f 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -25,15 +25,10 @@
}
-
-
+ Index
Index
+ This is where I dump my thoughts.
diff --git a/posts/2023-06-25-useful-tools.md b/posts/2023-06-25-useful-tools.md
index dbac67a..a91008f 100644
--- a/posts/2023-06-25-useful-tools.md
+++ b/posts/2023-06-25-useful-tools.md
@@ -69,6 +69,12 @@ Fun memory
- https://github.com/instaloader/instaloader
- https://gitlab.com/phoneybadger/pokemon-colorscripts
+#### Windows
+
+- https://github.com/abbodi1406/KMS_VL_ALL_AIO
+- https://github.com/massgravel/Microsoft-Activation-Scripts
+- https://github.com/abbodi1406/vcredist
+
### UI
- https://github.com/kovidgoyal/kitty
Thanks
+