如何在xcode中安装配置clang-format

clang-format是很好用的插件,所以我们也想在xcode中继续使用。

install

brew install clang-format

check version:

clang-format --version
clang-format version 9.0.0 (tags/google/stable/2019-05-14)

add automator service

创建automator action
automator
在左侧搜索“运行shell脚本”,并拖入右侧,在脚本本输入:

export PATH=/usr/local/bin:$PATH
clang-format

automator
将服务保存为clang-format(或者任意你喜欢的),后面还有用到这个名字。

setting clang-format

在当前用户的根目录 ~ 放置一个 .clang-format 文件。参考内容如下:

BasedOnStyle: LLVM
BreakBeforeBraces: Linux
Language: Cpp
ColumnLimit: 120
ReflowComments: false
SortIncludes: false

#括号风格
BreakBeforeBraces: Custom
BraceWrapping:
  AfterEnum: false
  AfterStruct: false
  SplitEmptyFunction: false

注意,这个只是参考,你需要按照你实际的风格进行设置。

add keyboard shortcuts

在系统设置页面找到“键盘”,选择“快捷键”的tab,在左侧选择 “app快捷键”,然后选择+号,创建用于xcode的快捷键,选择clang-format服务,然后选择一个你准备用户代码格式化的快捷键组合,比如 ctrl+i。
automator
在xcode中,选择我们的目标代码,然后ctrl+i,就触发clang-format格式化了。

done!

OCSP check failed for /xxx/cert1.pem (are we offline?)

现象

certbot renew时出现类似的错误:
OCSP check failed for /xxx/cert1.pem (are we offline?)

原因

经搜索原因:原因是 ocsp.int-x3.letsencrypt.org 的 cname 域名 a771.dscq.akamai.net 受到了干扰。
可以采用本地修改hosts的方案进行临时处理,在/etc/hosts中添加

23.32.3.72     ocsp.int-x3.letsencrypt.org

验证

# openssl ocsp -no_nonce -issuer /etc/letsencrypt/archive/xxx/chain1.pem -cert /etc/letsencrypt/archive/xxx/cert1.pem -url http://ocsp.int-x3.letsencrypt.org -CAfile /etc/letsencrypt/archive/xxx/chain1.pem -verify_other /etc/letsencrypt/archive/xxx/chain1.pem -trust_other -header Host ocsp.int-x3.letsencrypt.org
Response verify OK
/etc/letsencrypt/archive/www.itranscloud.com/cert1.pem: good
    This Update: May 14 10:00:00 2020 GMT
    Next Update: May 21 10:00:00 2020 GMT

添加后,在重试 certbot renew,ok,正常

ref:https://holmesian.org/letsencrypt-ocsp-fix

This branch has conflicts that must be resolved 解决示例

使用git日常免不了遇到conflicts,那么如何消除conflicts呢,以下的内容以一个具体的过程来讲解整个过程和原理。

以下我们手动创造一个conflicts:
git conflicts

Step 1: From your project repository, check out a new branch and test the changes.

git checkout -b apache-master master
git pull https://github.com/apache/incubator-apisix.git master

Step 2: Merge the changes and update on GitHub.

git checkout master
git merge --no-ff apache-master
git push origin master

以上的的例子, 我们从A合入到B:B <== A。
A: https://github.com/apache/incubator-apisix.git
B: xxxx/incubator-apisix.git

例子中有一个README.md的冲突,并且给出了解决的命令行参考。
我们将逐条命令来解释如何按照提示解决冲突。

  1. 假设我们已经在B的git 根目录下。
  2. git checkout -b apache-master master #建立B的 apache-master分支,并切换到apache-master
  3. git pull https://github.com/apache/incubator-apisix.git master # 将A最新的内容合入apache-master
  4. 因为有冲突,所以上条执行时,会提示冲突:
    From https://github.com/apache/incubator-apisix
    * branch            master     -> FETCH_HEAD
    Auto-merging README.md
    CONFLICT (content): Merge conflict in README.md
    Automatic merge failed; fix conflicts and then commit the result.
  5. 解决冲突[ ... resolve any conflicts ... ]:
    手动打开冲突文件,根据提示修改,删除冲突的内容,留下想要的结果内容。
  6. git add [files that were conflicted]
  7. git commit,将冲突修改提交敖本地仓库:
    $ git commit -m "resolve the conflict"
    [apache-master 6ad2d5e] resolve the conflict
  8. git checkout master # 将B切换为master
  9. git merge --no-ff apache-master #将B仓库的apache-master 合入 master
  10. git push origin master #将B仓库的最终的本地库推到云端master

