Ubuntu16.04怎样安装Python3.7

Ubuntu16.04默认安装了Python2.7和3.5

请注意,系统自带的python千万不能卸载

  1. 检查当前版本号,输入命令python
  2. 按Ctrl+D退出python命令行
  3. 输入命令
    sudo add-apt-repository ppa:jonathonf/python-3.7
  4. 按Enter确认
  5. 输入命令
    sudo apt-get update
    sudo apt-get install python3.7
  6. 调整Python3的优先级,使得3.7优先级较高
    sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1
    
    sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 2
  7. 更改默认值,python默认为Python2,现在修改为Python3
    sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
    
    sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
  8. 此时再输入命令python,可以看到此时已经是Python3.7了

系统创建定时执行任务bat批处理删除指定N天前文件夹的文件

首先我们要创建一个.bat的文件,下面是创建删除几天前D盘backup目录下的文件

@echo off
echo Delete 3month ago files

forfiles /p "E:\backup\pdf_files" /s /m *.pdf /d -90 /c "cmd /c del @path"
forfiles /p "E:\backup\reportFile" /s /m *.pdf /d -90 /c "cmd /c del @path"
forfiles /p "E:\backup\EmailFiles" /s /m *.pdf /d -90 /c "cmd /c del @path"
forfiles /p "E:\backup\EmailFiles" /s /m *.txt /d -90 /c "cmd /c del @path"

forfiles /p "E:\backup\pdf_files" /s /m *.pdf /d -90 /c "cmd /c del @path"
forfiles /p "E:\backup\reportFile" /s /m *.pdf /d -90 /c "cmd /c del @path"
forfiles /p "E:\backup\EmailFiles" /s /m *.pdf /d -90 /c "cmd /c del @path"
forfiles /p "E:\backup\EmailFiles" /s /m *.txt /d -90 /c "cmd /c del @path"

echo Deleting files, please waiting...

将以上其中一行复制,新建.txt文本文件,粘贴并保存为.bat格式

继续阅读

SpringBoot设置cors跨域请求的两种方式

1、第一种:

public class CorsFilter extends OncePerRequestFilter {

    static final String ORIGIN = "Origin";

    protected void doFilterInternal(
        HttpServletRequest request,
        HttpServletResponse response,
        FilterChain filterChain) throws ServletException, IOException {

        String origin = request.getHeader(ORIGIN);

        response.setHeader("Access-Control-Allow-Origin", "*");//* or origin as u prefer
        response.setHeader("Access-Control-Allow-Credentials", "true");
        response.setHeader("Access-Control-Allow-Methods", "PUT, POST, GET, OPTIONS, DELETE");
        response.setHeader("Access-Control-Max-Age", "3600");
        response.setHeader("Access-Control-Allow-Headers", "content-type, authorization");

        if (request.getMethod().equals("OPTIONS"))
            response.setStatus(HttpServletResponse.SC_OK);
        else
            filterChain.doFilter(request, response);

    }
}
@Bean
public CorsFilter corsFilter() throws Exception {
    return new CorsFilter();
}

http
    .addFilterBefore(corsFilter(), UsernamePasswordAuthenticationFilter.class)
    .addFilterBefore(authenticationTokenFilterBean(), UsernamePasswordAuthenticationFilter.class)
    .headers()
    .cacheControl();

继续阅读

SQLServer中利用XML实现行转列

SELECT country
INTO #example
FROM (
  SELECT N'Chinese,Japan,English,Russia' AS country
  Union
  SELECT N'Chinese,Korea' AS country
) x

SELECT DISTINCT country
FROM (
  SELECT CAST('<v>'+REPLACE(country, ',' , '</v><v>') + '</v>' AS xml) AS countrys
  FROM #example
) a
OUTER APPLY (
  SELECT T.C.value('.','VARCHAR(100)') AS country
  FROM a.countrys.nodes('/v') AS T(C)
) b

 

Git常用命令

#创建dev分支
ArmyQins-Mac-mini:vue-ssr-tech armyqin$ git branch dev
ArmyQins-Mac-mini:vue-ssr-tech armyqin$ git branch -a

#在dev分支上进行操作同步服务器
ArmyQins-Mac-mini:vue-ssr-tech armyqin$ git checkout dev
ArmyQins-Mac-mini:vue-ssr-tech armyqin$ git branch -a
rmyQins-Mac-mini:vue-ssr-tech armyqin$ git pull origin master

#在dev分支上进行操作提交到服务器
ArmyQins-Mac-mini:vue-ssr-tech armyqin$ git add .
ArmyQins-Mac-mini:vue-ssr-tech armyqin$ git commit -m 'ss'
ArmyQins-Mac-mini:vue-ssr-tech armyqin$ git push -u origin master

#在master分支上进行操作
ArmyQins-Mac-mini:vue-ssr-tech armyqin$ git checkout master
ArmyQins-Mac-mini:vue-ssr-tech armyqin$ git branch -a
ArmyQins-Mac-mini:vue-ssr-tech armyqin$ git merge dev

