打个比方 我们有个文件夹project project里面有一堆文件夹 aaa,bbb,ccc,我们需要找到aaa文件夹的其中某个文件file.txt的修改记录 我们可以再project上开启git操作 然后 输入 git blame -L 11,12 aaa/file.txt -L 11,12 含义是该文件的第11行和12行的修改记录 from:https://www.cnblogs.com/1179929172-zh/p/12938344.html
View Detailsgit bisect是一个很有用的命令,用来查找哪一次代码提交引入了错误。 它的原理很简单,就是将代码提交的历史,按照两分法不断缩小定位。所谓"两分法",就是将代码历史一分为二,确定问题出在前半部分,还是后半部分,不断执行这个过程,直到范围缩小到某一次代码提交。 本文通过一个实例,解释如何使用这个命令。下面是一个代码库,请将它克隆到本地。
|
1 2 3 4 |
$ git clone <a class="token email-link" href="mailto:git@github">git@github</a><span class="token punctuation">.</span>com<span class="token punctuation">:</span>bradleyboy<span class="token operator">/</span>bisectercise<span class="token punctuation">.</span>git $ cd bisectercise |
这个库是一个网页index.html,在浏览器打开这个网页。
|
1 2 3 |
$ open index<span class="token punctuation">.</span>html |
网页上是一个计数器,有两个按钮。点击+号按钮,可以看到计数器没有递增,反而递减,这说明代码有问题。 现在,就要来查找,到底哪一次代码提交,引入了错误。首先,检查一下代码提交历史。
|
1 2 3 |
$ git log <span class="token operator">--</span>pretty<span class="token operator">=</span>oneline |
可以看到,这个库一共有101次提交。最早的第一次提交的哈希是4d83cf。 git bisect start命令启动查错,它的格式如下。
|
1 2 3 |
$ git bisect start <span class="token punctuation">[</span>终点<span class="token punctuation">]</span> <span class="token punctuation">[</span>起点<span class="token punctuation">]</span> |
上面代码中,"终点"是最近的提交,"起点"是更久以前的提交。它们之间的这段历史,就是差错的范围。 这个例子中,我们选择全部的代码历史。起点是第一次提交4d83cf,终点是最近一次的HEAD。当然,指定其他范围也可以。
|
1 2 3 |
$ git bisect start HEAD 4d83cf |
执行上面的命令以后,代码库就会切换到这段范围正当中的那一次提交,本例是第51次提交。 现在刷新浏览器,点击+按钮,发现可以正常递增。使用git bisect good命令,标识本次提交(第51次)没有问题。
|
1 2 3 |
$ git bisect good |
既然第51次提交没有问题,就意味着错误是在代码历史的后半段引入的。执行上面的命令,Git 就自动切换到后半段的中点(第76次提交)。 现在刷新浏览器,点击+按钮,发现不能正常递增。使用git bisect bad命令,标识本次提交(第76)有问题。
|
1 2 3 |
$ git bisect bad |
执行上面的命令以后,Git 就自动切换到第51次到第76次的中点(第63次提交)。 接下来,不断重复这个过程,直到成功找到出问题的那一次提交为止。这时,Git 会给出如下的提示。
|
1 2 3 |
b47892 is the first bad commit |
既然找到那个有问题的提交,就可以检查代码,确定具体是什么错误。 然后,使用git bisect reset命令,退出查错,回到最近一次的代码提交。
|
1 2 3 |
$ git bisect reset |
现在就可以开始修复错误了。 (完) from:http://www.ruanyifeng.com/blog/2018/12/git-bisect.html
View Detailsnginx访问时报403, 于是查看nginx日志,路径为/var/log/nginx/error.log。打开日志发现报错Permission denied,详细报错如下: 1. open() "/data/www/1.txt" failed (13: Permission denied), client: 192.168.1.194, server: www.web1.com, request: "GET /1.txt HTTP/1.1", host: "www.web1.com" 没有权限?于是找了不少资料,可以通过下面四步排查解决此问题。你可能只是其中之前配置有问题,不一定四个步骤都用上。 一、由于启动用户和nginx工作用户不一致所致 1.1查看nginx的启动用户,发现是nobody,而为是用root启动的 命令:ps aux | grep "nginx: worker process" | awk'{print $1}' 1.2将nginx.config的user改为和启动用户一致, 命令:vi conf/nginx.conf 二、缺少index.html或者index.php文件,就是配置文件中index index.html index.htm这行中的指定的文件。 1. server { 2. listen 80; 3. server_name localhost; 4. index index.php index.html; 5. root /data/www/; 6. } 如果在/data/www/下面没有index.php,index.html的时候,直接文件,会报403 forbidden。 三、权限问题,如果nginx没有web目录的操作权限,也会出现403错误。 解决办法:修改web目录的读写权限,或者是把nginx的启动用户改成目录的所属用户,重启Nginx即可解决 1. chmod -R 777 /data 2. chmod -R 777 /data/www/ 四、SELinux设置为开启状态(enabled)的原因。 4.1、查看当前selinux的状态。 1. /usr/sbin/sestatus 4.2、将SELINUX=enforcing 修改为 SELINUX=disabled 状态。 1. vi /etc/selinux/config 2. 3. #SELINUX=enforcing 4. SELINUX=disabled 4.3、重启生效。reboot。 1. reboot from:https://blog.csdn.net/qq_35843543/article/details/81561240
View Details报错描述: nginx: [emerg] bind() to 0.0.0.0:8088 failed (13: Permission denied) 通过ansible远程给主机更换端口并重新启动nginx服务,出现以上报错信息(权限被拒绝)。 解决方式:经检查发现是selinux导致报错。 [root@localhost nginx]# getenforce #查询selinux状态 [root@localhost nginx]# setenforce 0 #临时将selinux关闭 如果需要永久关闭selinux,请编辑/etc/selinux/config文件,将SELINUX=disabled。之后将系统重启一下即可。 之后重启nginx服务,发现报错已经解除。 from:https://www.cnblogs.com/python-wen/p/11358978.html
View Details1 打开 首选项-设置 2 按照下图1,2,3执行即可 from:https://blog.csdn.net/sunyan3517/article/details/103944040
View Details|
1 2 3 4 5 6 7 8 9 10 11 12 |
public class test1_format { public static void main(String[] args) { BigDecimal decimal = new BigDecimal("1.12345"); System.out.println(decimal); BigDecimal setScale = decimal.setScale(4,BigDecimal.ROUND_HALF_DOWN); System.out.println(setScale); BigDecimal setScale1 = decimal.setScale(4,BigDecimal.ROUND_HALF_UP); System.out.println(setScale1); } } |
参数定义 ROUND_CEILING Rounding mode to round towards positive infinity. 向正无穷方向舍入 ROUND_DOWN Rounding mode to round towards zero. 向零方向舍入 ROUND_FLOOR Rounding mode to round towards negative infinity. 向负无穷方向舍入 ROUND_HALF_DOWN Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round down. 向(距离)最近的一边舍入,除非两边(的距离)是相等,如果是这样,向下舍入, 例如1.55 保留一位小数结果为1.5 ROUND_HALF_EVEN Rounding mode to round towards the "nearest neighbor" unless both neighbors are equidistant, in which case, round towards the even neighbor. 向(距离)最近的一边舍入,除非两边(的距离)是相等,如果是这样,如果保留位数是奇数,使用ROUND_HALF_UP ,如果是偶数,使用ROUND_HALF_DOWN ROUND_HALF_UP Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in […]
View Details1、Math中四舍五入的方法 Math.ceil(double a)向上舍入,将数值向上舍入为最为接近的整数,返回值是double类型 Math.floor(double a)向下舍入,将数值向下舍入为最为接近的整数,返回值是double类型 Math.round(float a)标准舍入,将数值四舍五入为最为接近的整数,返回值是int类型 Math.round(double a)标准舍入,将数值四舍五入为最为接近的整数,返回值是long类型 2、Math中random生成随机数 Math.random()生成大于等于0,小于1的随机数 3、Random类生成随机数 两种构造方式:第一种使用默认的种子(当前时间作为种子),另一个使用long型整数为种子,Random类可以生成布尔型、浮点类型、整数等类型的随机数,还可以指定生成随机数的范围 4、BigDecimal处理小数 两种构造方式:第一种直接value写数字的值,第二种用String
|
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 |
import java.math.BigDecimal; import java.util.Random; import java.util.concurrent.ThreadLocalRandom; public class TestNumber { public static void main(String[] args){ //ceil返回大的值 System.out.println(Math.ceil(-10.1)); //-10.0 System.out.println(Math.ceil(10.7)); //11.0 System.out.println(Math.ceil(-0.7)); //-0.0 System.out.println(Math.ceil(0.0)); //0.0 System.out.println(Math.ceil(-0.0)); //-0.0 System.out.println(Math.ceil(-1.7)); //-1.0 //floor返回小的值 System.out.println(Math.floor(-10.1)); //-11.0 System.out.println(Math.floor(10.7)); //10.0 System.out.println(Math.floor(-0.7)); //-1.0 System.out.println(Math.floor(0.0)); //0.0 System.out.println(Math.floor(-0.0)); //-0.0 System.out.println(Math.floor(-1.7)); //-2.0 //round四舍五入,float返回int,double返回long System.out.println(Math.round(10.5)); //11 System.out.println(Math.round(-10.5)); //-10 //Math生成随机数 System.out.println(Math.random()); //Random类生成随机数 Random rand=new Random(); System.out.println(rand.nextBoolean()); System.out.println(rand.nextDouble()); System.out.println(rand.nextInt()); System.out.println(rand.nextInt(10)); //Random使用当前时间作为Random的种子 Random rand2 = new Random(System.currentTimeMillis()); System.out.println(rand2.nextBoolean()); System.out.println(rand2.nextDouble()); System.out.println(rand2.nextInt()); System.out.println(rand2.nextInt(10)); System.out.println(rand2.nextInt(5)); //ThreadLocalRandom ThreadLocalRandom rand3 = ThreadLocalRandom.current(); System.out.println(rand3.nextInt(5,10)); //BigDecimal System.out.println(0.8 - 0.7); //0.10000000000000009 BigDecimal a1=new BigDecimal(0.1); BigDecimal b1=new BigDecimal(0.9); BigDecimal c1=a1.add(b1); System.out.println("a1.add(b1)="+c1); //a1.add(b1)=1.0000000000000000277555756156289135105907917022705078125 BigDecimal a2=new BigDecimal("0.1"); BigDecimal b2=new BigDecimal("0.9"); BigDecimal c2=a2.add(b2); System.out.println("a2="+a2); //a2=0.1 System.out.println("a2.add(b2)="+c2); //a2.add(b2)=1.0 } } |
from:https://www.cnblogs.com/testerlina/p/11349456.html
View Details能编译通过说明SDK导入正确,但是为啥我们点击每一个Java文件会出现好多红色的下划线 ,并提示idea cant resolve symbol 原因就是可能没有清除原来的历史缓存,导致一些错误,解决方法是 File-Invalidate Caches 然后重启IDEA,OK~困扰多年的问题解决!
View Details如题,其实这已经是以前遇到过的一个问题了。在.Net中使用Mysql的组件MySql.Data(Nuget.org的链接在这里http://www.nuget.org/packages/MySql.Data/)时需要在web.config的连接字符串中配置一些额外的属性,以最大程度地契合MS SERVER的数据类型,下面我以自己在实现工作遇到的问题为例子,来说明在连接字符串中配置的作用:Web.config连接Mysql字符串:
|
1 |
<add key="ConnstringMySql" value="server=xxx.xxx.xxx.xxx;database=YourDatabase;uid=xxx;pwd=xxx;pooling=false;charset=utf8;Treat Tiny As Boolean=false;Convert Zero Datetime=False" /> |
1.pooling:这个键的值设置为true,当值为True时,任何一个新创建的连接都将添加到连接池中当程序被关闭时,在下次试图开启一个相同的连接时,这个连接将从连接池中取出,如果连接字符串相同,则被认为是同一个连接。如果连接字符串不相同,则认为是不同的连接。 2.charset:这个一看应该明白,设置字符编码 3.Treat Tiny As Boolean:如果设置为True,则Mysql中的tinyint类型会被转换为MS Server中的bit类型,但有时候我们是不想要这来的转换的,所以这个可以根据自己的需要来配置 4.Convert Zero Datetime:今天就遇到了这个问题,当没有设置此属性时,如果Mysql数据库中的datetime列为null的时候,.net在转换时会抛出如下异常:Unable to convert MySQL date/time value to System.DateTime at MySql.Data.Types.MySqlDateTime.GetDateTime()这是因为.net的默认最小日期和Mysql的不匹配,导致转换出错,解决办法就是以上连接串中的(设置Convert Zero Datetime=True) 这是个人在实际操作中遇到的一些关于.NET 连接Mysql的常用设置,分享给大家,希望可以对你有一些帮助。如果你有更好的解决方案,欢迎拍砖,指正。
View Details