Live Note

Remain optimistic

工作以來的感受

最大的感受就是,需要學習的還有很多很多。獨立思考可以讓你的思維更加開放、活躍,同時可以激發更多的靈感。
目前的技術棧:React+Mobx+TypeScirpt

從前對狀態管理沒有什麽概念,自從接觸到工程項目之後,對爲何要進行 State Management 越來越清晰。
當然也產生了一定的不良影響 -> 只要上手就會想如何設計 State,導致有的地方代碼實在冗餘。

同時在項目代碼中瞭解了許多新知識,如何去設計一個可繼承、可復用的 Function;如何將 Store 封裝,便於使用;如何對請求進行封裝;何時使用 Interface、何時使用 Type;等等……

接下來需要做的

  • 思考之前的代碼如何優化
  • 思考目前的代碼是否還能拆分
  • 閲讀 State Management 的文章
  • ……

課餘時間的活動

  • 書籍

    • 熵的世界
    • 我的簡史 - 霍金
  • 日常

    • 陰陽師
    • B 站
    • 手游 - 跑跑卡丁車
    • 音樂
  • 綜藝

    • 説唱新世代
    • 中國新説唱
  • 影視劇

    • 甜蜜蜜
    • 投名狀
    • 親愛的
    • 八佰
    • Mulan
    • 信條

挖坑

考慮用點什麽搭一個自己的博客。

之前使用的是 trojan, 奈何找不到好的管理程序, 現使用 clash

clash 的 config 使用的是 yaml 文件, 所以比較好寫.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
port: 7890
socks-port: 7891
mixed-port: 7892 # 混合端口
allow-lan: true # 允許局域網連接
log-level: info
external-controller: 127.0.0.1:9090 # 外部控制端口
extarnal-ui: dashborad # 使用的ui
proxies: # clash官方文檔有更清楚的寫法
- {
type: ss,
name: "TEST-SS",
server: 127.0.0.1,
port: 2020,
password: 123456,
plugin: obfs,
plugin-opts: { mode: http },
} # 公司使用的是ss協議
- {
type: trojan,
name: "TEST-TROJAN",
server: 127.0.0.1,
port: 443,
password: 123456,
#sni
skip-cert-verify: true,
}
proxy-groups:
- { name: WORK, type: select, proxies: ["TEST-SS"] } # 將所需的proxy單獨進行分組
- { name: Proxy, type: select, proxies: ["TEST-TROJAN"] }
rules:
- IP-CIDR, 10.8.0.0/12, WORK # 根據rule將不同的請求轉發到所需的分組去
- IP-CIDR, 172.30.0.0/12, WORK
- IP-CIDR, 100.64.0.0/10, DIRECT
- IP-CIDR, 127.0.0.0/8, DIRECT
- DOMAIN-SUFFIX, google.com, Proxy

Example

假設現在有一個數據非常多的數組,但是我們只需要它的前幾個數據,并且進行一定的操作,這時候可以使用 generator 來進行 take 的操作.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
const from = (arr) => arr[Symbol.iterator]()

const filter = (f) =>
function* (iter) {
let v = iter.next()
while (!v.done) {
if (f(v.value)) yield v.value
v = iter.next()
}
}

const multipy = (n) =>
function* (iter) {
let v = iter.next()
while (!v.done) {
yield v.value * n
v = iter.next()
}
}

const take = (n) =>
function* (iter) {
let i = 0
let v = iter.next()
while (!v.done && i < n) {
yield v.value
i++
v = iter.next()
}
}

const pipe = (...arr) => arr.reduce((acc, func) => func(acc))

console.log([
...pipe(
from(arr),
filter((v) => v % 2 === 0),
multipy(3),
take(30),
filter((v) => v > 15)
),
]) // [18, 24, 30, 36]

Overview

随着消费者支付习惯的改变,现金的存在作用在不断弱化。无现金交易将成为下一个支付前沿。目前多国央行在筹备发行数字货币,数字货币的稳定性和安全性,是各国央行研发的重中之重。

Read more »

函数的默认值

在 ES6 之前,不能直接为函数指定默认值,只能采用变通的方法:

1
2
3
4
5
6
7
8
function log(x, y) {
if (y === "undefined") {
y = "world"
}
console.log(x, y)
}
log("hello") //hello test
log("hello", "") //hello

ES6 允许为函数的参数设置默认值:

1
2
3
4
5
6
7
8
9
10
11
12
function log(x, y = "world") {
console.log(x, y)
}
log("hello") //hello world
log("hello", "") //hello

eg: function Point(x = 0, y = 0) {
this.x = x
this.y = y
}
let p = new Point()
console.log(p.x + " " + p.y) //0 0
Read more »