#在master分支上进行操作
ArmyQins-Mac-mini:vue-ssr-tech armyqin$ git checkout master
ArmyQins-Mac-mini:vue-ssr-tech armyqin$ git branch -a
ArmyQins-Mac-mini:vue-ssr-tech armyqin$ git branch -D dev

ArmyQins-Mac-mini:vue-ssr-tech armyqin$ git branch -a


 

继续阅读

MyBatisGenerator插件及扩展(中文注释和Mapper重命名为DAO)

扩展MyBatis Generator

1. 将mybatis-generator-core项目克隆到本地

https://github.com/li24361/mybatis-generator-core

2. 将mybatis-generator-core打成jar包并存放到本地仓库中

cd mybatis-generator-core/

mvn install -Dmaven.test.skip=true

3. 修改pom.xml

<plugin>
	<groupId>org.mybatis.generator</groupId>
	<artifactId>mybatis-generator-maven-plugin</artifactId>
	<version>1.3.6</version>
	<configuration>
		<configurationFile>src/main/resources/generatorConfig.xml</configurationFile>
		<overwrite>true</overwrite>
		<verbose>true</verbose>
	</configuration>
	<dependencies>
		<dependency>
			<groupId>org.mybatis.generator</groupId>
			<artifactId>mybatis-generator-core</artifactId>
			<version>1.3.6</version>
		</dependency>
		<dependency>
			<groupId>com.haier.hairy</groupId>
			<artifactId>mybatis-generator-core</artifactId>
			<version>1.0.1</version>
		</dependency>
	</dependencies>
</plugin>

4. 修改generatorConfig.xml

<commentGenerator type="org.mybatis.generator.internal.HairyCommentGenerator">
    <property name="javaFileEncoding" value="UTF-8"/>
    <!--是否抑制所有的注释,默认为false-->
    <property name="suppressAllComments" value="false"/>
    <!--是否抑制注释中的时间,默认为false,这里改为true,不生成时间(如果生成时间,则每次都是新版本,每次都要提交)-->
    <property name="suppressDate" value="true"/>
</commentGenerator>

5. 运行Mybatis Generator

在IDEA中,点击Edit Configurations
–>添加一个Maven配置
–>录入Name GeneratorDAO
–>Command Line录入:mybatis-generator:generate -e
–>点击OK保存配置
–>点击或通过Alt+Shift+X运行这个Maven配置

 

 

用GitLab,Mac下如何生成SSH Key

步骤1.检查是否已经存在SSH Key

打开电脑终端,输入以下命令:

ls -al ~/.ssh

会出现两种情况

步骤2. 生成/设置SSH Key

继续上一步可能出现的情况

(1)情况一:终端出现文件id_rsa.pub 或 id_dsa.pub,则表示该电脑已经存在SSH Key,此时可继续输入命令:

pbcopy < ~/.ssh/id_rsa.pub

这样你需要的SSH Key 就已经复制到粘贴板上了,然后进行步骤3

(2)情况二:终端未出现id_rsa.pub 或 id_dsa.pub文件,表示该电脑还没有配置SSH Key,此时需要输入命令:

ssh-keygen -t rsa -C "your_email@example.com"

默认会在相应路径下(/your_home_path)生成id_rsa和id_rsa.pub两个文件,此时终端会显示:

Generating public/private rsa key pair.
Enter file in which to save the key (/your_home_path/.ssh/id_rsa):

连续回车即可,也可能会让你输入密码,密码就是你的开机密码

此时再输入命令:ls -al ~/.ssh    就会出现id_rsa.pub 和 id_dsa.pub两个文件,然后重复情况一的步骤即输入以下命令再进行步骤3即可:

pbcopy < ~/.ssh/id_rsa.pub

步骤3.将SSH Key添加到GitLab中

打开GitLab,  登录,点击设置, 找到左边栏有一个SSH密钥.

 

Nginx: 400 Bad Request | The plain HTTP request was sent to HTTPS port

 

20180301140903757

server {
    listen 80;
    server_name localhost;
    root html;
    index index.html index.htm;


    listen 443 ssl;  #注意这里
    #ssl on;
    ssl_certificate      cert/214525134250577.pem;
    ssl_certificate_key  cert/214525134250577.key;
    ssl_session_timeout 5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_protocols TLSv1;
    ssl_prefer_server_ciphers on;

    location / {
        root html;
        index index.html index.htm;
    }
}

删掉 ssl on; 并在 listen 443; 后面加上ssl即可 .

Ubuntu系统使用SSH免密码登陆

我们通常使用Ubuntu系统远程登陆时,一般使用 PASSWORD【用户名+密码】 的方式进行验证登陆,但是这种方式在使用的过程中需要频繁的输入用户名和密码,显得很繁琐,我们可以更具安全性的RSA密钥认证来避免这种登陆方式。

应用场景:

我们需要从Client机器上远程登陆Server机器。登陆方式采用RSA密钥免密码登陆方式。其中Client端与Server端都为Ubuntu系统。

  • Server端需要安装并开启SSH服务

  • Client端需要支持ssh-keygen命令

  • 确认两台机器能够连接到Internet

继续阅读