杂烩 Screen MariaDB mock mysql gitlab 允许MySqlWorkbench访问数据库 ...

安装数据库

1
2
3
4
5
6
7
8
9
10
11
yum install mariadb-server.x86_64

systemctl start mariadb

mysql -uroot

show databases
select user,host from mysql.user;

启动 phpmyading
systemctl restart httpd

cnpm库系统搭建

1. 仓库地址:github.com/fengmk2/cnpmjs.org.git
2. 文档说明:https://www.jianshu.com/p/659fb418c9e3

mockapi接口系统搭建

1. rap2-delos: 后端数据API服务器,基于Koa + MySQL   
    https://github.com/thx/rap2-delos
2. rap2-dolores: 前端静态资源,基于React
    https://github.com/thx/rap2-dolores

gitlab仓库系统搭建

> 后续增加

git 去掉最近一次的提交

1
2
git reset --hard HEAD~1
git push -f // 强制推送提交代码

登录服务器的用户名IP及密码

1
2
ssh username@127.0.0.1
password123

远程登录数据库

1
2
mysql -u root -h 127.0.0.1 -p
password123@!#

安装node

1
2
3
4
5
6
yum -y install nodejs

超级简单的升级node.js的方法
npm install -g n
安装稳定的版本
n stable

安装MariaDB数据库

MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。

  1. 安装mariadb

    1
    yum -y install mariadb-server mariadb-client
  2. maria常用命令

    1
    2
    3
    4
    systemctl start mariadb #启动服务
    systemctl enable mariadb #设置开机启动
    systemctl restart mariadb #重新启动
    systemctl stop mariadb.service #停止MariaDB
  3. 登录数据库 重置密码

    1
    2
    3
    4
    5
    6
    # 本机登录
    mysql -u root -p;
    SET PASSWORD = PASSWORD('10quan10m@i');
    # 远程登录
    mysql -u root -h 192.168.2.128 -p
    password123@!#
  4. 数据库常用命令

    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
    显示DBMS的所有数据库;
    show databases;
    创建数据库
    create database db_name;
    删除数据库
    drop database db_name;
    选择数据库
    use db_name;

    显示当前使用的数据库
    select database();
    显示当前登录的用户名称
    select user();
    显示当前数据库支持及默认的存储引擎
    show engines;
    显示当前数据库的触发器信息
    show triggers;

    显示当前数据库的表信息
    show tables;
    创建数据库表
    create table table_name;
    删除数据库表
    drop table table_name;
    显示当前数据库的表状态
    show table status;
    显示表结构信息
    describe table_name; 或 desc table_name; 或 show columns from able_name;
    显示表中的所有记录
    select * from table_name;

    查看mysql端口号
    mysql> show global variables like 'port';

安装git

1
yum install -y git

安装 screen

1
2
3
4
5
6
7
8
Screen是一款由GNU计划开发的用于命令行终端切换的自由软件。用户可以通过该软件同时连接多个本地或远程的命令行会话,并在其间自由切换。GNU Screen可以看作是窗口管理器的命令行界面版本。它提供了统一的管理多个会话的界面和相应的功能。

yum install -y screen
screen -dmS RAP2
screen -x RAP2
启动一个api后台服务
npm start
control + a + d

rap2前端服务nginx配置

1
2
3
4
5
6
7
8
9
10
11
12
13
git clone https://github.com/thx/rap2-dolores.git front-end

nginx配置
server{
listen *:80;
server_name mockapi.nixin8.com;
root /opt/rap2/front-end/build;
index index.html;
location / {
root /opt/rap2/front-end/build;
index index.html;
}
}

RAP2-Delos 后端数据API服务器

1
2
3
4
5
6
7
1. git clone https://github.com/thx/rap2-delos.git back-end
2. cd back-end
3. npm install
4. 确认/config/config.dev.js中的配置
5. npm run build
6. 修改/config/config.prod.js中的服务器配置
7. npm start

允许MySqlWorkbench访问数据库

1
2
3
4
在服务器上进行操作,进入mysql
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION //赋予任何主机访问数据的权限
mysql>FLUSH PRIVILEGES //修改生效
mysql>EXIT //退出MySQL服务器

其它命令记录一下

1
2
3
4
5
6
7
8
场景:
无hexo这个命令
只能/data/www/node-v8.4.0-linux-x64/bin/hexo这样执行该命令

