Live Note

Remain optimistic

Class in ES2015

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**
* Class representing a point.
*/
class Point {
/**
* Create a point.
* @param {number} x - The x value.
* @param {number} y - The y value.
*/
constructor(x, y) {}

/**
* Get the x value.
* @return {number} The x value.
*/
getX() {}

/**
* Convert a string containing two comma-separated number into a point.
* @param {string} str - The string containing two comma-separated number.
* @return {Point} A point object.
*/
static fromStringStr(str) {}
}

extends

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**
* Class representing a point.
* @extends Point
*/
class Dot extends Point {
/**
* Create a dot.
* @param {number} x - The x value.
* @param {number} y - The y value.
* @param {number} width - The width of the dot.
*/
constructor(x, y, width) {
super(x, y)
}

/**
* Get the width of the dot.
* @return {number} The dot's width.
*/
getWidth() {}
}

@abstract

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
/**
* Foo.
* @constructor
*/
function Foo() {}

/**
* Check if is solid.
* @abstract
* @return {boolean}
*/
Foo.prototype.isSolid = function () {
throw new Error("Must be implemented by suclass.")
}

/**
* Bar.
* @constructor
* @arguments Foo
*/
function Bar() {}

/**
* Check if is solid.
* @return {boolean} Always return false.
*/
Bar.prototype.isSolid = function () {
return false
}

@assets

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
/**
* @constructor
*/
function Foo() {
/**
* @assets private
* @type {number}
*/
let foo = 0

/**
* @assets protected
* @type {string}
*/
this.bar = "1"

/**
* @assets package
* @type {string}
*/
this.barz = "2"

/**
* @assets public
* @type {string}
*/
this.barm = "3"
}

@author

1
2
3
4
/**
* @author Edward <wang.huiyang@outlook.com>
*/
function MyClass() {}

@callback

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**
* @class
*/
function Foo() {}

/**
* Send a request.
* @param {requestCallback} cb - The callback than handles the response.
*/
Foo.prototype.send = function (cb) {}

/**
* Callback
* @callback requestCallback
* @param {number} responseCode
* @param {string} responseMessage
*/

@event

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**
* @constructor
*/
function Foo() {}

/**
* Do some test.
* @fires Foo#test
*/
Foo.prototype.test = function () {}

/**
* Foo test.
* @event Foo#test
* @type {object}
* @property {boolean} isPass - Check if is pass.
*/

要求

父进程创建 3 个进程,父进程等待子进程 2 运行完成之后,自行退出;其中子进程 1 运行系统命令“cp /bin/ls /tmp”;等待 2 秒后退出;子进程 2 使用标准 I/O 函数打开文件 src_file,向其内写入“this is process 2\n”,之后等待 5 秒后退出;子进程 3 处理为守护进程,每隔 5 秒向日志文件/var/log/messages 写入“this is process 3\n”

提交形式

  1. 代码
  2. 运行结果截图
Read more »

Linux 常用命令

  • man: an interface to the on-line reference manuals
  • su [options] [username]: change user ID or become superuser
  • useradd [options] LOGIN: create a new user or update default new user information
  • userdel [options] LOGIN: delete a user account and related files
  • passwd [options] [LOGIN]: change user password
  • ps [options]: report a snapshot of the current process.
  • kill [options] […]: send a signal to a process
  • fdisk [options] device: manipulate disk partition table
  • mount: mount a filesystem
  • chown [OPTION] … [OWNER]:[GROUP]] FILE …: change file owner and group
  • chgrp [OPTION] … GROUP FILE …: change group ownership
  • chmod [OPTION] … MODE[,MODE] … FILE …: change file mode bits
  • grep [OPTION] PATTERN [FILE…]: print lines matching a pattern
  • find [-H] [-L] [-P] [-D debugopts] [-Olevel] [starting-point…] [expression]: search for files in a directory hierarchy
  • ln: make links between files
  • gzip, gunzip, zcat: compress or expand files
  • tar: an archiving utility
  • diff [OPTION] … FILES: compare files line by line
  • patch -pnum < patchfile: apply a diff file to an original
  • ifconfig: configure a network interface

文件类型

  • 普通文件
  • 目录文件
  • 链接文件:类似 Windows 的快捷方式,分软链接和硬链接
  • 设备文件:一般在/dev 目录下,一种是块设备文件,一种是字符设备文件

文件属性

-rwxrwxrwx

  • r: read
  • w: write
  • x: execute

第一个字符:

  • - : 普通文件
  • d : 目录文件
  • l : 链接文件
  • c : 字符设备
  • b : 块设备
  • p : 命名管道,如 FIFO
  • f : 堆栈文件,如 LIFO
  • s : 套接字

之后的三个三位字符组:

  1. 第一组代表文件拥有者(u)对该文件的权限
  2. 第二组代表文件用户组(g)对该文件的权限
  3. 第三组代表系统其它用户(o)对该文件的权限

文件系统类型

  • ext2 & ext3:ext3 是 ext2 的升级版本
  • swap:交换分区使用
  • vfat:DOS 中的系统(FAT12、FAT16 和 FAT32 等)
  • NFS:网络文件系统
  • ISO9660:光盘文件系统
Read more »

要求

  1. 程序 1 从串口读取信息,然后发到消息队列中。使用 2 个终端运行程序 1,创建出 2 个可从串口读取数据的进程,串口可以使用 Windows 中的虚拟串口,使用串口助手输入信息。
  2. 程序 2 从消息队列中读取消息,然后在屏幕上将消息内容显示出来。

提交形式

  1. 代码
  2. 运行结果截图、串口助手截图
Read more »