fix typos
parent
a6557eca7a
commit
1f96f5322a
|
@ -56,7 +56,7 @@
|
|||
</div>
|
||||
<p>
|
||||
There are many use cases where we need to use a unique ID. In my
|
||||
experience, I only encouter 2 cases:
|
||||
experience, I only encounter 2 cases:
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
|
@ -86,7 +86,7 @@
|
|||
</div>
|
||||
<p>
|
||||
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
|
||||
(because maybe the possibility 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.
|
||||
</p>
|
||||
|
|
|
@ -138,7 +138,7 @@
|
|||
<p>
|
||||
Why?
|
||||
<a
|
||||
href="https://github.com/grpc/grpc-go/issues?q=is%3Aissue+compatibility+is%3Aclosed"
|
||||
href="https://github.com/grpc/grpc-go/issues?qgis%3Aissue+compatibility+is%3Aclosed"
|
||||
>See for yourself</a
|
||||
>.
|
||||
</p>
|
||||
|
@ -160,7 +160,7 @@
|
|||
<ul>
|
||||
<li>
|
||||
<a href="https://github.com/bufbuild/connect-go">bufbuild/connect-go</a
|
||||
>. Comming from buf, trust worthy but need time to make it match feature
|
||||
>. Coming from buf, trust worthy but need time to make it match feature
|
||||
parity with grpc-go.
|
||||
</li>
|
||||
<li><a href="https://github.com/twitchtv/twirp">twitchtv/twirp</a></li>
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
></a>
|
||||
</div>
|
||||
<p>
|
||||
Stay away from all kind of database timestamp (MySQL timestmap, SQLite
|
||||
Stay away from all kind of database timestamp (MySQL timestamp, SQLite
|
||||
timestamp, ...) Just use int64 then pass the timestamp in service layer
|
||||
not database layer.
|
||||
</p>
|
||||
|
@ -239,7 +239,7 @@
|
|||
<span class="pl-k">FROM</span> table
|
||||
<span class="pl-k">WHERE</span> (field_something IS <span class="pl-k">NULL</span> <span class="pl-k">OR</span> field_something <span class="pl-k">!=</span> <span class="pl-c1">1</span>)</pre>
|
||||
</div>
|
||||
<p>Need clarify why this happpen? Idk :(</p>
|
||||
<p>Need clarify why this happen? Idk :(</p>
|
||||
<div class="markdown-heading">
|
||||
<h2 class="heading-element"><code>VARCHAR</code> or <code>TEXT</code></h2>
|
||||
<a
|
||||
|
@ -284,7 +284,7 @@
|
|||
></a>
|
||||
</div>
|
||||
<p>
|
||||
Plase read docs about online ddl operations before do anything online
|
||||
Please read docs about online ddl operations before do anything online
|
||||
(keep database running the same time update it, for example create index,
|
||||
...)
|
||||
</p>
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
</p>
|
||||
<p>
|
||||
In my opinion, unit test is not that important (like must must have). It's
|
||||
just make sure your code is running excatly as you intent it to be. If you
|
||||
just make sure your code is running exactly as you intent it to be. If you
|
||||
don't think about edge case before, unit test won't help you.
|
||||
</p>
|
||||
<div class="markdown-heading">
|
||||
|
@ -224,7 +224,7 @@
|
|||
What if req is a struct with many fields? So in each test case you need to
|
||||
set up req. They are almost the same, but with some error case you must
|
||||
alter req. It's easy to be init with wrong value here (typing maybe ?).
|
||||
Also all req looks similiar, kinda duplicated.
|
||||
Also all req looks similar, kinda duplicated.
|
||||
</p>
|
||||
<div class="highlight highlight-source-go">
|
||||
<pre><span class="pl-s1">tests</span> <span class="pl-c1">:=</span> []<span class="pl-k">struct</span>{
|
||||
|
|
|
@ -113,7 +113,7 @@
|
|||
<p>Chaos right there!</p>
|
||||
<p>
|
||||
<strong>Solution</strong>: Use a lock, if user enter API upload, lock it
|
||||
to prevent user call other APIs. Rememeber to unlock after finished
|
||||
to prevent user call other APIs. Remember to unlock after finished
|
||||
</p>
|
||||
|
||||
<div>
|
||||
|
|
|
@ -327,7 +327,7 @@
|
|||
<p>Review:</p>
|
||||
<p>Things I don't like:</p>
|
||||
<ul>
|
||||
<li>Sandwhich style is meh when typing, so I buy Aluminium case.</li>
|
||||
<li>Sandwich style is meh when typing, so I buy Aluminium case.</li>
|
||||
<li>The left sandwich case is so tight to put switch in.</li>
|
||||
<li>
|
||||
Sometimes right encoder is not working, I need to plug out and plug in
|
||||
|
|
|
@ -106,7 +106,7 @@
|
|||
<div class="highlight highlight-source-viml">
|
||||
<pre>:<span class="pl-c1">sort</span> <span class="pl-k">-</span><span class="pl-c1">u</span></pre>
|
||||
</div>
|
||||
<p>Reverse lines (after selcting lines):</p>
|
||||
<p>Reverse lines (after selecting lines):</p>
|
||||
<div class="highlight highlight-source-viml">
|
||||
<pre>:<span class="pl-k">!</span>tail <span class="pl-k">-</span><span class="pl-c1">r</span></pre>
|
||||
</div>
|
||||
|
|
|
@ -45,12 +45,12 @@
|
|||
<a href="index.html"><code>~</code></a>
|
||||
</h2>
|
||||
<div class="markdown-heading">
|
||||
<h1 class="heading-element">Userful tools</h1>
|
||||
<h1 class="heading-element">Useful tools</h1>
|
||||
<a
|
||||
id="user-content-userful-tools"
|
||||
id="user-content-useful-tools"
|
||||
class="anchor"
|
||||
aria-label="Permalink: Userful tools"
|
||||
href="#userful-tools"
|
||||
aria-label="Permalink: Useful tools"
|
||||
href="#useful-tools"
|
||||
><span aria-hidden="true" class="octicon octicon-link"></span
|
||||
></a>
|
||||
</div>
|
||||
|
@ -666,12 +666,12 @@
|
|||
</li>
|
||||
</ul>
|
||||
<div class="markdown-heading">
|
||||
<h2 class="heading-element">Developement</h2>
|
||||
<h2 class="heading-element">Development</h2>
|
||||
<a
|
||||
id="user-content-developement"
|
||||
id="user-content-development"
|
||||
class="anchor"
|
||||
aria-label="Permalink: Developement"
|
||||
href="#developement"
|
||||
aria-label="Permalink: Development"
|
||||
href="#development"
|
||||
><span aria-hidden="true" class="octicon octicon-link"></span
|
||||
></a>
|
||||
</div>
|
||||
|
|
|
@ -394,7 +394,7 @@ rsync -avzP src/ dst</pre>
|
|||
<li><code>-z</code>: compress</li>
|
||||
<li>
|
||||
<code>-P</code>: enable both <code>--partial</code>,
|
||||
<code>--progress</code> to easily resume after interupt
|
||||
<code>--progress</code> to easily resume after interrupt
|
||||
</li>
|
||||
<li><code>-n</code>: dry run</li>
|
||||
</ul>
|
||||
|
|
|
@ -123,12 +123,12 @@
|
|||
<strong>counter</strong> as mac(secret_key, counter, alice).
|
||||
</li>
|
||||
<li>
|
||||
Verify must be done in <strong>constant time</strong>: if not, probaly
|
||||
Verify must be done in <strong>constant time</strong>: if not, probably
|
||||
return error the moment the bytes differ -> attacker recreate byte by
|
||||
byte by measuring how long -> timing attacks
|
||||
</li>
|
||||
</ul>
|
||||
<p>Constant time comparision:</p>
|
||||
<p>Constant time comparison:</p>
|
||||
<div class="highlight highlight-source-go">
|
||||
<pre><span class="pl-k">for</span> <span class="pl-s1">i</span> <span class="pl-c1">:=</span> <span class="pl-c1">0</span>; <span class="pl-s1">i</span> <span class="pl-c1"><</span> <span class="pl-en">len</span>(<span class="pl-s1">x</span>); <span class="pl-s1">i</span><span class="pl-c1">++</span> {
|
||||
<span class="pl-c">// Use XOR instead of compare x[i] == y[i]</span>
|
||||
|
|
|
@ -239,7 +239,7 @@
|
|||
</p>
|
||||
<p>Message Broker is a way to detach B from A.</p>
|
||||
<p>
|
||||
Dumb exaplain be like: each time A do something, A produces message to
|
||||
Dumb explain be like: each time A do something, A produces message to
|
||||
Message Broker, than A forgets about it. Then all B1, B2 can consume A's
|
||||
message if they want and do something with it, A does not know and does
|
||||
not need to know about it.
|
||||
|
@ -303,7 +303,7 @@
|
|||
</li>
|
||||
<li>
|
||||
Don't delete/rename/change old fields because you want and you can,
|
||||
please think it through before do it. Because back compability is very
|
||||
please think it through before do it. Because back compatibility is very
|
||||
hard, old apps should continue to function if user don't upgrade. Even
|
||||
if we rollout new version, it takes time.
|
||||
</li>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# UUID or else
|
||||
|
||||
There are many use cases where we need to use a unique ID. In my experience, I
|
||||
only encouter 2 cases:
|
||||
only encounter 2 cases:
|
||||
|
||||
- ID to trace request from client to server, from service to service
|
||||
(microservice architecture or nanoservice I don't know).
|
||||
|
@ -17,7 +17,7 @@ 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
|
||||
maybe the possibility 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.
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ This pattern is used by [google/go-github](https://github.com/google/go-github).
|
|||
## Find alternative to [grpc/grpc-go](https://github.com/grpc/grpc-go)
|
||||
|
||||
Why?
|
||||
[See for yourself](https://github.com/grpc/grpc-go/issues?q=is%3Aissue+compatibility+is%3Aclosed).
|
||||
[See for yourself](https://github.com/grpc/grpc-go/issues?qgis%3Aissue+compatibility+is%3Aclosed).
|
||||
|
||||
Also read:
|
||||
|
||||
|
@ -67,7 +67,7 @@ Also read:
|
|||
|
||||
Currently there are some:
|
||||
|
||||
- [bufbuild/connect-go](https://github.com/bufbuild/connect-go). Comming from
|
||||
- [bufbuild/connect-go](https://github.com/bufbuild/connect-go). Coming from
|
||||
buf, trust worthy but need time to make it match feature parity with grpc-go.
|
||||
- [twitchtv/twirp](https://github.com/twitchtv/twirp)
|
||||
- [storj/drpc](https://github.com/storj/drpc)
|
||||
|
|
|
@ -15,7 +15,7 @@ sortable.
|
|||
|
||||
## Stay away from database timestamp
|
||||
|
||||
Stay away from all kind of database timestamp (MySQL timestmap, SQLite
|
||||
Stay away from all kind of database timestamp (MySQL timestamp, SQLite
|
||||
timestamp, ...) Just use int64 then pass the timestamp in service layer not
|
||||
database layer.
|
||||
|
||||
|
@ -106,7 +106,7 @@ FROM table
|
|||
WHERE (field_something IS NULL OR field_something != 1)
|
||||
```
|
||||
|
||||
Need clarify why this happpen? Idk :(
|
||||
Need clarify why this happen? Idk :(
|
||||
|
||||
## `VARCHAR` or `TEXT`
|
||||
|
||||
|
@ -122,7 +122,7 @@ Prefer `LIMIT 10 OFFSET 5` to `LIMIT 5, 10` to avoid misunderstanding.
|
|||
|
||||
## Be super careful when migrate, update database on production and online!!!
|
||||
|
||||
Plase read docs about online ddl operations before do anything online (keep
|
||||
Please read docs about online ddl operations before do anything online (keep
|
||||
database running the same time update it, for example create index, ...)
|
||||
|
||||
- [For MySQL 5.7](https://dev.mysql.com/doc/refman/5.7/en/innodb-online-ddl-operations.html),
|
||||
|
|
|
@ -12,7 +12,7 @@ coverage, with minimum effort as possible, I hope this will show you some idea
|
|||
you can use :)
|
||||
|
||||
In my opinion, unit test is not that important (like must must have). It's just
|
||||
make sure your code is running excatly as you intent it to be. If you don't
|
||||
make sure your code is running exactly as you intent it to be. If you don't
|
||||
think about edge case before, unit test won't help you.
|
||||
|
||||
## First, rewrite the impossible (to test) out
|
||||
|
@ -138,7 +138,7 @@ Looks good right? Be careful with this. It can go from 0 to 100 ugly real quick.
|
|||
What if req is a struct with many fields? So in each test case you need to set
|
||||
up req. They are almost the same, but with some error case you must alter req.
|
||||
It's easy to be init with wrong value here (typing maybe ?). Also all req looks
|
||||
similiar, kinda duplicated.
|
||||
similar, kinda duplicated.
|
||||
|
||||
```go
|
||||
tests := []struct{
|
||||
|
|
|
@ -38,4 +38,4 @@ one, aka image in submitted data, is gone.
|
|||
Chaos right there!
|
||||
|
||||
**Solution**: Use a lock, if user enter API upload, lock it to prevent user call
|
||||
other APIs. Rememeber to unlock after finished
|
||||
other APIs. Remember to unlock after finished
|
||||
|
|
|
@ -91,7 +91,7 @@ Review:
|
|||
|
||||
Things I don't like:
|
||||
|
||||
- Sandwhich style is meh when typing, so I buy Aluminium case.
|
||||
- Sandwich style is meh when typing, so I buy Aluminium case.
|
||||
- The left sandwich case is so tight to put switch in.
|
||||
- Sometimes right encoder is not working, I need to plug out and plug in again.
|
||||
- See
|
||||
|
|
|
@ -46,7 +46,7 @@ Sort lines (after selecting lines):
|
|||
:sort -u
|
||||
```
|
||||
|
||||
Reverse lines (after selcting lines):
|
||||
Reverse lines (after selecting lines):
|
||||
|
||||
```vim
|
||||
:!tail -r
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Userful tools
|
||||
# Useful tools
|
||||
|
||||
This just a raw list.
|
||||
|
||||
|
@ -134,7 +134,7 @@ Memory
|
|||
- https://github.com/CodeEditApp/CodeEdit
|
||||
- https://github.com/Ranchero-Software/NetNewsWire
|
||||
|
||||
## Developement
|
||||
## Development
|
||||
|
||||
### Terminal
|
||||
|
||||
|
|
|
@ -285,7 +285,7 @@ Commonly flags:
|
|||
|
||||
- `-v`: verbose
|
||||
- `-z`: compress
|
||||
- `-P`: enable both `--partial`, `--progress` to easily resume after interupt
|
||||
- `-P`: enable both `--partial`, `--progress` to easily resume after interrupt
|
||||
- `-n`: dry run
|
||||
|
||||
Be careful flags (need dry run if not sure):
|
||||
|
|
|
@ -31,11 +31,11 @@ sequenceDiagram
|
|||
- Replay attacks: send transaction 2 times with perfectly MAC and u know why ->
|
||||
instead of mac(secret_key, alice), use **counter** as mac(secret_key, counter,
|
||||
alice).
|
||||
- Verify must be done in **constant time**: if not, probaly return error the
|
||||
- Verify must be done in **constant time**: if not, probably return error the
|
||||
moment the bytes differ -> attacker recreate byte by byte by measuring how
|
||||
long -> timing attacks
|
||||
|
||||
Constant time comparision:
|
||||
Constant time comparison:
|
||||
|
||||
```go
|
||||
for i := 0; i < len(x); i++ {
|
||||
|
|
|
@ -101,7 +101,7 @@ Bn, this is so depressed to continue.
|
|||
|
||||
Message Broker is a way to detach B from A.
|
||||
|
||||
Dumb exaplain be like: each time A do something, A produces message to Message
|
||||
Dumb explain be like: each time A do something, A produces message to Message
|
||||
Broker, than A forgets about it. Then all B1, B2 can consume A's message if they
|
||||
want and do something with it, A does not know and does not need to know about
|
||||
it.
|
||||
|
@ -154,8 +154,8 @@ sequenceDiagram
|
|||
hacker computer. (Actually we can but this is out of scope, and require lots
|
||||
of advance work)
|
||||
- Don't delete/rename/change old fields because you want and you can, please
|
||||
think it through before do it. Because back compability is very hard, old apps
|
||||
should continue to function if user don't upgrade. Even if we rollout new
|
||||
think it through before do it. Because back compatibility is very hard, old
|
||||
apps should continue to function if user don't upgrade. Even if we rollout new
|
||||
version, it takes time.
|
||||
|
||||
**Pro tip**: Use proto to define models (if you can) to take advantage of
|
||||
|
|
Loading…
Reference in New Issue