macos 配置 git ssh访问方式

生成 ssh key $ ssh-keygen -t rsa -C "git服务端留存的邮箱地址" Generating public/private rsa key pair. Enter file in which to save the key (~/.ssh/id_rsa): "这里输入ssh key保存路径,不建议使用默认地址" Enter passphrase (empty for no passphrase): "这里输入密码,建议输入空(方便后续配置)" Enter same passphrase again: "再输入一遍密码,建议输入空(方便后续配置)" 应生成两个文件,公钥和私钥,文件名形式为 xxx(私钥), xxx_pub 或者 xxx.pub(公钥)。记住ssh key生成的文件路径。 默认情况下,ssh会使用 ~/.ssh/id_rsa 这个私钥,但无法处理访问多个ssh远端的场景。 配置本地ssh访问git使用的私钥 打开 ~/.ssh/config 文件,如果没有则创建一个文本文件,添加如下内容 # 请保证 Host 和 HostName 的值相同 (macos11 实测不相同时,git ssh 访问失败) # 远端ssh主机别名 Host bitbucket.cmbc.com.cn # 远端ssh主机名(域名或者ip都可以) HostName bitbucket.cmbc.com.cn # 鉴权文件 ,这填写ssh私钥文件路径 IdentityFile "ssh 私钥文件路径" # 使用公钥算法进行鉴权 PreferredAuthentications publickey 关于 ssh config 更多细节参考 https://linux.die.net/man/5/ssh_config ...

November 27, 2020 · 1 min · holdsky

判断苹果app是否以转译模式运行(Rosetta translation)

苹果app的进程是否运行在转译模式(Rosetta translation),通过调用 sysctlbyname 函数,传入 sysctl.proc_translated 标识来判断 /// 返回 1 表示在Rosetta translation模式 ;返回 0 表示在Native Code模式;返回 -1,表示发生错误 int processIsTranslated() { int ret = 0; size_t size = sizeof(ret); if (sysctlbyname("sysctl.proc_translated", &ret, &size, NULL, 0) == -1) { if (errno == ENOENT) return 0; return -1; } return ret; } 参考地址https://developer.apple.com/documentation/apple_silicon/about_the_rosetta_translation_environment#3616845

November 20, 2020 · 1 min · holdsky

iOS shouldAutorotate , supportedInterfaceOrientations , viewWillTransitionToSize不调用问题

