解决git push报错问题

起因

本地仓库推送远程时经常出现错误:fatal: unable to access 'xxxxxxx': OpenSSL SSL_connect: Connection was reset in connection to github.com:443。根据目前查到的资料,应该是挂了Clash的问题。虽然每次检查端口号配置都没有发现问题,但只要重新设置一下问题就暂时消失了。
这次我勤快一点把配置记录在自己的文章里,方便之后查阅。

FIX

1
2
3
4
5
6
7
8
// 查看配置
git config --global http.proxy
git config --global https.proxy
git config --global -l // list all

// 修改配置(敲这两行就行了~)
git config --global http.proxy 127.0.0.1:7890
git config --global https.proxy 127.0.0.1:7890

C++ STL 基本用法总结

Vector

#include <vector>

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
vector<int> a;

// 末尾添加
for (int i=0; i<10; i++) {
a.push_back(i);
}

// 删除尾元素
a.pop_back();

// 访问首元素
cout << a.front();
cout << a[0];

// 访问某下标元素
cout << a.at(index);
cout << a[index];

// 访问尾元素
cout << a.back();
cout << a[a.size()-1];

// iterator遍历
vector<int>::iterator it;
for (it=a.begin(); it!=a.end(); it++) {
cout << *it << endl;
}

// size()遍历
int size = a.size();
for (int i=0; i<size; i++) {
cout << a[i] << endl;
}

// erase() & iterator 删除某个或连续多个元素
vector<int>::iterator it, it2;

it = a.begin() + 1;
it2 = a.begin() + 3;
a.erase(it); // 删除第二个元素
a.erase(it, it2); // 删除第二和第三个元素(左闭右开)

// 清空vector
a.clear();

// 判断是否为空
a.empty();

// insert() & iterator 指定位置插入
it = a.begin();
a.insert(it, -1); // 插入后it仍指向首元素
a.insert(it, 2, -2); // 插入重复元素(两个-2)

// 排序
#include <algorithm>
sort(a.begin(), a.end());

// 交换两个vector
a.swap(b);

Stack

#include <stack>
默认的容器类型是deque(double ended queue 双端队列),让双端队列展示栈的性质。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
stack<int> s;

// 入栈
s.push(1);

// 出栈
s.pop(); // 不返回栈顶元素

// 取栈顶元素
s.top();

// 判断栈是否为空
s.empty();

// 栈中元素个数
s.size();

Queue

#include <queue>
默认的容器类型是deque,让双端队列展示队列的性质。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
queue<int> q;

// 入队
q.push(1);

// 出队
q.pop(); // 不返回队首元素

// 访问队首/队尾元素
q.front();
q.back();

// 判断队列是否为空
q.empty();

// 队中元素个数
q.size();

Set

#include <set>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
set<int> s;

// 插入
s.insert(20);

// 获取大小
s.size();

// 遍历
set<int>::iterator it = s.begin();
for(it; it != s.end(); it++) {
cout << *it << endl;
}

// 删除指定元素
s.erase(20);

// 清空
s.clear();

// 查找元素是否存在
bool exist = (s.find(20) != s.end()); // find()
int count = s.count(20) // count() != 0

Map

#include <map>红黑树实现,内部元素有序
#include <unordered_map>哈希实现,内部无序,查找更高效

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
map<string, string> m;

// 插入键值对
m.insert(make_pair("key", "value"));
m["key"] = "value";

// 访问键对应的值
string v = m.at("key");

// 元素个数
m.size();

// 遍历
for (map<string, string>::iterator it=m.begin(); it != m.end(); it++) {
cout << it->first << ": " << it->second << endl;
}

// 删除键值对
m.erase("key");

// 清空
m.clear();

// 查找键是否存在
bool exist = (m.find("key") != m.end()); // find()
int count = m.count("key") // count() != 0