0%

格式化代码 command + option + L
优化导入 ^ + option + O
格式化代码选项 command + option + shift + L

返回 command + [
前进 command + ]

最近文件 command + E
最近位置 command + shift + E
转到行列 command + L
转到上/下个函数 ^ + shift + up/down

复制一行 command + D, 相当于 command + C && command + V
删除一行 command + backspace
新起一行 shift + enter
上/下移一行 option + shift + up/down
上/下移部分 commang + shift + up/down

注释/取消 command + /
块注释/取消 option + command + /

查找 command + F
替换 command + R
所有文件中查找 command + shift + F
所有文件中替换 command + shift + R
查找任意 shift + shift

在匹配括号间移动 ^ + M
生成 command + N

重构 ^ + T
重命名 shift + F6

安装TeX Live

macOS/Linux

1
$ brew install texlive

Linux下更推荐用自带包管理安装.

Windows

1
PS > choco install texlive

配置TeX Live

查看TeX Live包管理版本

1
$ tlmgr --version

测试安装包

1
$ tlmgr install latexindent

如果报错

1
tlmgr: action not allowed in system mode: install

则需要在命令上加上--usermode参数:

1
$ tlmgr install latexindent --usermode

如果报错

1
2
TLPDB: not a directory, not loading: /Users/xxx/texmf
cannot setup TLPDB in /Users/xxx/texmf at /usr/local/bin/tlmgr line 6887.

则先执行

1
$ tlmgr init-usertree

再执行安装命令.

随后可以安装一些常用包, 例如beamer:

1
$ tlmgr install beamer

配置VSCode

安装LaTeX Workshop扩展:
https://marketplace.visualstudio.com/items?itemName=James-Yu.latex-workshop

打开扩展设置, 搜索 @ext:James-Yu.latex-workshop recipes

定位到 Latex-workshop › Latex: Recipes

点击 Edit in settings.json

将xelatex移动至第一位

1
2
3
4
5
6
7
8
9
"latex-workshop.latex.recipes": [
{
"name": "latexmk (xelatex)",
"tools": [
"xelatexmk"
]
},
...
]

每次保存tex文件时会自动编译, 此行为可以通过配置

1
"latex-workshop.latex.autoBuild.run": "onFileChange"

来更改, 可选值为

  • onFileChange 监测到文件改动时
  • onSave 文件保存时
  • never 永不

遇到编译错误时, 如果原因为缺少包, 可以通过包管理tlmgr安装.

@Nullable, @NonNull

用于修饰变量/参数/返回值. @Nullbale表示可空, @NonNull表示非空.

以下行为会生成警告:

  • 将null/可空值赋值给非空变量/参数/字段

  • 未进行null检查而直接调用可空值的方法/字段

此外, null注解也作用于Kotlin于Java交互:

1
2
@NonNull
String foo(@Nullable String a, @NonNull String b) {}

对应Kotlin函数签名:

1
fun foo(a: String?, b: String): String
阅读全文 »

Modem

调试解调器, 用于信号转换

Router

路由器, 根据IP地址在网络间传输/转发数据报

Switch

交换机, 根据MAC地址将数据报转发给目标接口

Hub

集线器, 将每个数据报广播到所有接口

Bridge

网桥, 可以为Hub局域网划分网段

AP

接入点, 无线交换机

Gateway

网关, 用于网络层以上网络互联

Hello, 异步函数

1
2
3
4
func hello() async -> String {
try? await Task.sleep(nanoseconds: 1000_000_000)
return "hello"
}

Kotlin:

1
2
3
4
suspend fun hello(): String {
delay(1.seconds)
return "hello"
}
阅读全文 »

安装

下载镜像

$ wget https://mirrors.tuna.tsinghua.edu.cn/archlinux/iso/latest/archlinux-x86_64.iso

wget可以替换成其他工具, 比如aria2c

mirrors list: https://archlinux.org/download/

制作启动U盘

# dd bs=4M if=archlinux-x86_64.iso of=/dev/sdx status=progress && sync

也可以使用GUI工具, 比如etcher, rufus(Windows)

阅读全文 »

g_signal_connect

Swift无法调用C宏, 需要使用g_signal_connect_data函数

1
2
3
4
let slot: @convention(c) (UnsafeMutableRawPointer?) -> Void = { data in
...
}
g_signal_connect_data(ptr, "signal", unsafeBitCast(slot, to: GCallback?.self), data, nil, G_CONNECT_AFTER)

slot必须标记为@convention(c), 否则unsafeBitCast将产生fatalError

g_object_get_property

1
2
3
4
5
6
7
func gproperty<T, R>(of ptr: UnsafeMutablePointer<T>, name: String, transform: (UnsafeMutablePointer<GValue>) -> R) -> R {
ptr.withMemoryRebound(to: GObject.self, capacity: 1) {
var value = GValue()
g_object_get_property($0, name, &value)
return transform(&value)
}
}

再使用g_value_get族函数从GValue中获取值

1
let property = gproperty(of: ptr, name: "property") { g_value_get_variant($0) }

待续..

HTTPS抓包时, 如果应用不信任用户证书, 需要把证书安装为系统证书.

如果证书为二进制格式(cer, der), 需要先转换为文本格式

$ openssl x509 -inform der -in cert.cer -outform pem -out cert.pem

获取hash, 存为$CERT_HASH

$ CERT_HASH=`openssl x509 -inform pem -in cert.pem -subject_hash_old | head -1`

制作证书文件

$ cp cert.pem ${CERT_HASH}.0

$ openssl x509 -inform pem -in cert.pem -text -noout >> ${CERT_HASH}.0

阅读全文 »

UID

Linux会为每个用户分配一个uid, 可以用id命令查看:

1
2
$ id
uid=501(sea) gid=20(staff) groups=20(staff)...

root用户uid=0

而在Android系统中, 默认情况下,Android会为新安装应用分配uid, 范围[10000, 19999], 称之为appid

通过在manifest文件中指定android:sharedUserId=""可以更改此行为, 使用相同sharedUserId的应用需要使用相同的签名, 使用相同sharedUserId的应用之间可以直接访问数据, 甚至在同一进程中运行.

支持多用户后, Android的uid由两部分组成:

uid = userid * 100_000 + appid

阅读全文 »