除非只支持单个屏幕方向,否侧shouldAutorotate,viewWillTransitionToSize等方法应被调用。 不被调用的原因,可能是配置文件错误(info.plist),也可能是被Appdelegate或父ViewController拦截了。 1、info.plist配置错误 IPad 上的相关旋转方法都不执行,可能是info中的Supported interface orientations (iPad)项与General->Deployment Info下的Device Orientation配置不一致导致的。 删除不一致项应可以解决问题。 2、被Appdelegate或父ViewController拦截 有点类似触摸事件传递,屏幕旋转也是一层一层的询问。 Appdelegate ---> UIWindow.rootViewController ----> rootViewController的子ViewController 父子ViewController的概念,可以参考 UIViewController.addChildViewController 相关方法。 具体来说 Appdelegate关于旋转的方法 - (UIInterfaceOrientationMask)supportedInterfaceOrientationsForWindow:(nullable UIWindow *)window; - (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(nullable UIWindow *)window; rootViewController关于旋转的方法 # rootViewController 是UINavigationController -(UIInterfaceOrientationMask)navigationControllerSupportedInterfaceOrientations:(UINavigationController *)navigationController; - (BOOL)shouldAutorotate; 子ViewController - (BOOL) shouldAutorotate; -(UIInterfaceOrientationMask)supportedInterfaceOrientations; - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration; - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation; - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator; 参考 https://www.jianshu.com/p/b1ebaad87a80 参考https://www.jianshu.com/p/7c1d214adcbd 参考https://www.jianshu.com/p/73be6d0e152f

November 5, 2020 · 1 min · holdsky

iOS 分享扩展(ShareExtension)指定可以分享的数据类型

可修改info.plist文件中的NSExtensionAttributes .NSExtensionActivationRule 值,例如 <key>NSExtensionAttributes</key> <dict> <key>NSExtensionActivationRule</key> <dict> <key>NSExtensionActivationSupportsImageWithMaxCount</key> <integer>10</integer> <key>NSExtensionActivationSupportsMovieWithMaxCount</key> <integer>1</integer> <key>NSExtensionActivationSupportsWebURLWithMaxCount</key> <integer>1</integer> </dict> </dict> 更多参见 https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html#//apple_ref/doc/uid/TP40014214-CH21-SW8

November 5, 2020 · 1 min · holdsky

adb 遍历Android应用包名并删除

adb命令 adb usb ==== 重启 adb的 usb连接 adb shell pm list packages ==== 列举所有应用包名 adb shell am monitor ==== 监控手机上的应用启动 adb shell pm uninstall -k --user 0 包名 ==== 删除包(屏蔽包)

November 5, 2020 · 1 min · holdsky

手动创建一个electron工程

1、创建工程文件夹 并进入 mkdir my-electron-app && cd my-electron-app 2、初始化npm npm init -y 3、安装electron npm i --save-dev electron 自动化脚本 #!/bin/bash # -*- coding:utf-8 -*- import os import sys import json if (len(sys.argv) < 2 ): print("缺少electron工程名字 ; python create-electron-app name") exit(0) CURRENT_PATH = sys.path[0] APP_NAME = sys.argv[1] APP_DIR = os.path.join(CURRENT_PATH,APP_NAME) if os.path.exists( APP_DIR ): print("目录" + APP_NAME + "已存在") exit(0) # 创建工程目录 os.system("cd {} && mkdir {}".format(CURRENT_PATH,APP_NAME)) # 初始化npm os.system("cd {} && npm init -y".format(APP_DIR)) #安装electron os.system("cd {} && npm i --save-dev electron".format(APP_DIR)) #创建主脚本 mainjs = """ const { app, BrowserWindow } = require('electron') function createWindow () { const win = new BrowserWindow({ width: 800, height: 600, webPreferences: { nodeIntegration: true } }) win.loadFile('main.html') win.webContents.openDevTools() } app.whenReady().then(createWindow) app.on('window-all-closed', () => { if (process.platform !== 'darwin') { app.quit() } }) app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) { createWindow() } }) """ fs = open(os.path.join(APP_DIR,"main.js"),"w") fs.write(mainjs) fs.close() #创建主html mainhtml = """ <OCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Hello World!</title> <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" /> </head> <body> <h1>Hello World!</h1> <p>世界你好</p> </body> </html> """ fs = open(os.path.join(APP_DIR,"main.html"),"w") fs.write(mainhtml) fs.close() # 添加快捷启动方式 fs = open(os.path.join(APP_DIR,"package.json"),"r") jsondata = fs.read() fs.close() jsonobj = json.loads(jsondata) jsonobj["scripts"]["start"] = "electron ." jsonobj["main"]= "main.js" jsondata = json.dumps(jsonobj,indent=4) fs = open(os.path.join(APP_DIR,"package.json"),"w") fs.write(jsondata) fs.close() # 启动 os.system("cd {} && npm start".format(APP_DIR)) 参考 https://www.electronjs.org/docs/tutorial/quick-start

October 28, 2020 · 1 min · holdsky

学习笔记:(转)CSS样式选择器优先级

CSS 7 种基础的选择器: ID 选择器, 如 #id{} 类选择器, 如 .class{} 属性选择器, 如 a[href=“segmentfault.com”]{} 伪类选择器, 如 :hover{} 伪元素选择器, 如 ::before{} 标签选择器, 如 span{} 通配选择器, 如 *{} CSS 优先规则3:优先级关系:内联样式 > ID 选择器 > 类选择器 = 属性选择器 = 伪类选择器 > 标签选择器 = 伪元素选择器 参考 https://www.runoob.com/w3cnote/css-style-priority.html

September 30, 2020 · 1 min · holdsky

UITablView Reload会是TextView失去焦点,可使用beginUpdates/endUpdates替代

如题 如果cell中有TextView或者TextField,tableview reload后会是TextView/TextField失去焦点。使用beginUpdates/endUpdates,则会保持焦点

September 14, 2020 · 1 min · holdsky

判断Unicode码是否落在了中文区间

static inline BOOL isChineseC(u_long ch) { /// https://www.qqxiuzi.cn/zh/hanzi-unicode-bianma.php return ( (/ 基本汉字/ ch >= 0x4E00 && ch <= 0x9FA5) || (/ 基本汉字补充/ ch >= 0x9FA6 && ch <= 0x9FEF) || (/ 扩展A/ ch >= 0x3400 && ch <= 0x4DB5) || (/ 扩展B/ ch >= 0x20000 && ch <= 0x2A6D6) || (/ 扩展C/ ch >= 0x2A700 && ch <= 0x2B734) || (/ 扩展D/ ch >= 0x2B740 && ch <= 0x2B81D) || (/ 扩展E/ ch >= 0x2B820 && ch <= 0x2CEA1) || (/ 扩展F/ ch >= 0x2CEB0 && ch <= 0x2EBE0) || (/ 扩展G/ ch >= 0x30000 && ch <= 0x3134A) || (/ 康熙部首/ ch >= 0x2F00 && ch <= 0x2FD5) || (/ 部首扩展/ ch >= 0x2E80 && ch <= 0x2EF3) || (/ 兼容汉/ ch >= 0xF900 && ch <= 0xFAD9) || (/ 兼容扩展/ ch >= 0x2F800 && ch <= 0x2FA1D) || (/ PUA(GBK)部件/ ch >= 0xE815 && ch <= 0xE86F) || (/ 部件扩展/ ch >= 0xE400 && ch <= 0xE5E8) || (/ PUA增补/ ch >= 0xE600 && ch <= 0xE6CF) || (/ 汉字笔画/ ch >= 0x31C0 && ch <= 0x31E3) || (/ 汉字结构/ ch >= 0x2FF0 && ch <= 0x2FFB) || (/ 汉语注音/ ch >= 0x3105 && ch <= 0x312F) || (/ 注音扩展/ ch >= 0x31A0 && ch <= 0x31BA) || (/ 〇/ ch == 0x3007) ); }

September 4, 2020 · 2 min · holdsky

UICollectionView (UICollectionViewFlowLayout)添加元素时保持屏幕定位不变

默认情况下,使用UICollectionViewFlowLayout布局的UICollectionView 的 添加元素,没多一行就会会有自动向上滚动。UITableView的效果也是类似的。 (相对于用户来说)为了保持屏幕定位不变,也就是用户操作的某个cell在屏幕上的位置不变,可以这样做: 获取一行的高度,设置UICollectionView的contentOffset,使向反方向滚动一行,然后立即添加元素 示意代码 //在performBatchUpdates中批量执行 [collectionView performBatchUpdates:^{ // 禁用动画效果 [UIView setAnimationsEnabled:NO]; //添加元素 [collectionView insertItemsAtIndexPaths:@[addIndp]]; if (新增一行) { // 计算一行高度 CGFloat oneLineHeight= 1000; CGFloat oneTop = 0; for (UICollectionViewCell * cell in _collectionView.visibleCells) { if (oneTop <= 0 ) { oneTop = cell.top; } else if (oneTop != cell.top) { CGFloat tmp = (cell.top - oneTop); tmp = ABS(tmp); if (tmp > 1 && oneLineHeight > tmp ) { oneLineHeight = tmp; } } } //向上滚动一行 CGPoint offset = collectionView.contentOffset; offset.y += oneLineHeight; collectionView.contentOffset = offset; } } completion:^(BOOL finished) { //开启动画效果 [UIView setAnimationsEnabled:YES]; }];

July 17, 2020 · 1 min · holdsky