0%

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
➜ sudo apt update 
命中:1 https://pro-driver-packages.uniontech.com eagle InRelease
获取:2 http://mirrors.tuna.tsinghua.edu.cn/ubuntu hirsute InRelease [269 kB]
命中:3 http://packages.microsoft.com/repos/code stable InRelease
命中:4 https://home-packages.chinauos.com/home plum InRelease
命中:5 https://home-packages.chinauos.com/home plum/beta InRelease
命中:6 https://home-packages.chinauos.com/printer eagle InRelease
错误:2 http://mirrors.tuna.tsinghua.edu.cn/ubuntu hirsute InRelease
由于没有公钥,无法验证下列签名: NO_PUBKEY 871920D1991BC93C
命中:7 https://home-store-img.uniontech.com/appstore eagle InRelease
正在读取软件包列表... 完成
W: GPG 错误:http://mirrors.tuna.tsinghua.edu.cn/ubuntu hirsute InRelease: 由于没有公钥,无法验证下列签名: NO_PUBKEY 871920D1991BC93C
E: 仓库 “http://mirrors.tuna.tsinghua.edu.cn/ubuntu hirsute InRelease” 没有数字签名。
N: 无法安全地用该源进行更新,所以默认禁用该源。
N: 参见 apt-secure(8) 手册以了解仓库创建和用户配置方面的细节。

执行:

1
➜ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 871920D1991BC93C

Item 26:Postpone variable definitions as long as possible.

推迟变量的定义有两个好处:

  • 改善程序效率,减少无用的构造和析构。
  • 增加程序流程清晰度。

这条规则看似简单,但存在流程控制语句的时候容易疏忽。如:

1
2
3
4
5
6
7
8
9
string encryptPassword(const string& password){
string encrypted;
if (password.length() < MinimumPasswordLength) {
throw logic_error("Password is too short");
}
encrypted = password;
encrypt(encrypted);
return encrypted;
}
阅读全文 »

Item 25: Consider support for a non-throwing swap.

swap 函数能置换两对象值,功能很重要!

std 的缺省基本实现如下:

1
2
3
4
5
6
7
8
namespace std {
template <typename T>
void swap(T& a, T& b) {
T temp(a);
a = b;
b = temp;
}
}
阅读全文 »

Item 20: Prefer pass-by-reference-to-const to pass-by-value.

缺省情况下C++ 用传值得方式(一个继承自C的方式)传递对象至(或来自)函数。除非你另外指定,否则函数参数都是以实际实参的复件(副本)为初值,而调用端所获得的亦是函数返回值的一个复件。这些复件(副本)系由对象的copy构造函数产出。

尽量以传常量引用替换传值前者通常比较高效,并可避免切割问题 (slicing problem),但是内置类型和 STL 迭代器,还是传值更加合适。

阅读全文 »

什么是 MIME 类型?

MIME(多用途 Internet 邮件扩展)的类型来识别文件格式。 MIME 类型构成了 Internet 上对文件类型进行分类的标准方法。

  • MIME Type是用于描述文件的类型的一种表述方法,其将文件划分为多种类型,方便对其进行统一的管理。
  • MIME Type指定了文件的类型名称、描述、图标信息,同时通过与.desktop应用程序描述文件整合,指定了文件的打开方式。
阅读全文 »