git无父分支

创建无父分支

1
git checkout --orphan version2 #创建分支时会继承父分支已经commit过里面的文件

删除继承过来的东西

1
git rm -rf . #删除继承过来的对象

添加新的对象

1
git add .

提交新的对象

1
git commit -m "version2 commit "

应用场景

每个分支管理不同的产品

一个分支管理博客静态代码,一个分支管理源码

mybatis generator 的使用和问题

mybatis generator 自动生成代码

需要准备的jar包

1
2
3
4
5
├── generatorConfig.xml
├── mybatis-3.2.7.jar
├── mybatis-generator-core-1.3.2.jar
├── mysql-connector-java-5.1.30.jar
└── src

配置文件如下:

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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<!-- 数据库驱动-->
<classPathEntry location="mysql-connector-java-5.1.30.jar"/>
<context id="DB2Tables" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressDate" value="true"/>
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!--数据库链接URL,用户名、密码 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://127.0.0.1/db_icp" userId="root" password="xxxx">
</jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- 生成模型的包名和位置-->
<javaModelGenerator targetPackage="com.hundsun.acm.model" targetProject="src">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!-- 生成映射文件的包名和位置-->
<sqlMapGenerator targetPackage="main.resources.mapping" targetProject="src">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!-- 生成DAO的包名和位置-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.hundsun.acm.dao" targetProject="src">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
<!--想要生成几个表,就写几个table标签-->
<table tableName="zxxxb" domainObjectName="Zxxx" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
</context>
</generatorConfiguration>

1
2
## -overwrite 是覆盖选项,如果第一次生成没必要加
$java -jar mybatis-generator-core-1.3.2.jar -configfile generatorConfig.xml -overwrite

生成之后的目录结构

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
├── generatorConfig.xml
├── mybatis-3.2.7.jar
├── mybatis-generator-core-1.3.2.jar
├── mysql-connector-java-5.1.30.jar
└── src
├── com
│   └── hundsun
│   └── acm
│   ├── dao
│   │   └── ZxxxMapper.java
│   └── model
│   ├── Zxxx.java
│   └── ZxxxWithBLOBs.java
└── main
└── resources
└── mapping
└── ZxxxMapper.xml

date类型映射错误

应该映射成 java.sql.Date
但是却映射成 java.util.Date

jdbc type 和 javaType的映射关系

apache官方链接

JDBC是直接和数据库打交道的,因此类型基本与数据库类型一致

linux wireshark 权限问题

背景知识

最近需要分析一些http 报文里面的一些细节问题,比如post是如何携带数据传递给后台的

需要安装wireshark 来分析报文

1
sudo pacman -S wireshark-gtk

遇到的问题 

无法显示网卡列表 /usr/bin/dumpcap子进程启动失败

更改当前执行用户的权限即可

可以更改用户的用户组

1
sudo usermod -aG wireshark currentUserName

也可以直接用chmod更改程序的权限

1
sudo chmod u+x /usr/bin/dumpcap

选中相应网卡后提示没有权限

第一种解决办法

1
setcap 'CAP_NET_RAW+eip CAP_NET_ADMIN+eip' /usr/sbin/dumpcap

参数简要解释

eip是将chown的能力以cap_effective(e),cap_inheritable(i),cap_permitted(p)三种位图的方式授权给相关的程序文件.

CAP_NET_RAW 13 (允许使用原始(raw)套接字)

CAP_NET_ADMIN 12 允许执行网络管理任务:接口、防火墙和路由等.

普通用户不能创建新的网络接口(interface),不能更改ip地址,而CAP_NET_ADMIN可以帮助普通用户完成这项工作

原始套接字编程可以接收到本机网卡上的数据帧或者数据包,对监控网络流量和分析是很有作用的.

wireshark 官方wiki 权限问题

Linux的capability深入分析

第二种解决办法

1
2
3
chown root /usr/bin/dumpcap
chmod u+s /usr/bin/dumpcap

Mybatis学习笔记

mybatis 的基本组织方式

核心配置文件
sqlxml文件

mybatis新颖的地方

  • 将sql独立成xml文件,将这种方式作为唯一处理sql的方式,将sql作为独立的一部分。
  • 支持接口编程,dao层无需实现(但不许遵循mybatis接口编程的规范)

