git使用的tag

Tag类似于branch,区别是branch是可以不断改变、Merge的而Tag不行。Tag可以认为是一个快照、一个记录点,用于记录某个commit点或分支的历史快照。Tag通常打开Master分支上,以保证代码的准确性。

创建Tag

1
git tag <Tag名字>

这样创建的tag,默认会记录在最后提交的上。也可以通过commit id 指定要创建Tag 的地方。

1
git tag <Tag 名字> <SHA-1 Code>

创建带标签的Tag

1
git tag -a <Tag名字> -m <注释文字> <SHA-1 Code>

SHA-1 Code 并不需要全部写完,只要写前6、7 位就差不多了,Git就可以查找到相应的id了。

查看Tag

1
git tag

查看指定Tag的详细信息

1
git show <Tag 名字>

删除标签

1
git tag -d <Tag 名字>

推送Tag到远程

1
git push origin <Tag 名字>

或者通过–tags 参数来推送所有本地的Tag

1
git push origin --tags

删除远程Tag

当本地Tag已经Push到远程代码仓库后,再要删除这个Tag,就必须删除本地Tag.

1
git tag -d <Tag 名字>

删除本地Tag后,再重新Push到远程的代码仓库。

1
git push origin :refs/tags/<Tag 名字>

BottomNavigationView 的使用

不多说先上效果图

zhouchatian.com

添加依赖

compile ‘com.android.support:design:25.0.0’

添加控件

在布局文件添加BottomNavigationView组件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.zhouchatian.baseandroid.MainActivity">
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:layout_centerInParent="true"/>
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:menu="@menu/navigation"/>
</RelativeLayout>

添加按钮

在res下创建navigation.xml 放在menu文件夹下,如果没有就创建一个menu文件夹

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/bottom_home"
android:icon="@mipmap/ic_home_white_24dp"
android:title="首页" />
<item
android:id="@+id/bottom_book"
android:icon="@mipmap/ic_book_white_24dp"
android:title="书本" />
<item
android:id="@+id/bottom_collection"
android:icon="@mipmap/ic_favorite_white_24dp"
android:title="收藏"/>
<item
android:id="@+id/bottom_setting"
android:icon="@mipmap/ic_tv_white_24dp"
android:title="设置" />
</menu>

要说下的这个按钮只能创建3个到5个,多了或少了都会报错。

添加监听

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public class MainActivity extends AppCompatActivity {
private TextView mTextView;
private BottomNavigationView mNavigationView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTextView = (TextView) findViewById(R.id.text);
mNavigationView = (BottomNavigationView) findViewById(R.id.navigation);
mNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
mTextView.setText(item.getTitle().toString().toUpperCase());
return true;
}
});
}
}

这样一个建的底部导航就做好了,控件使用简单,带来局限性,只有修改一些。

修改

app:itemIconTint=”#FFFFFF”设置图标的颜色

app:itemTextColor=”#FFFFFF”设置文字的颜色

app:itemBackground=”@color/colorPrimary” 设置背景色

如果不设置就是上图的颜色,官方提供了三个颜色

zhouchatian.com

1
2
3
4
5
6
7
8
9
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:itemIconTint="#FFFFFF"
app:itemTextColor="#FFFFFF"
app:itemBackground="@color/colorPrimary"
app:menu="@menu/navigation"/>

当然你也可以在代码中设置

setItemBackgroundResource(int resId)
setItemIconTintList(ColorStateList tint)
setItemTextColor(ColorStateList textColor)

在实际开发中使用item.getItemId()使用switch来判断选中了哪一个

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
mNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.bottom_home:
mTextView.setText(item.getTitle());
break;
case R.id.bottom_book:
mTextView.setText(item.getTitle());
break;
case R.id.bottom_collection:
mTextView.setText(item.getTitle());
break;
case R.id.bottom_setting:
mTextView.setText(item.getTitle());
break;
}
return true;
}
});

其实这个还有另外一个监听

BottomNavigationView.OnNavigationItemReselectedListener

官方解释用于重选的监听,特意提下是希望各位用的时候别选错了。

问题

1. 默认选中的是第一个,但是我们要默认选中其他的怎么办?

官方提供了两个方法

getSelectedItemId(int itemId)

获得选中item的id,这时我们就可以使用另一个方法

setSelectedItemId(int itemId)

git提交代码三部曲

拉取远程库最新代码

1
git pull

把工作区的代码提交到暂存区

1
git add .

或者

1
git add <文件名字>

add . 代表所有文件,注意add 和 点之间有空格

把暂存区的代码提交到历史区

1
git commit -m "备注信息"

把历史区代码提交到远程库

1
git push

https://github.com/TheSadFrog

最后贴上git 的工作过程示意图

https://github.com/TheSadFrog

新建分类

在命令行里面输入:

hexo new page “about”
然后你会发现source里面多了个目录about,里面有个index.md。其实你也可以手动建立。页面的格式和文章一样。

接着把链接加上,themes//_config.yml里面的menu一项,添加一行About: /about。

完事。

Android Stuido 无线调试

安装插件

Android Studio 打开
File>Seting>Plugins输入ADB WIFI点击Search in repositories搜索,选择ADB WIFI 右边点击Install就安装好了
https://github.com/TheSadFrog

如何使用

  1. 你手机必须usb连接电脑,并且Android直接能运行。手机和电脑必须在同一局域网下
  2. Android Studio 打开
    Tools>Android>ADB WIFI>ADB Restart
    https://github.com/TheSadFrog
  3. Android Studio 打开
    Tools>Android>ADB WIFI>ADB USB to WIFI到此就可以无线使用了。现在可以拔掉usb后Android 还是显示有一个设备连接着。

    问题

    重启Android Studio不会自动连接,如果你没带数据线还是白忙活了半天。

    解决方法

