git patch 文件冲突时的解决办法

生成patch 1、生成当前分支的patch 生成当前分支指定节点之后的所有patch 生成的patch,会根据节点顺序自动编号,一个commit生成一个patch文件 git format-patch 404777e8586393d5eb6581485fc1bb2bf2e8eb2a //这里长短commit id都可以 2、生成两个节点之间的patch git format-patch 节点开始..节点结束 //这里长短commit id都可以 //例如 git format-patch aed12..ecf3a 更多详细 https://blog.csdn.net/sunnylgz/article/details/7661920 使用patch 生成patch相对容易,使用时却有些麻烦,尤其是有冲突的时候。 对于有冲突的patch,用搜索引擎搜索出的结果大都是 git apply --reject patch文件 //对于冲突,会生成.rej文件,然后手动解决所有冲突 这种办法在有冲突时,并不好用(因为根据.rej文件手动解决冲突比较麻烦) 我尝试的一个简单方法是 git am --3way patch文件 //解决冲突后 git am --continue --3way,会尝试合并冲突到目标文件,而不是另生成.rej文件,这样的好处是可以使用成熟的冲突解决工具

July 6, 2020 · 1 min · holdsky

【转】ssh访问控制,多次失败登录即封掉IP,防止暴力破解

读取/var/log/secure,查找关键字 Failed,例如: Sep 17 09:08:09 localhost sshd[29087]: Failed password for root from 13.7.3.6 port 44367 ssh2 Sep 17 09:08:20 localhost sshd[29087]: Failed password for root from 13.7.3.6 port 44367 ssh2 Sep 17 09:10:02 localhost sshd[29223]: Failed password for root from 13.7.3.6 port 56482 ssh2 Sep 17 09:10:14 localhost sshd[29223]: Failed password for root from 13.7.3.6 port 56482 ssh2 从这些行中提取IP地址,如果次数达到10次(脚本中判断次数字符长度是否大于1)则将该IP写到 /etc/hosts.deny 中。 步骤: 1、先把始终允许的IP填入 /etc/hosts.allow ,这很重要!比如: sshd:19.16.18.1:allow sshd:19.16.18.2:allow 2、脚本 /usr/local/bin/secure_ssh.sh #! /bin/bash cat /var/log/secure|awk '/Failed/{print $(NF-3)}'|sort|uniq -c|awk '{print $2"="$1;}' > /usr/local/bin/black.list for i in <code>cat /usr/local/bin/black.list</code> do IP=<code>echo $i |awk -F= '{print $1}'</code> NUM=<code>echo $i|awk -F= '{print $2}'</code> if [ ${#NUM} -gt 1 ]; then grep $IP /etc/hosts.deny > /dev/null if [ $? -gt 0 ];then echo "sshd:$IP:deny" >> /etc/hosts.deny fi fi done 3、将secure_ssh.sh脚本放入cron计划任务,每1分钟执行一次。 ...

June 27, 2020 · 1 min · holdsky

Ubuntu18上从源码部署禅道项目管理系统

安装环境: Ubuntu MySql Php Nginx 如果没有安装mysql、PHP、Nginx(或Apache)还是直接使用官方提供的一键安装包吧https://www.zentao.net/book/zentaopmshelp/90.html 相比一键安装包,源码安装也挺简单的。 下载开源版源码: https://www.zentao.net/download/zentaopms12.3.2-80227.html 然后解压缩到服务器上的某个目录,假设目录为 ~/zentaopms 配置nginx,新建一个配置文件 /etc/nginx/sites-available/zentaopms.conf,内容如下 server { server_tokens off; server_name zentaopms.你的域名; listen 80; listen [::]:80; root ~/zentaopms/www; //这里的目录参考禅道源码解压目录 index index.php index.html index.htm; client_max_body_size 5M; location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { include snippets/fastcgi-php.conf; #unix socket 路径参见 /etc/php/7.3/fpm/pool.d/www.conf fastcgi_pass unix:/run/php/php7.3-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } 创建软链接,重启nginx ...

June 25, 2020 · 1 min · holdsky

iOS 给自定义视图添加高亮背景色

