小纸片

LaTeX

可以使用 hyperref 给生成度pdf添加元数据。

1
2
3
4
5
6
7
\usepackage[
    pdfauthor={Bao Hengtao},
    pdftitle={Convex Optimization},
    pdfsubject={The Subject},
    pdfkeywords={Some Keywords},
    pdfproducer={Latex with hyperref, or other system},
    pdfcreator={pdflatex, or other tool}]{hyperref}

Docker

用 shell 连接正在运行的容器 : docker exec -it qbittorrent /bin/bash

查看运行日志: docker logs -f qbittorrent

正则表达式

RE
. Match any character.
^ Cause match only occur at the begining of the line.
$ Cause match only occur at the end of the line.
? Match the preceding element appear Zero or One Time.
* Match the preceding element occur Any Number of Time.
+ Match the preceding element One or More Times.
'{n,m}' Match an Element a Specific Number of Times(range from n to m)
[] Specify a set of characters to be matched.
[^bg] If the first character in a bracket expression is a caret (^), the remaining characters are taken to be a set of characters that must not be present at the given character position.
(bz | gz | zip) Allow a match to occur from among a set of expressions

Shell 命令

  • head: View the first n lines of data
  • tail: View the last n lines of data
  • sort: Orgnise the data into order
  • nl: Print line numbers before data
  • wc: Print a count of lines, words and characters.
  • cut: Cut the data into fields and only display the specified fields.
  • sed: Do a search and replace on the data
  • uniq: Remove duplicate lines
  • tac: Print the data in reverse order
  • > : Save output to a file
  • >> : Append output to a file
  • < : Read input from a file
  • 2> : Redirect error messages.
  • | : Send the output from one program as input to another program.

SSH 密钥

  1. 使用 ssh-keygen 生产一对密钥. 生成的密钥一般位于 ~/.ssh 文件夹下. 该文件应当有如下结构:

    1
    2
    3
    4
    5
    6
    
    .ssh
    ├── id_rsa_key1
    ├── id_rsa_key1.pub
    ├── id_rsa_key2
    ├── id_rsa_key2.pub
    └── known_hosts
    
  2. 将生成的密钥使用 ssh-add path/to/id_rsa 加入到ssh中。

  3. 将id_rsa_key.pub 的内容拷贝至服务器的文件~/.ssh/authorized_keys 中,

若 仍需输入密码, 则可通过查看日志rpi:/var/log/auth.log发现原因。 group最好不要将权限设置为writable,以免密钥失效。

字体

  • 等宽字体: Monaco

  • Terminal: Hack Nerd Font Mono

  • 中文字体: Noto Serif SC

{% tabs Font %}

 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
# Find fonts on Google Fonts (https://fonts.google.com)
font:
  enable: true
  host: https://fonts.googleapis.com

  # Font options:
  # `size: x.x`. Use `em` as unit. Default: 1 (16px)

  global:
    external: true
    family: Monda, Noto Serif SC
    size:

  title:
    external: true
    family: Amita,  Noto Serif SC
    size:

  headings:
    external: true
    family: Bree Serif, Noto Serif SC
    #family: Fredoka One, Noto Serif SC
    size:

  
  posts:
    external: true
    family: Montserrat, Noto Serif SC

  codes:
    external: true
    family: Monaco, PT Mono, Noto Serif SC
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
/* 修改字体 */
body {
  --monospace: 'Monaco'; /* for all code blocks, inline code, and source code mode */
  font-family: 'Monda', 'Noto Serif SC';  /* 'Noto Serif SC' 中文字体 */
}

#typora-source {
  font-family: 'Monaco';
  font-size: inherit;
  --monospace: 'Monaco'; /* for code blocks and inline code inside source code mode */
}

code,
.md-fences,
kbd,
tt {
  font-family: 'Monaco', 'Fira Mono', 'Cousine', 'Consolas', monospace;
  font-size: 1rem;
} 

{% endtabs %}

Amazon S3 图床

If you want to use Amazon S3 to share files publicly for your website or to allow downloads, etc, you might want a URL that's prettier than the default that will be something like this:photos.havecamerawilltravel.com.photoshelter.com.s3.amazonaws.com

I might, for instance, just want to be able to use the URL:images.havecamerawilltravel.com

To do that, you can set a CNAME that points to your Amazon S3 bucket.

  1. First make sure that your bucket name is the same as your CNAME. For instance, if I want the CNAME to be photos.havecamerawilltravel.comotoshelter.com, I'd set the bucket name to photos.havecamerawilltravel.comotoshelter.com.
  2. Then you need to log into wherever your DNS settings are being maintained (if you haven't changed it, it's probably your web host), and create a new CNAME record for that domain. For the example above, I'd then point that CNAME to: photos.havecamerawilltravel.com.photoshelter.com.s3.amazonaws.com

Troublesome

Mac充电提示音

充电提示音还是挺烦的,尤其是在图书馆安静的环境下,用如下命令可以对提示音进行关闭

1
2
defaults write com.apple.PowerChime ChimeOnNoHardware -bool true
killall PowerChime 

Git文件名乱码问题

1
git config --global core.quotepath false 

Rsync 乱码问题

macOS 自带的 rsync 版本为2.6.9, 中文会出现乱码. 可用 brew 安装最新版解决.

Brew rebase-merge error

The following problem can be solved with brew update-reset

1
2
3
4
5
6
7
8
9
Updating Homebrew...
fatal: It seems that there is already a rebase-merge directory, and
I wonder if you are in the middle of another rebase.  If that is the
case, please try
 git rebase (--continue | --abort | --skip)
If that is not the case, please
 rm -fr ".git/rebase-merge"
and run me again.  I am stopping in case you still have something
valuable there.

Emacs shell 乱码

[Help] terminal zsh control characters in prompt : emacs

rm ~/.iterm2_shell_integration.zsh

字体问题

Monaco 字符扩充:https://github.com/Karmenzind/monaco-nerd-fonts

Monaco 粗体: https://github.com/vjpr/monaco-bold

iTerms 2 全屏下顶部有白条在闪烁

White line appears when in full-screen (#9199) · Issues · George Nachman / iterm2 · GitLab

Apple has acknowledged the bug, so I guess it's hard to fix.

There is another workaround. Turn on Prefs > Appearance > Tabs > Flash tab bar when switching tabs in full screenand make sure the menu item View > Show Tabs in Full Screen is not checked.

This prevents the tabbar from becoming a titlebar accessory, which is the root cause of the bug.

Parallels 不能联网怎么办?

通过终端执行命令运行

  1. 打开终端执行:sudo -b -S /Applications/Parallels\ Desktop.app/Contents/MacOS/prl_client_app
  2. 输入电脑密码,回车即可。

需要注意的是,每次启动 PD 都需要打开终端执行以上命令才可以!

如果嫌麻烦,那你可以将「相关文件 -> PD 启动」拖拽到桌面上,然后在「PD 启动」上右键 -> 打开方式 -> 文本编辑,将里面的「你的密码」改成你的管理员密码,然后保存,用的时候双击「PD 启动」即可(如果打不开请右键,打开方式,终端)。

Mosh 无法连接

添加--bind-server=any选项

Nothing received from server on UDP port 60001 · Issue #1074 · mobile-shell/mosh

1
 mosh [email protected]  --bind-server=any 
updatedupdated2021-03-052021-03-05