2018-11-09 09:43:03   Visit  13

简单服务

var http = require(\'http\');

http.createServer(function (request, response) {

    // 发送 HTTP 头部 
    // HTTP 状态值: 200 : OK
    // 内容类型: text/plain
    response.writeHead(200, {\'Content-Type\': \'text/plain\'});

    // 发送响应数据 \"Hello World\"
    response.end(\'Hello World\\n\');
}).listen(8888);

// 终端打印如下信息
console.log(\'Server running at http://127.0.0.1:8888/\');

http静态文件服务

安装http-server

npm install http-server -g

启动服务

http-server -p 8089
2018-11-07 11:29:52   Visit  17

添加postgresql官网安装源

在/etc/yum.repos.d目录下新建pgdg-10-centos.repo 文件

[pgdg10]
name=PostgreSQL 10 $releasever - $basearch
baseurl=https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-$releasever-$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-10

[pgdg10-source]
name=PostgreSQL 10 $releasever - $basearch - Source
failovermethod=priority
baseurl=https://download.postgresql.org/pub/repos/yum/srpms/10/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-10

[pgdg10-updates-testing]
name=PostgreSQL 10 $releasever - $basearch
baseurl=https://download.postgresql.org/pub/repos/yum/testing/10/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-10

[pgdg10-source-updates-testing]
name=PostgreSQL 10 $releasever - $basearch - Source
failovermethod=priority
baseurl=https://download.postgresql.org/pub/repos/yum/srpms/testing/10/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-10

更新yum

yum update

安装

yum install postgresql10-contrib postgresql10-server -y

初始化数据库

/usr/pgsql-10/bin/postgresql-10-setup initdb

创建服务链接

sudo systemctl start postgresql-10
sudo systemctl enable postgresql-10.service

切换到postgresql用户

su postgres
2018-11-07 10:34:14   Visit  13
route add 10.0.0.0 mask 255.0.0.0 172.16.1.253 -p
2018-11-05 11:04:46   Visit  16

版本

git add filename  //添加文件至暂存区
git commit -m “commit  description” // 提交暂存区至版本(只提交暂存区的内容,工作区修改未提交至暂存区的不提交至版本)
git status   查看状态
git diff 比对

文件管理

git add test.txt
git rm test.txt
git checkout -- test.txt   //恢复在文件系统中误删的文件,恢复在工作区中修改的文件

git reset HEAD readme.txt  //撤销暂存区的修改(工作区中仍然是修改状态,如果想恢复原来文件,使用checkout恢复文件至上一个版本)

关联远程


git remote add origin git@server-name:path/repo-name.git

git remote -v  显示远程服务信息
git remote rm origin  删除远程关联

提交至远程

git push -u origin master  --第一次推送master分支的所有内容
git push origin master  --推送最新修改

clone

$ git clone git@github.com:michaelliao/gitskills.git

分支

查看分支:git branch

创建分支:git branch <name>

切换分支:git checkout <name>

创建+切换分支:git checkout -b <name>
从远程获取分支: git checkout -b dev origin/dev

合并某分支到当前分支:git merge <name>

删除分支:git branch -d <name>
删除未合并过的分支:git branch -D <name>

关联本地分支和远程分支 :  git branch --set-upstream-to=github/dev dev

储藏

git status  保存现在的工作空间
git stash list 
git stash apply 恢复指定储藏
git stash drop 删除指定储藏 默认最后一个
git stash pop 恢复并删除最后一个储藏

日志

图形化显示日志
git log --graph --pretty=oneline --abbrev-commit

git config --global alias.lg \\\\\\\"log --color --graph --pretty=format:\\\\\\\'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset\\\\\\\' --abbrev-commit\\\\\\\"

标签

git tag v1.0  打标签
git tag v0.9 f52c633    根据给定的提交版本打标签
git tag -a v0.1 -m  \\\"version 0.1 released \\\" 1094adb  根据给定的提交版本打标签  并添加说明
git tag  查看标签列表
git show v0.1  查看标签详情

git tag -d v0.1  删除标签
git push GitHub :refs/tags/v0.1 删除远程标签

git push GitHub v1.0  推送指定标签到远程
git push GitHub --tags 推送所有标签到远程

https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000

2018-11-02 11:23:09   Visit  22

在/etc/yum.repos.d 目录下创建文件gitlab-ce.repo,使用国内的安装源

baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1

清理yum缓存

yum makecache

安装

yum install gitlab-ce

gitlab-ce 在centos中的目录

配置目录在这里
/etc/gitlab
主目录在这里
/opt/gitlab
运行目录在这里

gitlab-ctl reconfigure 后生成的新的配置文件都在这里

/var/opt/gitlab

启动

gitlab-ctl start

修改配置

配置文件是 /etc/gitlab 下的gitlab.rb

修改域名

external_url \\\'https://gitlab.leechg.com\\\'

配置nignx端口

gitlab内置NGINX,修改其配置也要在gitlab.rb文件中进行

nginx[\\\'listen_port\\\'] = 8100

gitlab服务端口修改

# unicorn[\\\'backlog_socket\\\'] = 1024

修改完配置后一定要运行 gitlab-ctl reconfigure 才能生效

gitlab-ctl reconfigure 
2018-10-29 16:57:07   Visit  20

安装python的docx支持

python -m pip install  python-docx
# -*- coding: utf-8 -*-
import docx
from docx import Document
 

path = \"./file2.docx\"
document = Document(path)
 
def readlist():
    table_count = 0
    row_count = 0
    textlist = []
    for paragraph in document.paragraphs:
        
        r_text = paragraph.text
        textlist.append(r_text)
     
        row_count = row_count+1
        if r_text.startswith(u\'表名\'):
            # print row_count
            
            tablenamec =  textlist[row_count-2]
            tablenamearr = textlist[row_count-1].split(u\':\')
            tablename  = tablenamearr[len(tablenamearr)-1]
            print tablenamec,tablename
            readtable(table_count)
            textlist = []
            row_count=0
            table_count =table_count+1

def readtable(table_count): 
    # 遍历所有表格
    tables = document.tables
    table = tables[table_count]
    rowlen = len(table.rows)
    if rowlen>1:
        collen = len(table.rows[0].cells)
        row_num = 0
        for row in table.rows:
            if(row_num>0):
                colname = row.cells[1].text
                colnamec = row.cells[2].text
                bz = \"\"
                if(collen>4):
                    bz =  row.cells[4].text
                else:
                    bz =  row.cells[3].text
                sql = u\"insert into tablename (a,b,c,d) values(\'{0}\',\'{1}\',\'{2}\',\'{3}\')\".format(row_num,colname,colnamec ,bz)
                # print sql
            row_num = row_num +1
    # 
    # for table in document.tables:
    #     for row in table.rows:
    #         print row.cells[2].text

if __name__ ==\"__main__\":
    print \"start\"
    readlist()

2018-10-26 11:41:50   Visit  17
function js_getDPI() {
 var arrDPI = new Array();
 if (window.screen.deviceXDPI != undefined) {
? arrDPI[0] = window.screen.deviceXDPI;
? arrDPI[1] = window.screen.deviceYDPI;
 }
 else {
? var tmpNode = document.createElement(\"DIV\");
? tmpNode.style.cssText = \"width:1in;height:1in;position:absolute;left:0px;top:0px;z-index:99;visibility:hidden\";
? document.body.appendChild(tmpNode);
? arrDPI[0] = parseInt(tmpNode.offsetWidth);
? arrDPI[1] = parseInt(tmpNode.offsetHeight);
? tmpNode.parentNode.removeChild(tmpNode); 
 }
 return arrDPI;
} 
2018-10-22 17:03:21   Visit  25

React组件使用{}方式引入字符串时默认会转义其中的非法字符,以下方法不转义

<div dangerouslySetInnerHTML={{__html: \"<div>\"+this.state.DescriptionWillShow+\"</div>\"}} />
The \\\'Access-Control-Allow-Origin\\\' header contains multiple values \\\'http://localhost:5000, *\\\', but only one is allowed. Origin \\\'http://localhost:5000\\\' is therefore notallowed access.

在iis中父级和子应用同时配置了Access-Control-Allow-Origin = * 响应头。删除任意一个配置就可以了。

2018-10-19 16:04:00   Visit  25
mapOption = { {
        portalItem: { // autocasts as new PortalItem()
            portal: {
                url: \"https://localhost/portal/\"
            },
            id: \"e487c8e548a4474e8ff161563568aa98\"
        }
    }
}

// then we load a web map
var map = new Map(mapOption);
// and we show that map in a container w/ div
var view = new View(Object.assign({
            map: map,
            container: container
        }, viewOption));