React: How To Append JSX
Use array!
1 | const collect = [] |
React example
1 | import React from "react"; |
Will print out this:
- first row
- 1
- 2
- 3
Use array!
1 | const collect = [] |
React example
1 | import React from "react"; |
Will print out this:
將分為兩部分討論:
我們無法否認我們的思想、身體限制了我們對於世界的認知。身體上,我們的眼睛能看到的光的波段是有限的;思想上,我們的語言所能描述的範圍,就是我們能理解的範圍。
所以我們可以初步把知識分為:可理解的、不可理解的。
既然認知範圍外的我們碰不到、也確認不了,那我們就不管啦!關注我們能認知的就好(?)
只要在我們能理解的範圍內,驗證為真的知識就是真知識!
問題是,我們如何驗證呢?
例如,我們如何驗證天氣播報說:「今天是晴天」呢?
「很簡單啊,打開窗戶往外看不就知道了?」
「問題是我們怎麼驗證自己的感官器官運作正常呢?」
「那我們相信氣象數據總不會錯吧?」
「一樣的問題,我們怎麼驗證做氣象儀器的人、和解讀數據的人說的是真的呢?」
最後我們會發現,要理性的去驗證每件事成本太高,不可能做到去親證每件事。
所以我們選擇採信他人的說法,既然大家都說那是對的,那他是對的機率應該夠高足以讓我們相信。
但他人何嘗不是如此?
「解釋性」高的知識是指更好解釋當前現象的知識。
讓稻作生長的是陽光、水?還是豐收之神?
平心而論,其實兩者都說得通,都具備解釋性。
我們今天之所以會傾向前者,只是因為前者更符合我們知道的其他物理「知識」。想像一下,如果我們是中世紀的普通人,擁有的是中世紀普通人的「知識體系」,那後者的解釋性可能的就強,因為他跟我們的其他知識擺在一起不矛盾!
我們可以發現,我們相信的其實是那與我們「知識體係」不矛盾、前後邏輯一致的知識,而整件事又受我們「經驗」限制。
但只有我們如此意識到認知上的諸多限制,才能有機會更靠近那個真實。
I got this error when I run hexo server
. The site still works but it made feel unsatisfied…
1 | (node:87224) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency |
Append below code to package.json
then run yarn install
or npm install
. The error should be fixed.
1 | "resolutions": { |
最近看中國視頻學到的新詞。
簡單定義:低級的循環往復
從農場、工廠、互聯網創作,都是產出供給,而供給需要被有效的消費掉
在需求不變的情況下,新生產力(新工人)投入,可能導致以下兩種情況:
出口需求飽和,但國內消費又不足夠填補
國內消費需求低的可能原因:
工资太低?什么都难做?究竟是什么导致中国这些年的”突然内卷化”?【Eng Sub】What caused China’s Involution/Neijuanhua? Rich Poor Gap?
To make deflation
Send tokens to an address without a private key, which means no one can access the tokens anymore.
To fasten the burn efficiency.
Since the solution is to burn partial of validators’ reward, the more users use BSC (which means more blocks need to be validated by validators), the more BNB would be burned.
The more the price of BNB decreases, the more BNB will be burned.
When the total supply is lower than 1B, the burn process stops (BEP-95 still works).
1 | B = N * 1000 / (P + K) |
More detail about Auto-Burn
I got a mission to clone an existing service, which has its database separately from the original.
Here is my to-do list:
This article will focus on how to sync data. To read how to create tables from the old database check out here
I found this great tool to do this task: https://github.com/waelwalid/laravel-database-sync
Please follow the instructions to install the tool.
I run my app in a php-fpm-alpine docker container so some adjustments need to do or the tool won’t work.
The sync-tool is implemented by shell scripts, and with the header, #!/bin/bash
, so only bash can run it.
And since I used an alpine image, which doesn’t have the Bash installed by default so I had two options:
#!/bin/sh
1 | # add this to the Dockerfile |
Still, by default, the alpine image doesn’t come with mysql-client, which is used in the shell script so we need to install it.
1 | apk add --no-cache mysql-client |
Since I sync the data using a user who ONLY has SELECT privilege, I need to disable LOCK TABLE, and PROCESS when dumping the data.
Open vendor/waelwalid/laravel-database-sync/database-update.sh
.
Add --single-transaction=TRUE --no-tablespaces
after mysqldump
command.
Like this:
1 | mysqldump -v --single-transaction=TRUE --no-tablespaces \ |
If you use login as root, or other users with LOCK TABLE, and PROCESS privileges, you can skip this step.
Quote from the document:
mysqldump requires at least the SELECT privilege for dumped tables, SHOW VIEW for dumped views, TRIGGER for dumped triggers, LOCK TABLES if the –single-transaction option is not used, and (as of MySQL 8.0.21) PROCESS if the –no-tablespaces option is not used. Certain options might require other privileges as noted in the option descriptions.
Check out for more details about mysqldump
Now you can run composer database-update
to sync the data, or just execute .vendor/waelwalid/laravel-database-sync/database-update.sh
which is the same, cheers :)
I got a mission to clone an existing service, which has its database separately from the original.
Here is my to-do list:
This article will only record the first step. the next step will be written in the second episode.
Since this project is a Laravel app, but without migration files so I came out with 2 solutions:
php artisan migrate
to create the same tables to my new databaseI thought the first one is more ideal since it is easier for other developers to maintain so I googled “laravel create migration …” then google returned me a bunch of packages to do these tasks, nice!
here is a couple of choices:
So I generated all the migrations in seconds, lovely!
Then I run php artisan migrate
!
CRASH!
Checked out the migrations, found that the generator didn’t generate the codes properly. It missed some details, like lacking index, so I needed to go through each file to debug… which was not my purpose to use a tool so I tried the second solution, create tables by pure SQL
It is easier than I thought
1 | use Illuminate\Support\Facades\DB; |
I test a table and it worked properly, created exactly same table as the original without error
So I exported the table structure in SQL from phpMyAdmin manually (the total number of tables is still acceptable for me to do this).
Instead of creating a command to do this task, I still generated migrations matched to the tables since I would like to have the ROLLBACK feature in Laravel migration. Remember? We can create migrations in seconds by using one of the mentioned packages. Don’t forget to edit .env
to switch to the original database, And after generating, switch back to the NEW database.
Here is my migration code. I put all the SQL in database/sql_migrations
but you can put them anywhere you like.
1 | <?php |
After all files are set, we can easily run php artisan migrate
to create tables, and php artisan migrate:rollback
to rollback.
1 | <img src="https://render.githubusercontent.com/render/math?math=O(n^2)"> |
Result:
https://gist.github.com/a-rodin/fef3f543412d6e1ec5b6cf55bf197d7b