From 8139b361323488c83a47e49a638b7854c291f93e Mon Sep 17 00:00:00 2001 From: Hau Nguyen Date: Wed, 28 Sep 2022 00:48:51 +0700 Subject: [PATCH] chore: use iosevka web fonts See https://github.com/google/fonts/issues/559 See https://github.com/google/fonts/issues/4728 FYI, ..., u know what I mean --- README.md | 3 +++ docs/2022-06-08-backup.html | 2 +- docs/2022-06-08-dockerfile-go.html | 2 +- docs/2022-07-10-bootstrap-go.html | 2 +- docs/2022-07-12-uuid-or-else.html | 2 +- docs/2022-07-19-migrate-to-buf.html | 2 +- docs/2022-07-31-experiment-go.html | 2 +- docs/2022-07-31-sql.html | 2 +- docs/2022-08-10-gitignore.html | 2 +- docs/index.html | 2 +- docs/styles.css | 2 +- templates/post.html | 4 ++++ templates/styles.css | 2 +- 13 files changed, 18 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 28c7895..4e08796 100644 --- a/README.md +++ b/README.md @@ -22,3 +22,6 @@ make - https://perfectmotherfuckingwebsite.com/ - https://primer.style/design/foundations/color - https://primer.style/primitives/colors +- https://github.com/arrowtype/recursive +- https://github.com/be5invis/Iosevka +- https://github.com/ntk148v/iosevkawebfont diff --git a/docs/2022-06-08-backup.html b/docs/2022-06-08-backup.html index e18a84b..206f8d6 100644 --- a/docs/2022-06-08-backup.html +++ b/docs/2022-06-08-backup.html @@ -1,4 +1,4 @@ -Index

Backup my way

First thing first, I want to list my own devices, which I have through the years:

App/Service I use daily:

The purpose is that I want my data to be safe, secure, and can be easily recovered if I lost some devices;
or in the worst situation, I lost all.
Because you know, it is hard to guess what is waiting for us in the future.

There are 2 sections which I want to share, the first is How to backup, the second is Recover strategy.

How to backup

Before I talk about backup, I want to talk about data.
In specifically, which data should I backup?

I use Arch Linux and macOS, primarily work in the terminal so I have too many dotfiles, for example, ~/.config/nvim/init.lua.
Each time I reinstall Arch Linux (I like it a lot), I need to reconfigure all the settings, and it is time-consuming.

So for the DE and UI settings, I keep it as default as possible, unless it's getting in my way, I leave the default setting there and forget about it.
The others are dotfiles, which I write my own dotfiles tool to backup and reconfigure easily and quickly.
Also, I know that installing Arch Linux is not easy, despite I install it too many times (Like thousand times since I was in high school).
Not because it is hard, but as life goes on, the official install guide keeps getting new update and covering too many cases for my own personal use, so I write my own guide to quickly capture what I need to do.
I back up all my dotfiles inside my dotfiles tool in GitHub and GitLab as I trust them both.
Also as I travel the Internet, I discover Codeberg and Treehouse and use them as another backup for git repo.

So that is my dotfiles, for my regular data, like Wallpaper or Books, Images, I use Google Drive (Actually I pay for it).
But the step: open the webpage, click the upload button and choose files seems boring and time-consuming.
So I use Rclone, it supports Google Drive, One Drive and many providers but I only use Google Drive for now.
The commands are simple:

# Sync from local to remote
+Index

Backup my way

First thing first, I want to list my own devices, which I have through the years:

  • Laptop Samsung NP300E4Z-S06VN (Old laptop which I give to my mom)
  • Laptop Dell Inspiron 15 3567 (My mom bought it for me when I go to college, I give it to my sister afterward)
  • Laptop Acer Nitro AN515-45 (Gaming laptop which I buy for gaming, of course)
  • MacBook Pro M1 2020 (My company laptop)
  • Phone Xiaomi Poco X3 NFC (Primary phone which I use daily)

App/Service I use daily:

The purpose is that I want my data to be safe, secure, and can be easily recovered if I lost some devices;
or in the worst situation, I lost all.
Because you know, it is hard to guess what is waiting for us in the future.

There are 2 sections which I want to share, the first is How to backup, the second is Recover strategy.

How to backup

Before I talk about backup, I want to talk about data.
In specifically, which data should I backup?

I use Arch Linux and macOS, primarily work in the terminal so I have too many dotfiles, for example, ~/.config/nvim/init.lua.
Each time I reinstall Arch Linux (I like it a lot), I need to reconfigure all the settings, and it is time-consuming.

So for the DE and UI settings, I keep it as default as possible, unless it's getting in my way, I leave the default setting there and forget about it.
The others are dotfiles, which I write my own dotfiles tool to backup and reconfigure easily and quickly.
Also, I know that installing Arch Linux is not easy, despite I install it too many times (Like thousand times since I was in high school).
Not because it is hard, but as life goes on, the official install guide keeps getting new update and covering too many cases for my own personal use, so I write my own guide to quickly capture what I need to do.
I back up all my dotfiles inside my dotfiles tool in GitHub and GitLab as I trust them both.
Also as I travel the Internet, I discover Codeberg and Treehouse and use them as another backup for git repo.

