2019-10-09 Daily Report

概览

寒山转苍翠,秋水日潺湲。

时间:Wednesday, October 09, 2019 09:30 AM

作者:Syncher Pylon


  • 处理邮件
  • 更新 Todo List
  • 学习算法
  • 学习英语

今日笔记

JavaScript 闭包问题

在函数 A 里定义的函数 B 会将 A 的活动对象 $VO_a$ 添加到自己的作用域链中,即 $ VO_a \in Scope_b$, A 执行完毕后,$VO_a$ 不会被销毁,因为 B 的作用域链仍然在引用它。

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
/**
function createFuncs() {
var result = [];
for (var i = 0; i < 10; i++) {
result[i] = function() {
return i;
};
}
return result;
}
*/
/**
function createFuncs() {
var result = [];

for (var i = 0; i < 10; i++) {
result[i] = function (num) {
return function() {
return num;
}
}(i);
}

return result;
}
*/

function createFuncs() {
var result = [];
for (let i = 0; i < 10; i++) {
result[i] = function() {
return i;
};
}
return result;
}

var res = createFuncs();
for (var i = 0; i < res.length; i++) {
console.log(res[i]());
}

变量对象:

每个执行环境都会创建一个变量对象,保存了该环境下定义的所有变量和函数 ${variables, functions \in VO, if them defined in the context}$,如果这个环境是一个函数的执行环境,那么将其活动对象作为变量对象。

活动对象:

活动对象首先包含了 arguments 变量和实际传入的有名参数,然后包含了函数内部定义的变量和子函数。


[issue]Cannot connect to daemon

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

  1. start/restart docker daemon

    1
    $ sudo dockerd

    Then, following errors comes back:

    1
    2
    3
    4
    5
    6
    ...
    INFO[2019-10-09T06:04:21.269630521Z] pickfirstBalancer: HandleSubConnStateChange: 0xc42086e1a0, CONNECTI NG module=grpc
    INFO[2019-10-09T06:04:21.269737455Z] pickfirstBalancer: HandleSubConnStateChange: 0xc42086e1a0, READY m odule=grpc
    INFO[2019-10-09T06:04:21.270032674Z] pickfirstBalancer: HandleSubConnStateChange: 0xc4201948d0, READY m odule=grpc
    INFO[2019-10-09T06:04:21.272283303Z] [graphdriver] using prior storage driver: overlay2
    Error starting daemon: error while opening volume store metadata database: timeout
  2. Perhaps docker process still runing, so

    1
    $ ps -aux | grep docker

    my screen shows following message:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    root     10786  0.0  0.0  63816  4068 ?        S    Aug09   0:00 sudo dockerd -H 0.0.0.0 -H unix:///var/run/docker.sock
    root 10787 4.3 16.5 5624440 2708464 ? Sl Aug09 3815:26 dockerd -H 0.0.0.0 -H unix:///var/run/docker.sock
    root 11108 0.0 0.0 108756 5580 ? Sl Aug09 2:20 containerd-shim -namespace moby -workdir /var/lib/containerd/io.containerd.runtime.v1.linux/moby/f492a6fe06b05a304590a09c5c3879fc352ffb28a42cabfc0ec297caaff915f3 -address /run/containerd/containerd.sock -containerd-binary /usr/bin/containerd -runtime-root /var/run/docker/runtime-runc
    root 11129 0.0 0.0 107412 5564 ? Sl Aug09 1:55 containerd-shim -namespace moby -workdir /var/lib/containerd/io.containerd.runtime.v1.linux/moby/007bd428ee78857037c449b2097c144f55ea93c5a9c3744fcac5408f046eb9d3 -address /run/containerd/containerd.sock -containerd-binary /usr/bin/containerd -runtime-root /var/run/docker/runtime-runc
    root 11139 0.0 0.0 108756 5892 ? Sl Aug09 1:56 containerd-shim -namespace moby -workdir /var/lib/containerd/io.containerd.runtime.v1.linux/moby/8b3650991995aee7143a004b49d10f6d2473fd9053fa5a5783fce2c7cd7fcc1a -address /run/containerd/containerd.sock -containerd-binary /usr/bin/containerd -runtime-root /var/run/docker/runtime-runc
    root 11148 0.0 0.0 107348 5572 ? Sl Aug09 1:56 containerd-shim -namespace moby -workdir /var/lib/containerd/io.containerd.runtime.v1.linux/moby/c8f0cbf9076dc70aba9368b559fa018c252afe9b81485f70fa1ea9daaac41443 -address /run/containerd/containerd.sock -containerd-binary /usr/bin/containerd -runtime-root /var/run/docker/runtime-runc
    root 11327 0.0 0.0 108756 5880 ? Sl Aug09 2:05 containerd-shim -namespace moby -workdir /var/lib/containerd/io.containerd.runtime.v1.linux/moby/ecf5896b8f6fde6bf4102c30aeb0d847a1a17d0d390faa1017af9d23bdec5c53 -address /run/containerd/containerd.sock -containerd-binary /usr/bin/containerd -runtime-root /var/run/docker/runtime-runc
    root 11349 0.0 0.0 108756 5760 ? Sl Aug09 1:51 containerd-shim -namespace moby -workdir /var/lib/containerd/io.containerd.runtime.v1.linux/moby/cb60f378c71dbe99c4d80db42d8cc2b803893ed336f15851d512c7cc2967f7f8 -address /run/containerd/containerd.sock -containerd-binary /usr/bin/containerd -runtime-root /var/run/docker/runtime-runc
    ...
  3. so, I need to end these process

    1
    $ ps axf | grep docker | grep -v grep | awk '{print "kill -9 " $1}' | sudo sh

    Next, run sudo dockerd again. Well done :)


VIM 知识补充

  • m{a-zA-Z} 用于标记位置,如标记当前光标位置为 mm

  • {a-zA-Z}` 用于跳转到位置标记处,如 ``m` 表示跳转到 m 标记处

  • 常用自动标记

  • q{register} 开始录制宏,再次按 q 结束录制。使用 @{register} 来引用录制的宏。

算法学习笔记

英语学习笔记

  • whether 是否

  • weather 天气

  • tile

    砖瓦

    tile view

  • scenario

    a situation that could possibly happen

  • supplement

    to add something extra in order to improve something or make it bigger

  • decoration

    the process or art of decorating or adorning something.

  • stuff vs staff

    stuff: something staff: employee

本文标题:2019-10-09 Daily Report

文章作者:Syncher

发布时间:2019年10月09日 - 09:10

最后更新:2019年11月11日 - 23:11

原始链接:https://0x400.com/2019-10-09-diary-2019-10-09.html

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。