0%

参考

资源

nginx

安装

1
brew install nginx
1
2
3
4
5
6
7
8
9
10
11
==> nginx
Docroot is: /home/linuxbrew/.linuxbrew/var/www

The default port has been set in /home/linuxbrew/.linuxbrew/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

nginx will load all files in /home/linuxbrew/.linuxbrew/etc/nginx/servers/.

Warning: nginx provides a launchd plist which can only be used on macOS!
You can manually execute the service instead with:
nginx

愚蠢的人让神经网络像机器的硬盘一样记忆信息, 聪明的人让机器模仿学习像人类一样深邃的思考.

参考

资源

node-module-boilerplate

使用 npm 初始化项目

1
2
cd x:/git.workspace/node-module-boilerplate
npm init --scope=floatsyi

使用 rollup 构建工具, 构建现代化 node package

  1. 使用 npm 添加开发时依赖: rollup

    1
    npm i rollup -D
  2. 创建基本的目录结构

    1
    mkdir -p src/index.js __test__/ build coverage rollup.config.js
    阅读全文 »

参考

资源

bable-jest

安装

1
npm i -D babel-jest

.babelrc
参考: JavaScript compiler: Babel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{
"env": {
"test": {
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
},
"modules": "auto",
"useBuiltIns": "usage",
"corejs": {
"version": 3,
"proposals": true
}
}
]
]
}
}

package.json

1
2
3
4
5
{
"scripts": {
"test": "cross-env BABEL_ENV=test jest",
}
}

资源

.babelrc

babel

安装

1
npm i -D @babel/core @babel/preset-env @babel/cli

.babelrc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
"env": {
"production": {
"presets": [
[
"@babel/preset-env",
{
"modules": false
}
]
]
}
},
"ignore": [
"node_modules/**"
]
}

安装 cross-env

1
npm i -D cross-env

package.json

1
2
3
4
5
6
{
"scripts": {
"build": "rollup --config",
"build:prod": "cross-env BABEL_ENV=production npm run build"
}
}

Polyfill: core-js

安装

1
npm i -D core-js@3

.babelrc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
"env": {
"production": {
"presets": [
[
"@babel/preset-env",
{
"modules": false,
"useBuiltIns": "usage",
"corejs": {
"version": 3,
"proposals": true
}
}
]
]
}
}
}

babel-jest

资源

jest.config.js

jest

安装 jest

1
npm install --save-dev jest

jest.config.js

1
2
3
4
5
6
7
8
// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html

module.exports = {
collectCoverage: true,
testEnvironment: 'node',
testMatch: ['<rootDir>/__tests__/**/*spec.js']
}

package.json

1
2
3
4
5
{
"scripts": {
"test": "jest",
},
}

babel-jest

参考

资源

travis-ci 持续集成

示例

.travis.yml

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
language: node_js
cache:
directories:
- ~/.npm
notifications:
email: true
node_js:
- 'node'
- 'lts/*'
install: npm install
before_install:
- npm install -g npm@5
- npm install -g greenkeeper-lockfile@1
jobs:
include:
- stage: test
script:
- npm run build
- npm run build:prod
- npm run lint:fix
- npm run test
- npm run report-coverage
before_script: greenkeeper-lockfile-update
after_script: greenkeeper-lockfile-upload
- stage: deploy
node_js: 'node'
if: branch = master
script:
- npm run deploy

生命周期

使用 jest 生成代码覆盖率报告, 并用 codecov 上传

安装

1
npm i test -D
1
npm install codecov --save-dev

jest.config.js

1
2
3
4
5
6
7
8
// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html

module.exports = {
collectCoverage: true,
testEnvironment: 'node',
testMatch: ['<rootDir>/__tests__/**/*spec.js']
}

package.json

1
2
3
4
5
6
{
"scripts": {
"test": "jest",
"report-coverage": "codecov"
},
}

.travis.yml

1
2
3
script:
- npm run test
- npm run report-coverage

资源


你想说的话, 都是你想表达的意思

SELECT [DISTINCT] [table.]col[, …[table.]col] // 查哪些列 (DISTINCT 去重)
FROM table0 ([…(INNER JOIN | (RIGHT | LEFT)OUTER JOIN) table1 ON table0.main_key = table1.main_key] | [, …table]) // 从哪些表
WHERE (condition […( AND | OR) (condition | sub query)] | [table.]col [NOT] IN (sub query | refer)) // 有哪些条件
GROUP BY [DISTINCT] [table.]col[, …[table.]col] // 如何分组
HAVING (condition […( *AND | OR ) (condition | sub query)] | [table.]col [NOT] IN (sub query | refer)) // 分组后如何过滤
ORDER BY [table.]col[, …[table.]col] [(ASC | DESC)] // 如何排序
LIMIT int OFFSET int // 最多返回多少条, 从哪条开始(默认0)
UNION // 是否组合其他查询(通过 UNION 组合的每个查询必须包含相同的列、表达式或聚集函数)


阅读全文 »

资源

安装

安装 yarn

1
npm install yarn -g

代理

设置代理

1
2
3
4
5
6
#npm
npm config set proxy http://127.0.0.1:1080
npm config set https-proxy http://127.0.0.1:1080
# yarn
yarn config set proxy http://127.0.0.1:1080
yarn config set https-proxy http://127.0.0.1:1080

删除代理

1
2
3
4
5
6
#npm
npm config delete proxy
npm config delete https-proxy
# yarn
yarn config delete proxy
yarn config delete https-proxy

镜像

ref: https://npm.taobao.org/mirrors

nvm

1
2
export NVM_NODEJS_ORG_MIRROR=http://npm.taobao.org/mirrors/node
export NVM_IOJS_ORG_MIRROR=http://npm.taobao.org/mirrors/iojs
1
2
3
4
5
npm config set registry https://registry.npm.taobao.org -g
npm config set disturl https://npm.taobao.org/dist -g
npm config set electron_mirror https://npm.taobao.org/mirrors/electron/ -g
npm config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/ -g
npm config set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs/ -g
1
2
3
4
5
yarn config set registry https://registry.npm.taobao.org -g
yarn config set disturl https://npm.taobao.org/dist -g
yarn config set electron_mirror https://npm.taobao.org/mirrors/electron/ -g
yarn config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/ -g
yarn config set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs/ -g