使用adb 命令连接手机,即使有一天数据线坏了也照常可以使用。

1.配置环境变量

win7右键点击计算机属性 >高级系统设置>环境变量

https://github.com/TheSadFrog
下面系统变量新建
https://github.com/TheSadFrog
把你安装SDK目录下的platform-tooltools 路径配置上。
再把Android 加入到系统变量中
https://github.com/TheSadFrog
名字要对,%Android% 刚才新建的,注意要分好隔开。
现在你可以打开命令行 win+r 输入cmd 然后输入 adb 如果出现下面这个,就代表配置成功,如果出现不是系统命令就没配置成功。
https://github.com/TheSadFrog

2.使用adb 命令连接手机

adb connect <你手机的ip地址>

你手机局域网的网络IP地址,在手机设置>WLAN 你连接的WiFi长按修改网络就看到ip地址。

adb devices

就可以看到你的手机连接,当然你也可以不用打开命令行工具。Android studio自带一个,在底部Terminal 这个和cmd 也是一样的。现在就可以运行你的程序,会有你的连接的手机。到时你把测试手机拿过来,搞好,直接就可以操作他的手机了。我不会告诉你

adb uninstall <包名可以卸载程序>

可以卸载程序哦。

Hexo更换主题

使用Hexo更换主题还算方便,先使用克隆命令安装好主题,然后更改一下博客的配置文件D:\hexo_config.yml里面的主题名称就好了。

1. 安装主题

在博客目录D:\hexo下右键点击Git Bash,输入以下命令。其他的主题也类似操作。

1
git clon https://github.com/wuchong/jacman.git themes/jacman

或者到D:\hexo\themes目录下执行

1
git clon https://github.com/wuchong/jacman.git

2. 启用主题

修改博客目录D:\hexo_config.yml中的theme属性,将其设置为jacman。

1
theme: jacman

3. 更新主题

在主题更新之前,一定要备份好主题目录下的_config.yml文件,尤其是到后面修改了很多配置之后。在themes/jacman目录下执行

1
git pull origin master

就这么简单,更换Hexo 主题。

Markdown简明语法

一级标题

二级标题

三级标题

四级标题

  • 无序列表1
  • 无序列表2
  • 无序列表3
  • 无序列表1
  • 无序列表
    • 无序列表2.1
      • 列表内容
  • 列表内容
  1. 有序列表1
  2. 有序列表2
  3. 有序列表3

这个是引用

这个是粗体
这个斜体
这个是粗体加斜体
这里写图片描述

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
这里是代码块
```
~~我是删除~~
换行 空格+空格+回车
分割线
---
这是表格
header 1 | header 2
---|---
row 1 col 1 | row 1 col 2
row 2 col 1 | row 2 col 2
[超链接](http://note.youdao.com/)
数学公式
```math
E = mc^2

② 制作待办事项To-do List

  • [x] 已完成项目
    • [x] 已完成事项1
    • [x] 已完成事项2
  • [ ] 待办事项1
  • [ ] 待办事项2

Hexo搭建个人博客

环境准备

  1. 安装git,自行百度
  2. 安装Node.js通过Homebrew或者从官网上下载安装包的方式都可以进行安装。
    安装完毕后打开终端,检查是否安装正确。
1
2
3
- node -v
- npm -v
- git --version

安装Hexo

创建一个目录blog(你也可以改为你喜欢的名字),然后执行以下指令。(以下指令均用Git Bash 终端下)

1
npm install -g hexo-cli

初始化

1
hexo init

本地部署测试

到此你的Hexo 本地已经安装完成在Git Bash 终端下输入以下指令即可运行本地测试服务。

1
hexo server

服务器运行起来之后,打开浏览器,输入http://localhost:4000/ 即可打开Hexo的默认页,如图
ctrl + C 结束本地预览。

部署到github

  • 首先你的有个github 账号,注册github账号自行百度。
  • 在github创建一个repository 名字为你的organization名字 .github.io
  • 你安装的hexo目录(就刚才建的blog)下的_config.yml文件翻到最下面,改成我这样子的(冒号后面有空隔)
1
2
3
4
deploy:
type: git
repository: https://github.com/zhouchatian/zhouchatian.github.io.git
branch: master

repository就是你刚才在github上创建的repository 的ssh。

推送到github

1.首先安装git 一个插件
执行命令:

1
npm install hexo-deployer-git --save

2.推送到个ithub

1
hexo deploy

到此你的Hexo已经完成了,那么开始写博客吧

新建博客

1.命令生成

1
hexo new "文章名字"

新生成的文章都会保存到/source/_posts 目录下。打开自动生成的文档模板,内容如下:

1
2
3
4
5
---
title: testMyBlog
date: 2017-03-09 07:20:04
tags:
---

可以在这用Markdown 写作工具打开,编写文章。
2.文档拷贝

生成博客

1
hexo generate

在这之前最好执行下

1
hexo clean

3.发布到github上

1
hexo deploy

常用快捷命令

1
2
3
4
5
6
7
hexo new "postName" //新建文章
hexo new page"pageNme" //新建页面
hexo server //开启预览访问端口(默认端口4000,`ctrl+c`关闭server)
hexo generate //生成静态页面至public目录
hexo deploy //将deploy 目录部署到服务器
hexo help //查看帮助
hexo version //查看Hexo的版本

对应的快捷指令

1
2
3
4
5
hexo n ==hexo new
hexo g ==hexo generate
hexo s ==hexo server
hexo d ==hexo deploy
hexo h ==hexo help