sql语句支持ognl表达式

  • 可直接调用java对象的方法
  • where set sql … 极大的增加了sql的灵活性和功能性
  • 灵活的日志框架

    控制台调试Mybatis

    mybatis中文文档-日志说明

  • 独立mybatis的话,核心配置文件,配置日志的接口

    1
    2
    3
    4
    5
    6
    7
    <configuration>
    <settings>
    ...
    <setting name="logImpl" value="LOG4J"/>
    ...
    </settings>
    </configuration>

log4j.properties文件的配置

1
2
3
4
5
log4j.rootLogger=DEBUG,Console
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n
log4j.logger.org.apache=INFO

  • 如果要跟spring结合的话,在web.xml添加log4j的相关参数
    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
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    id="WebApp_ID" version="2.5">
    <!--log4j参数部分-->
    <context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>classpath:log4j.properties</param-value>
    </context-param>
    <context-param>
    <param-name>log4jExposeWebAppRoot</param-name>
    <param-value>true</param-value>
    </context-param>
    <context-param>
    <param-name>log4jRefreshInterval</param-name>
    <param-value>10000</param-value>
    </context-param>
    <!--log4j监听器-->
    <listener>
    <listener-class>
    org.springframework.web.util.Log4jConfigListener
    </listener-class>
    </listener>
    </web-app>

Mybatis 常用标签

1
2
3
4
5
6
7
8
9
10
11
<selelct id="" resultMap="" parameterType="">
selelct * from MESSAGE
<where>
<if test="">
and COMMAND =#{commonad}
</if>
<if test="">
and DESCRIPTION
</if>
</where>
</selelct>

where 标签的作用:
如果条件都不满足的话可执行空条件查询
Mybatis-tags

linux-制作启动盘

dd制作启动盘

1
2
3
4
5
6
7
8
9
10
11
dd -i /path/to/ubuntu16.04.iso -o /dev/sdx
#sdx x指的是第几块硬盘 不能是sdx1,sdx2等磁盘分区,而是整块硬盘,通过lsblk可显示块设备
➜ hexo lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme0n1 259:0 0 238.5G 0 disk
├─nvme0n1p1 259:1 0 18.7G 0 part /
├─nvme0n1p2 259:2 0 1.9G 0 part /boot
├─nvme0n1p3 259:3 0 1K 0 part
├─nvme0n1p5 259:4 0 15.1G 0 part [SWAP]
└─nvme0n1p6 259:5 0 202.9G 0 part /home
#我的本机硬盘是ssd,识别的时候名称不再是传统的命令方式

hexo 遇到的问题

参考文档

github+hexo搭建独立博客

## 淘宝的npm源无法安装成功,标准的可以

1
2
3
$ npm install -g cnpm --registry=https://registry.npm.taobao.org
$ npm install hexo-cli -g
$ npm install hexo --save

本想加快速度,但却安装失败

hexo 常用插件汇总

1
2
3
4
5
6
7
8
9
10
11
12
13
$ npm install hexo-generator-index --save
$ npm install hexo-generator-archive --save
$ npm install hexo-generator-category --save
$ npm install hexo-generator-tag --save
$ npm install hexo-server --save
$ npm install hexo-deployer-git --save
$ npm install hexo-deployer-heroku --save
$ npm install hexo-deployer-rsync --save
$ npm install hexo-deployer-openshift --save
$ npm install hexo-renderer-marked@0.2 --save
$ npm install hexo-renderer-stylus@0.2 --save
$ npm install hexo-generator-feed@1 --save
$ npm install hexo-generator-sitemap@1 --save

markdown 语法基本问题

如何使用标签和目录

标准写法参照本文档开头部分

空格是重要的分隔符

tags 后’-‘之后要有空格,否则无法识别标签
_config.yml 每一个配置项后面要有空格

如何为hexo的常用变量赋值

title: 标题名

hexo 是如何解析变量的?

1
2
3
4
5
6
7
8
9
10
11
---
变量名: 值
title: 文章名
categories: 目录名
tags: tag4
tags:
- tag1
- tag2
- tag3
---