So that is my dotfiles, for my regular data, like Wallpaper or Books, Images, I use Google Drive (Actually I pay for it).
But the step: open the webpage, click the upload button and choose files seems boring and time-consuming.
So I use Rclone, it supports Google Drive, One Drive and many providers but I only use Google Drive for now.
The commands are simple:

# Sync from local to remote
 rclone sync MyBooks remote:MyBooks -P --exclude .DS_Store
 
 # Sync from remote to local
diff --git a/docs/2022-06-08-dockerfile-go.html b/docs/2022-06-08-dockerfile-go.html
index a28914c..b5befb6 100644
--- a/docs/2022-06-08-dockerfile-go.html
+++ b/docs/2022-06-08-dockerfile-go.html
@@ -1,4 +1,4 @@
-Index

Dockerfile for Go

Each time I start a new Go project, I repeat many steps.
Like set up .gitignore, CI configs, Dockerfile, ...

So I decide to have a baseline Dockerfile like this:

FROM golang:1.18-bullseye as builder
+Index

Dockerfile for Go

Each time I start a new Go project, I repeat many steps.
Like set up .gitignore, CI configs, Dockerfile, ...

So I decide to have a baseline Dockerfile like this:

FROM golang:1.18-bullseye as builder
 
 RUN go install golang.org/dl/go1.18@latest \
     && go1.18 download
diff --git a/docs/2022-07-10-bootstrap-go.html b/docs/2022-07-10-bootstrap-go.html
index 9265b49..0c36890 100644
--- a/docs/2022-07-10-bootstrap-go.html
+++ b/docs/2022-07-10-bootstrap-go.html
@@ -1,4 +1,4 @@
-Index

Bootstrap Go

It is hard to write bootstrap tool to quickly create Go service.
So I write this guide instead.
This is a quick checklist for me every damn time I need to write a Go service from scratch.
Also, this is my personal opinion, so feel free to comment.

Structure

main.go
+Index

Bootstrap Go

It is hard to write bootstrap tool to quickly create Go service.
So I write this guide instead.
This is a quick checklist for me every damn time I need to write a Go service from scratch.
Also, this is my personal opinion, so feel free to comment.

Structure

main.go
 internal
 | business
 | | http