解决:
vi /etc/profile
export PATH=$PATH:/data/www/node-v8.4.0-linux-x64/bin/
source /etc/profile
1
2
3
4
5
6
7
8
远程复制:
scp md.zip root@192.168.258.126:/home/sww

移动:
mv md.zip /data/www/sww/

解压:
unzip md.zip
1
2
3
4
5
跟踪日志:
tailf /data/logs/nginx/error_sww.log

执行过的命令记录:
history
1
2
3
4
5
ssh-keygen生成git ssh密钥:
cd ~/.ssh
ssh-keygen -t rsa -C "happysww1230@163.com"
密钥会包含id_rsa和id_rsa.pub两个文件,分别表示生成的私钥和公钥
使用cat ~/.ssh/id_rsa.pub命令,并将相应内容复制到源代码管理服务器即可实现git的无密码管理

vs code 配置及插件

推荐使用vs code进行前端编码,规定Tab大小为2个空格

  1. vs code配置

    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
    {
    "editor.tabSize": 2,
    "workbench.startupEditor": "newUntitledFile",
    "workbench.iconTheme": "vscode-icons",
    // 以下为stylus配置
    "stylusSupremacy.insertColons": false, // 是否插入冒号
    "stylusSupremacy.insertSemicolons": false, // 是否插入分好
    "stylusSupremacy.insertBraces": false, // 是否插入大括号
    "stylusSupremacy.insertNewLineAroundImports": false, // import之后是否换行
    "stylusSupremacy.insertNewLineAroundBlocks": false, // 两个选择器中是否换行
    "vetur.format.defaultFormatter.html": "js-beautify-html",
    "eslint.autoFixOnSave": true,
    "eslint.validate": [
    "javascript",
    {
    "language": "html",
    "autoFix": true
    },
    {
    "language": "vue",
    "autoFix": true
    },
    "javascriptreact",
    "html",
    "vue"
    ],
    "eslint.options": { "plugins": ["html"] },
    "prettier.singleQuote": true,
    "prettier.semi": false,
    "javascript.format.insertSpaceBeforeFunctionParenthesis": false,
    "vetur.format.js.InsertSpaceBeforeFunctionParenthesis": false,
    "vetur.format.defaultFormatter.js": "prettier",
    // "prettier.eslintIntegration": true
    }
  2. vs code 插件

    • Auto Close Tag
    • Path Intellisense
    • Prettier
    • Vetur
    • vscode-icons
    • Markdown Preview Enhanced

Git常用命令

参考文档

初始并配置

1
2
3
4
5
git init
git config --global user.name "sww1230"
git config --global user.email sww1230@163.com

git config --list // 检查配置信息

工作流

  • Git 怎样保证fork出来的project和原project(上游项目)同步更新

    1. 在 Fork 的代码库中添加上游代码库的 remote 源,该操作只需操作一次即可。如: 其中# upstream 表示上游代码库名, 可以任意。

      1
      git remote add upstream https://github.scm.corp.ebay.com/montage/frontend-ui-workspace
    2. 将本地的修改提交 commit

    3. 在每次 Pull Request 前做如下操作,即可实现和上游版本库的同步。

      1
      2
      git remote update upstream
      git rebase upstream/{branch name}

      需要注意的是在操作3.2之前,一定要将checkout到{branch name}所指定的branch,如:

      1
      git checkout develop
    4. Push 代码到 Github

      1
      git push origin dev.161625

分支

  • 查看分支
    • git branch -a
  • 删除远程分支
    • git branch -r -d origin/
    • git push origin :
  • 删除不存在对应远程分支的本地分支
    • 查看远程分支
    • git remote show origin
      • refs/remotes/origin/b1 stale (use ‘git remote prune’ to remove)
      • git remote prune origin
    • 更简单的用法
      • git fetch -p
  • 新建分支

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    //create branch
    git checkout -b dev.170220

    //coding

    //update upstream
    git remote update upstream
    git rebase upstream/dev.170220

    //push
    git push --set-upstream origin dev.170220
====

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
创建分支: $ git branch mybranch
切换分支: $ git checkout mybranch
创建并切换分支: $ git checkout -b mybranch

更新master主线上的东西到该分支上:$git rebase master

切换到master分支:$git checkout master

更新mybranch分支上的东西到master上:$git rebase mybranch

提交:git commit -a

对最近一次commit的进行修改:git commit -a –amend