最终解决了冲突,完成了对B master的更新。

希望以上就解释清楚,谢谢!

how to upgrade certbot from acmev1 to acmev2

original

certbot version:0.9.3
centos version:CentOS Linux release 7.0.1406 (Core)

upgrade the certbot version

#sudo yum update certbot

# certbot --version
certbot 1.3.0

upgrade the acme account

#certbot update_account
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): xxx@xxx.com
Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y
Starting new HTTPS connection (1): supporters.eff.org

IMPORTANT NOTES:
 - Your e-mail address was updated to xxx@xxx.com.

check upagrade result

ls /etc/letsencrypt/accounts
acme-staging.api.letsencrypt.org  acme-v01.api.letsencrypt.org  acme-v02.api.letsencrypt.org

you can see the acme-v02 information, it indicate that the upgrade is successful.

done, have fun!

iphone 屏幕尺寸相关

屏幕物理尺寸

4.0寸的iPhone5/5s
4.7寸的iPhone678
5.5寸的iPhone6P7P8P
5.8寸的iPhoneX/XS iPhone11Pro
6.1寸的iPhoneXr iPhone11
6.5寸的iPhone XS Max/iPhone 11 Pro Max

屏幕像素分辨率

ref:https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/adaptivity-and-layout/#device-screen-sizes-and-orientations

Device Portrait dimensions Landscape dimensions
12.9" iPad Pro 2048px × 2732px 2732px × 2048px
11" iPad Pro 1668px × 2388px 2388px × 1668px
10.5" iPad Pro 1668px × 2224px 2224px × 1668px
9.7" iPad 1536px × 2048px 2048px × 1536px
7.9" iPad mini 4 1536px × 2048px 2048px × 1536px
iPhone XS Max 1242px × 2688px 2688px × 1242px
iPhone XS 1125px × 2436px 2436px × 1125px
iPhone XR 828px × 1792px 1792px × 828px
iPhone X 1125px × 2436px 2436px × 1125px
iPhone 8 Plus 1242px × 2208px 2208px × 1242px
iPhone 8 750px × 1334px 1334px × 750px
iPhone 7 Plus 1242px × 2208px 2208px × 1242px
iPhone 7 750px × 1334px 1334px × 750px
iPhone 6s Plus 1242px × 2208px 2208px × 1242px
iPhone 6s 750px × 1334px 1334px × 750px
iPhone SE 640px × 1136px 1136px × 640px

图片分辨率

ref:https://developer.apple.com/design/human-interface-guidelines/ios/icons-and-images/image-size-and-resolution/

Device Scale Factor
12.9" iPad Pro @2x
11" iPad Pro @2x
10.5" iPad Pro @2x
9.7" iPad @2x
7.9" iPad mini 4 @2x
iPhone XS Max @3x
iPhone XS @3x
iPhone XR @2x
iPhone X @3x
iPhone 8 Plus @3x
iPhone 8 @2x
iPhone 7 Plus @3x
iPhone 7 @2x
iPhone 6s Plus @3x
iPhone 6s @2x
iPhone SE @2x

三者关系图

ref:https://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions

iad10.2

ref:https://medium.com/@hacknicity/how-ipad-apps-adapt-to-the-new-10-2-ipad-5d050b565fca
On 10th September 2019, Apple announced a 7th generation iPad with a 10.2" screen. There are now five different iPad resolutions (in landscape):
9.7": 1024×768 points (2048×1536 pixels)
10.2": 1080×810 points (2160×1620 pixels)
10.5": 1112×834 points (2224×1668 pixels)
11.0": 1194×834 points (2388×1668 pixels)
12.9": 1366×1024 points (2732×2048 pixels)

高德地图的bundle缺失错误

错误

无效的资源bundle,请检查AMap.bundle是否正确导入

这种错误一般是由于pod错误引起的。

解决

  1. 手动:在高德开发包MAMapKit.framework 中,通过项目文件管理器找到AMap.bundle,加入到项目中,一般放置于resource目录下,注意去掉file inspector 中的membership,否则可能报重复的错误问题
  2. pod 自动:重新执行pod update 或者 pod install