UITableView的默认Cell,是有点击选中的高亮背景色的,UIButton也可以通过设置不同状态的背景图片来实现高亮,那么如何给自定义视图添加高亮呢? 一个技术上可行的方法就是重写UIView的各种touches方法,自己记录点击选中,点击取消等状态,不过很繁琐。 还有一个是重写UIControl的下面四个方法,下面四个方法将点击选中,取消等状态处理简化了 //是否可以开始追踪事件 - (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(nullable UIEvent *)event; //是否持续追踪事件 - (BOOL)continueTrackingWithTouch:(UITouch *)touch withEvent:(nullable UIEvent *)event; //事件追踪结束 - (void)endTrackingWithTouch:(nullable UITouch *)touch withEvent:(nullable UIEvent *)event; // touch is sometimes nil if cancelTracking calls through to this. //事件追踪取消 - (void)cancelTrackingWithEvent:(nullable UIEvent *)event; // event may be nil if cancelled for non-event reasons, e.g. 具体示例 - (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(nullable UIEvent *)event { BOOL b = [super beginTrackingWithTouch:touch withEvent:event]; if (b) { 如果开始追踪,那么就高亮显示 [super setBackgroundColor:高亮色]; } return b; } - (void)endTrackingWithTouch:(nullable UITouch *)touch withEvent:(nullable UIEvent *)event { [super endTrackingWithTouch:touch withEvent:event]; //结束追踪 恢复原始背景色 [super setBackgroundColor:原始背景色]; } - (void)cancelTrackingWithEvent:(nullable UIEvent *)event { [super cancelTrackingWithEvent:event]; //取消追踪 恢复原始背景色 [super setBackgroundColor:原始背景色]; }

June 16, 2020 · 1 min · holdsky

UITableView attempt to delete section 1, but there are only 1 sections before the update

虽然提示是删除一个section,但不一定显式调用了deleteSection接口,还有可能是reloadSection,一个复现的场景就是reload了一个不存在的section。 例如 //以下为示意代码 tableview = [UITableView alloc] initWithFrame:CGRectMake(0,0,100,400) style:UITableViewStylePlain]; //添加一个section [tableview.dataSource addObject:section]; //此时,只有一个section,我们reload第二个section [tableview reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationNone]; //崩溃 详细堆栈 Assertion failure in -[UITableView _endCellAnimationsWithContext:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore/UIKit-3901.4.5/UITableView.m:2040 2020-05-14 15:17:07.597057+0800 AppTest[33419:3092839] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to delete section 1, but there are only 1 sections before the update' *** First throw call stack: (0x187a92a48 0x1877b9fa4 0x187994e88 0x187dca654 0x18bcc5f44 0x18bcdf9d8 0x18bce0044 0x1021422a0 0x1021420bc 0x1019194e0 0x1019193b0 0x10223d8b4 0x1075817fc 0x107582bd8 0x107590c34 0x187a105e4 0x187a0b5d8 0x187a0aadc 0x1919ab328 0x18bb1863c 0x100e9cfcc 0x187894360)

May 15, 2020 · 1 min · holdsky

Java反编译工具MacOS版--JD-GUI-OSX-1.6.6

官方地址下载速度有点慢,这里备个份。 jd-gui-osx-1.6.6

May 5, 2020 · 1 min · holdsky

iOS崩溃日志定位

日志格式 先说日志格式,常见的日志格式: 日志头 + 线程堆栈 + 映像加载信息 日志头(截取我们需要的部分) # 软硬件信息 Hardware Model: iPhone9,1 Code Type: ARM-64 (Native) OS Version: iPhone OS 13.3.1 (17D50) # 崩溃原因 Exception Type: EXC_GUARD Exception Subtype: GUARD_TYPE_FD Exception Message: CLOSE on file descriptor 66 (guarded with 0x534b434869d9c32f) Exception Note: SIMULATED (this is NOT a crash) # 崩溃线程 Triggered by Thread: 44 崩溃线程信息(截取我们需要的部分) Thread 44 name: MHD-worker Thread 44 Crashed: # 调用堆栈 # 栈号 模块名 方法地址 加载地址 偏移量 0 libsystem_kernel.dylib 0x00000001aa54ae8c close + 8 1 iQiYiPhoneVideo 0x0000000100cceda0 0x1005e0000 + 7269792 2 iQiYiPhoneVideo 0x0000000100ccbde4 0x1005e0000 + 7257572 3 iQiYiPhoneVideo 0x0000000100ccc83c 0x1005e0000 + 7260220 4 iQiYiPhoneVideo 0x0000000100ccdc00 0x1005e0000 + 7265280 5 libsystem_pthread.dylib 0x00000001aa46dd8c _pthread_start + 156 6 libsystem_pthread.dylib 0x00000001aa47176c thread_start + 8 Thread 44 crashed with ARM Thread State (64-bit): x0: 0x0000000000000001 x1: 0x0000000000000000 x2: 0x0000000171516bdc x3: 0x0000000171516e00 x4: 0x0000000000000000 x5: 0x0000000000000400 x6: 0x0000000000000000 x7: 0x0000000000000000 x8: 0x0000000000000005 x9: 0x0000000000000006 x10: 0x0000000000000001 x11: 0x0000000000000000 x12: 0x0000000000000001 x13: 0x0000000000000002 x14: 0x0000000000000000 x15: 0x0000000000006dc2 x16: 0x0000000000000006 x17: 0x0000000055800000 x18: 0x0000000000000000 x19: 0x0000000109d900e0 x20: 0x0000000000000042 x21: 0x0000000171516e80 x22: 0x0000000171516f00 x23: 0x0000000000000000 x24: 0x0000000000000000 x25: 0x0000000000000000 x26: 0x0000000000000000 x27: 0x0000000000000000 x28: 0x0000000000000000 fp: 0x0000000171516c20 lr: 0x0000000100cceda0 sp: 0x0000000171516c00 pc: 0x00000001aa54ae8c cpsr: 0x60000000 esr: 0x00000000 Address size fault 二进制映像加载信息(截取我们需要的部分) ...

