Node.js 是一个开源跨平台的 JavaScript 运行环境,它是时下最流行的工具,能够应用于几乎所有的项目。Node.js 运行 V8 JavaScript engine。它是 chrome 的核心,这让 Node.js 可以脱离浏览器运行 JavaScript 代码。

一个 Node.js app 运行在一个线程中,不会给每个 request 建立一个进程。Node.js 在其标准库中提供了一个 asynchronous I/O primitives 异步 IO 原生语法库来防止阻塞,同时 Node.js 中的库使用一种 non-blocking paradigms 无阻塞范式,将阻塞作为一种 exception 来处理。

当 Node.js 执行 IO 动作,例如读取文件,访问数据库等,不同于等待进程,占用 CPU 资源,Node.js 会在收到 request 响应后再去处理后续操作。这将使 Node.js 可以在一个 server 上同时处理上千条链接而不会引入大量的进程而导致 bug 出现。

Node.js 的另一大优势是使用 JavaScript 的前端开发者可以同时编写 server 端的代码而不用学习新的语言。

最新的 ECMAScript 标准可以在 Node.js 中使用,你不需要等待用户去更新浏览器。通过使用不同版本的 Node.js 来切换不同的 ECMAScript 标准。

阅读全文


随着升级到 macOS Big Sur 后,虚拟机 parallels desktop 也更新到了 16 版本。我当然是继续安装破解版啦。

但是安装好后,启动虚拟机会有一个报错:Network Initialization Failed,启动后会发现虚拟机无法联网,网络设置中无法正常在各种模式中切换。

在寻找解决方案期间,了解到了这可能是由于破解的原因,正版用户没有这个问题。网上有人提供了一个方法,执行一条命令就启动虚拟机就可以正常联网了。但是会导致虚拟机无法访问主机的共享目录及无法访问 USB 设备。而且一旦重启 parallels desktop 后又回恢复之前的状态,我也就没有去做。

这两天看到网上终于有人找到的解决方法,测试后的确可用,所以介绍给大家参考。

阅读全文


最近在调试软件的时候需要用到 CentOS 6 系统,yum 命令无法更新包返回都是 404,查了下发现大多数主流的源地址都取消对 CentOS 6 的支持,找了半天才找到一个可用的地址,记录下来备用。

CentOS 6 的包列表在:/etc/yum.repos.d/CentOS-Base.repo 文件中定义。

参考链接:https://blog.csdn.net/h952520296/article/details/110541018

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
 
[base]
name=CentOS-6.10 - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
 
#released updates 
[updates]
name=CentOS-6.10 - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
 
#additional packages that may be useful
[extras]
name=CentOS-6.10 - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6.10 - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-6.10 - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6

将以上内容替换到 CentOS-Base.repo 文件内,然后执行:

yum clean all && yum makecache

更新缓存即可。



ECMAScript (ES) 就是标准 JavaScript 的脚本语言规范。

它的第 6 个版本,开始被叫做 ECMAScript 6 (ES6) 然后改名为 ECMAScript 2015,为编写更加复杂的程序添加了很重要的新语法。包括了:classes and modules, iterators and for/of loops, generators, arrow functions, binary data, typed arrays, collections (maps, sets and weak maps), promises, number and math enhancements, reflection, and proxies。

ES6 是 ES5 的超集,ES6 现在非常流行,原因就是它引入了新的约定和 OOP 的概念,如:classes。下面我们介绍一些 ES6 中最核心的一些特性。

需要注意的是只有浏览器支持 ES6 的情况下才能够执行 ES6 指令,否则会报错。

阅读全文