commit之后,如果想撤销最近一次提交(即退回到上一次版本)并本地保留代码:git reset HEAD^
合并分支:(merge from) $ git checkout master
$ git merge mybranch (merge from mybranch)
删除分支: $ git branch -d mybranch
强制删除分支: $ git branch -D mybranch
列出所有分支: $ git branch
查看各个分支最后一次提交: $ git branch -v

查看哪些分支合并入当前分支: $ git branch –merged

查看哪些分支未合并入当前分支: $ git branch –no-merged

更新远程库到本地: $ git fetch origin
推送分支: $ git push origin mybranch
取远程分支合并到本地: $ git merge origin/mybranch
取远程分支并分化一个新分支: $ git checkout -b mybranch origin/mybranch
删除远程分支:                 $ git push origin :mybranch

rebase: $ git checkout mybranch
$ git rebase master (rebase from master)

举例: $ git checkout server
$ git rebase –onto master server client
$ git checkout master
$ git merge client (fostforward)
$ git rebase master server (checkout sever)
$ git merge server
$ git branch -d client
$ git branch -d server

tag

  • 删除tag
    • git tag -d
    • git push origin :refs/tags/

子模块

Git Submodule管理项目子模块

安装数据库

yum install mariadb-server.x86_64

systemctl start mariadb

mysql -uroot

show databases
select user,host from mysql.user;

启动 phpmyading
systemctl restart httpd

桌面可视化编辑工具

参考文档

  • Eletron

    1
    Electron 是一款可以利用 Web技术 开发跨平台桌面应用的框架,最初是 Github 发布的 Atom 编辑器衍生出的 Atom Shell,后更名为 Electron。
  • Create React App

Electron 镜像

1
2
npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install -g electron

Electron 示例

1
2
3
4
git clone https://github.com/electron/electron-quick-start
cd electron-quick-start
npm install
npm start

Create React App

1
2
3
npx create-react-app my-app
cd my-app
npm start

Electron 知识点

1
2
3
4
//返回一个隐藏标题栏的全尺寸内容窗口
mainWindow = new BrowserWindow({width: 750, height: 500, titleBarStyle: 'hidden'})
//可拖拽窗口区域css设置
style="-webkit-app-region: drag"
1
2
默认打开浏览器
openBrowser(urls.localUrlForBrowser);

commander

  • 一个帮助快速开发Nodejs命令行工具的package

respawn

electron进程与进程之间的通信

child_process

在node中,child_process这个模块非常重要。掌握了它,等于在node的世界开启了一扇新的大门。熟悉shell脚本的同学,可以用它来完成很多有意思的事情,比如文件压缩、增量部署等,感兴趣的同学,看文本文后可以尝试下。

  • 创建进程

    下面列出来的都是异步创建子进程的方式,每一种方式都有对应的同步版本。
    .exec()、.execFile()、.fork()底层都是通过.spawn()实现的。
    .exec()、execFile()额外提供了回调,当子进程停止的时候执行。

Sass 是对 CSS 的扩展,让 CSS 语言更强大、优雅

主要功能

  • 变量定义
  • @for from to 遍历
  • @each in 遍历
  • @mixin @include 混合定义
  • @if @else
  • @extend 继承

例子

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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

$color1: purple;
$color2: orange;
$color3: red;
$color4: green;

@for $i from 1 to 5 {
@each $cor in $color1, $color2, $color3, $color4 {
.border-#{$cor}-#{$i} {
border: #{$i}px solid $cor;
}
}
}

@mixin createType($pm, $fx, $size){
#{$pm}-#{$fx}: #{$size*10}px;
}

@each $pm in padding, margin {
@each $type in top, right, bottom, left {
@for $i from 1 to 6 {
.#{$pm}-#{$type}-#{$i}{
@include createType($pm,$type,$i)
}
}
}
}

@each $pm in padding, margin {
@for $i from 1 to 6 {
.#{$pm}-#{$i}{
#{$pm}: #{$i*10}px;
}
}
}

$text-color: purple;
.cc{
font-weight:bold;
}

@mixin my{
color: $text-color;
font-size:20px;
}

@mixin createBorder($side, $width, $color){
border: $side $width $color;
}

.aa{
.color:$text-color;
$bgCor:blue;
.b{
color:red;
@extend .cc;
.c#{$text-color}{
background:$bgCor;
&:hover{
font-size:16px;
@include my;
}
}
}
}