April 15, 2020 · 2 min · holdsky

TS2769: Property 'xxx' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly<{}> & Readonly<{ children?: ReactNode; }>

用TypeScript开发React项目,在父子组件间传值时发生错误提示 class Page extends React.Component { render() { return <div> <NavigationBar title="标题"/> </div> } } class NavigationBar extends React.Component { render() { return <div> "返回标题" </div> } } 错误提示 No overload matches this call. Overload 1 of 2, '(props: Readonly<{}>): NavigationBar', gave the following error. Type '{ title: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<NavigationBar> & Readonly<{}> & Readonly<{ children?: ReactNode; }>'. Property 'title' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<NavigationBar> & Readonly<{}> & Readonly<{ children?: ReactNode; }>'. Overload 2 of 2, '(props: {}, context?: any): NavigationBar', gave the following error. Type '{ title: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<NavigationBar> & Readonly<{}> & Readonly<{ children?: ReactNode; }>'. Property 'title' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<NavigationBar> & Readonly<{}> & Readonly<{ children?: ReactNode; }>'. TS2769 原因是Typescript是强类型语言,如果要给组件传值,需要在接受值组的地方声明值类型,就本例而言,需要明确定义 props,本例为 NavigationBarProps ...

April 5, 2020 · 1 min · holdsky

基于npm项目初始化TypeScript项目

# 初始化npm项目 mkdir projectName cd projectName npm init # 初始化TypeScript项目 tsc --init #安装 node的ts符号生命(用于ts的静态编译检查、语法提示) npm i @types/node

April 5, 2020 · 1 min · holdsky

JavaScript如何实现sleep?

JavaScript如何实现sleep? 一般的, sleep 是将当前上下文所在的线程从执行状态转化为挂起状态,直到指定的一段实时时间过去后,再从挂起状态转化为执行状态,在sleep执行结束前,线程不会执行其他任务。 该函数使当前进程从执行状态转化为挂起状态,直到参数seconds所指定的一段实时时间过去后,或者是一个唤醒信号跟踪功能或终止进程功能的信号到来。该挂起时间由于系统的其他调度活动可能会比要求的时间长。 在ES标准中,JavaScript代码的执行环境是一个单线程环境,所以 JavaScript如何实现sleep 的本质是如何将一个线程阻塞一段时间然后继续工作。 这里的重点是 阻塞。所以,使用 promise、 generator 之类的实现是不满足这个需求的,任务调度机制本质不同,因为 promise、 generator 的本质是延迟,而不是阻塞。 在不扩展JavaScript语言底层能力的情况下,实现阻塞方式: 计算阻塞 IO阻塞 计算阻塞 也就是消耗CPU资源进行阻塞,通常是一段循环计算,在循环期间,JavaScript代码执行线程不会执行其他任务,从而达到模拟 sleep 的效果 <script type="text/javascript"> // bad implementation function sleep(milliSeconds){ var startTime = new Date().getTime(); // get the current time while (new Date().getTime() < startTime + milliSeconds); // hog cpu } } </script> 这种方式在任何标准的ES环境中都可以实现,阻塞和计时在同一个线程中完成。 IO阻塞 也就是消耗IO资源进行阻塞,通常是消耗网络IO,如 XMLHttpRequest 的同步通信。 <script type="text/javascript"> function sleep(milliSeconds) { var resource; var response; if(typeof ActiveXObject == 'undefined'){ resource = new XMLHttpRequest(); } else{ resource = new ActiveXObject("Microsoft.XMLHTTP"); } try{ resource.open('GET', 'sleep?milliSeconds=' + milliSeconds, false); resource.send(null); response = resource.responseText; // JavaScript waits for response } catch(e){ alert(e); } } </script> 这种方式是基于BS模型,Server负责计时,在指定的时间后返回响应,Browser负责阻塞。 ...

March 30, 2020 · 1 min · holdsky