diff --git a/docs/2022-07-12-uuid-or-else.html b/docs/2022-07-12-uuid-or-else.html
index 93fec15..dd94709 100644
--- a/docs/2022-07-12-uuid-or-else.html
+++ b/docs/2022-07-12-uuid-or-else.html
@@ -1 +1 @@
-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:

  • ID to trace request from client to server, from service to service (microservice architecture or nanoservice I don't know).
  • Primary key for database.

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:

  • ID to trace request from client to server, from service to service (microservice architecture or nanoservice I don't know).
  • Primary key for database.

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 diff --git a/docs/2022-07-19-migrate-to-buf.html b/docs/2022-07-19-migrate-to-buf.html index 1f41e34..e792171 100644 --- a/docs/2022-07-19-migrate-to-buf.html +++ b/docs/2022-07-19-migrate-to-buf.html @@ -1,4 +1,4 @@ -Index

Migrate to buf from prototool

Why? Because prototool is outdated, and can not run on M1 mac.

There are 2 use cases:

We need 3 files:

  • build.go: need to install protoc-gen-* binaries with pin version in go.mod
  • buf.yaml
  • buf.gen.yaml

FYI, the libs version I use:

gRPC only

build.go:

//go:build tools
+Index

Migrate to buf from prototool

Why? Because prototool is outdated, and can not run on M1 mac.

There are 2 use cases:

We need 3 files:

  • build.go: need to install protoc-gen-* binaries with pin version in go.mod
  • buf.yaml
  • buf.gen.yaml

FYI, the libs version I use:

gRPC only

build.go:

//go:build tools
 // +build tools
 
 import (
diff --git a/docs/2022-07-31-experiment-go.html b/docs/2022-07-31-experiment-go.html
index 32e029e..44067d1 100644
--- a/docs/2022-07-31-experiment-go.html
+++ b/docs/2022-07-31-experiment-go.html
@@ -1,4 +1,4 @@
-Index

Experiment Go

There come a time when you need to experiment new things, new style, new approach.
So this post serves as it is named.

Design API by trimming down the interface/struct or whatever

Instead of:

type Client interface {
+Index

Experiment Go

There come a time when you need to experiment new things, new style, new approach.
So this post serves as it is named.

Design API by trimming down the interface/struct or whatever

Instead of:

type Client interface {
     GetUser()
     AddUser()
     GetAccount()
diff --git a/docs/2022-07-31-sql.html b/docs/2022-07-31-sql.html
index fb52929..9ad9529 100644
--- a/docs/2022-07-31-sql.html
+++ b/docs/2022-07-31-sql.html
@@ -1,4 +1,4 @@
-Index

SQL

Previously in my fresher time, I rarely write SQL, I always use ORM to wrap SQL.
But time past and too much abstraction bites me.
So I decide to only write SQL from now, no more ORM for me.
But if there is any cool ORM for Go, I guess I try.

This guide is not kind of guide which cover all cases.
Just my little tricks when I work with SQL.

Stay away from database unique id

Use UUID instead.

Stay away from database timestamp

Stay away from all kind of timestamp, timestamp of MySQL or any database.
Just use int64 then pass the timestamp in service layer not database layer.

Why? Because time and date and location are too much complex to handle.
In my business, I use timestamp in milliseconds.
Then I save timestamp as int64 value to database.
Each time I get timestamp from database, I parse to time struct in Go with location or format I want.
No more hassle!

Use index

You should use index for faster query, but not too much.
Don't create index for every fields in table.
Choose wisely!

For example, create index in MySQL:

CREATE INDEX `idx_timestamp`
+Index

SQL

Previously in my fresher time, I rarely write SQL, I always use ORM to wrap SQL.
But time past and too much abstraction bites me.
So I decide to only write SQL from now, no more ORM for me.
But if there is any cool ORM for Go, I guess I try.

This guide is not kind of guide which cover all cases.
Just my little tricks when I work with SQL.

Stay away from database unique id

Use UUID instead.

Stay away from database timestamp

Stay away from all kind of timestamp, timestamp of MySQL or any database.
Just use int64 then pass the timestamp in service layer not database layer.

Why? Because time and date and location are too much complex to handle.
In my business, I use timestamp in milliseconds.
Then I save timestamp as int64 value to database.
Each time I get timestamp from database, I parse to time struct in Go with location or format I want.
No more hassle!

Use index

You should use index for faster query, but not too much.
Don't create index for every fields in table.
Choose wisely!

For example, create index in MySQL:

CREATE INDEX `idx_timestamp`
     ON `user_upload` (`timestamp`);
 

Be careful with NULL

If compare with field which can be NULL, remember to check NULL for safety.

-- field_something can be NULL
 
diff --git a/docs/2022-08-10-gitignore.html b/docs/2022-08-10-gitignore.html
index 1d6c07f..05ee99a 100644
--- a/docs/2022-08-10-gitignore.html
+++ b/docs/2022-08-10-gitignore.html
@@ -1,4 +1,4 @@
-Index

gitignore

My quick check for .gitignore.

Base

# macOS
+Index

gitignore

My quick check for .gitignore.

Base

# macOS
 .DS_Store
 
 # Windows
diff --git a/docs/index.html b/docs/index.html
index 976d979..c1455b4 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -1 +1 @@
-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 \ No newline at end of file diff --git a/docs/styles.css b/docs/styles.css index 1993190..d0e2d0e 100644 --- a/docs/styles.css +++ b/docs/styles.css @@ -1 +1 @@ -body{font-family:recursive,sans-serif;font-variation-settings:"MONO" 0,"CASL" 1;margin:5% auto;max-width:75%;line-height:1.8;color:#24292f;background:#fff}code{font-family:recursive,monospace;font-variation-settings:"MONO" 1,"CASL" 1;display:inline-block;background:#f6f8fa}a{color:#0969da}@media(prefers-color-scheme:dark){body{color:#c9d1d9;background:#0d1117}code{background:#161b22}a{color:#58a6ff}} \ No newline at end of file +body{font-family:recursive,sans-serif;font-variation-settings:"MONO" 0,"CASL" 1;margin:5% auto;max-width:75%;line-height:1.8;color:#24292f;background:#fff}code{font-family:iosevka web;font-variation-settings:"MONO" 1,"CASL" 1;display:inline-block;background:#f6f8fa}a{color:#0969da}@media(prefers-color-scheme:dark){body{color:#c9d1d9;background:#0d1117}code{background:#161b22}a{color:#58a6ff}} \ No newline at end of file diff --git a/templates/post.html b/templates/post.html index 2bc47e8..40d42d7 100644 --- a/templates/post.html +++ b/templates/post.html @@ -9,6 +9,10 @@ href="https://fonts.googleapis.com/css2?family=Recursive:wght,CASL,MONO@300..800,0..1,0..1&display=swap" rel="stylesheet" /> + diff --git a/templates/styles.css b/templates/styles.css index f44c507..9626095 100644 --- a/templates/styles.css +++ b/templates/styles.css @@ -9,7 +9,7 @@ body { } code { - font-family: "Recursive", monospace; + font-family: "Iosevka Web"; font-variation-settings: "MONO" 1, "CASL" 1; display: inline-block; background: #f6f8fa;