3月 012021
 
"""
https://matplotlib.org/stable/index.html
Matplotlib: Visualization with Python
Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python.
"""
# 导入模块并指定别名
import matplotlib.pyplot as plt

# 提供输入值,解决x坐标从0开始的问题
input_values = [1, 2, 3, 4, 5]
# 定义平方数列表
square = [1, 4, 9, 16, 25]


# 将列表传递给函数
# plt.plot(square)
# 改善图形可读性,线条加粗
# plt.plot(square, linewidth=5)
# 同时提供输入值列表和输出值列表
plt.plot(input_values, square, linewidth=5)


# 函数title()指定图表标题,参数fontsize指定文字大小
plt.title("Square Numbers", fontsize=24)
# 函数xlable()和ylable()为每条轴设置标题并指定文字大小
plt.xlabel("Value", fontsize=14)
plt.ylabel("Square of Value", fontsize=14)

# 函数tick_parms()设置刻度样式,并将设置刻度文字大小
# axis n. 轴(旋转物体假想的中心线); (尤指图表中的)固定参考轴线,坐标轴; 对称中心线(将物体平分为二);
plt.tick_params(axis='both', labelsize=14)

# 调用matplotlib查看器,显示绘制的图形
plt.show()
1月 262021
 

iptables示例

sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 8443

firewalld示例

# allow incoming connections on port 80.
# You can also use --add-service=http instead of adding a port number
sudo firewall-cmd --add-port=80/tcp --permanent
sudo firewall-cmd --permanent \
--add-forward-port=port=80:proto=tcp:toaddr=127.0.0.1:toport=8080

# allow incoming connections on port 443.
# You can also use --add-service=https instead of adding a port number
sudo firewall-cmd --add-port=443/tcp --permanent
sudo firewall-cmd --permanent \
--add-forward-port=port=443:proto=tcp:toaddr=127.0.0.1:toport=8443
sudo firewall-cmd --reload

内容引用:

https://www.jenkins.io/doc/book/system-administration/reverse-proxy-configuration-iptables/

1月 262021
 

安装阶段修改配置

[root@jenkins ~]# cd /var/lib/jenkins/
[root@jenkins jenkins]# cat hudson.model.UpdateCenter.xml 
<?xml version='1.1' encoding='UTF-8'?>
<sites>
<site>
<id>default</id>
<url>https://updates.jenkins.io/update-center.json</url>
</site>
</sites>[root@jenkins jenkins]#

[root@jenkins jenkins]# cat hudson.model.UpdateCenter.xml 
<?xml version='1.1' encoding='UTF-8'?>
<sites>
<site>
<id>default</id>
<url>https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json</url>
</site>
</sites>
[root@jenkins jenkins]#

使用阶段修改配置

1月 052021
 
File -> Settings -> Project -> Python Interpreter -> Install -> Available Packages -> Manage Repositories

https://mirrors.163.com/pypi/simple/
https://mirrors.ustc.edu.cn/pypi/web/simple
https://pypi.tuna.tsinghua.edu.cn/simple
https://mirrors.aliyun.com/pypi/simple/
12月 252020
 

Jenkins版本

Jenkins 2.263.1

Jenkins操作

SSH Server --> Test Configuration

错误提示

Failed to connect or change directory
jenkins.plugins.publish_over.BapPublisherException: Failed to connect and initialize SSH connection.

默认输出key格式

[root@iZwz92yjivclsut0awv6bjZ ~]# ssh-keygen -t ecdsa -b 256
Generating public/private ecdsa key pair.
Enter file in which to save the key (/root/.ssh/id_ecdsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_ecdsa.
Your public key has been saved in /root/.ssh/id_ecdsa.pub.
The key fingerprint is:
SHA256:bG0w07gnsQlE68UytVRe+ZlD21B9EeKN+OD4wmAf7cg root@iZwz92yjivclsut0awv6bjZ
The key's randomart image is:
+---[ECDSA 256]---+
| .o o.. .o +=|
| . = = .+ * o|
| = X oo = B.|
| . * X+ o * .|
| .oSo+o . . |
| ..=+= |
| E o |
| . |
| |
+----[SHA256]-----+
[root@iZwz92yjivclsut0awv6bjZ ~]# cat .ssh/id_ecdsa
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAaAAAABNlY2RzYS
1zaGEyLW5pc3RwMjU2AAAACG5pc3RwMjU2AAAAQQRs8Cw4Ydm7zowb4ZYpuqwqSfeaOXqw
byz0iL1KAsWJyA8swh/AG2eHW3HJd1QWYExeQBKGe/9kPBpdKP+JpVcmAAAAuO37TNHt+0
zRAAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBGzwLDhh2bvOjBvh
lim6rCpJ95o5erBvLPSIvUoCxYnIDyzCH8AbZ4dbccl3VBZgTF5AEoZ7/2Q8Gl0o/4mlVy
YAAAAhAOEdqVnSzZwrdb0QpuT6taMnF3LrIF+Wbo4TMMVnDcJiAAAAHHJvb3RAaVp3ejky
eWppdmNsc3V0MGF3djZialoBAgM=
-----END OPENSSH PRIVATE KEY-----
[root@iZwz92yjivclsut0awv6bjZ ~]#

指定输出key格式

[root@iZwz92yjivclsut0awv6bjZ ~]# ssh-keygen -t ecdsa -b 256 -m PEM
Generating public/private ecdsa key pair.
Enter file in which to save the key (/root/.ssh/id_ecdsa): 
/root/.ssh/id_ecdsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_ecdsa.
Your public key has been saved in /root/.ssh/id_ecdsa.pub.
The key fingerprint is:
SHA256:BsVkzYf82bO5QtF1gs85DN90JvyqGFSaMD9D2+xV+fI root@iZwz92yjivclsut0awv6bjZ
The key's randomart image is:
+---[ECDSA 256]---+
| o++ . o .|
| o+ * = +.B|
| . = X X @+|
| . O * & +|
| S. + o O |
| . . o + E|
| + . . |
| . o . |
| . |
+----[SHA256]-----+
[root@iZwz92yjivclsut0awv6bjZ ~]# cat .ssh/id_ecdsa
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIIPtHTiOHFbg0ib+xqpT/Ppu15gIVnnh1UGJjjZoiDr9oAoGCCqGSM49
AwEHoUQDQgAEp/PU4drzb49XzMmrnIa55Veb9K5coVX/67B6aNF3owQX3tCBSzFp
Y3BwI+m5jRZ8CDRwQgItF6jW6h8snr9xeg==
-----END EC PRIVATE KEY-----
[root@iZwz92yjivclsut0awv6bjZ ~]#

参数描述

-m key_format
Specify a key format for the -i (import) or -e (export) conversion options. The supported key formats are: “RFC4716” (RFC 4716/SSH2 public or private key), “PKCS8” (PEM PKCS8 public key) or “PEM” (PEM public key). The default conversion format is “RFC4716”.

 

12月 242020
 
https://ipinfo.io/developers
C:\Users\harveymei>curl ipinfo.io
{
"ip": "119.137.55.106",
"city": "Shenzhen",
"region": "Guangdong",
"country": "CN",
"loc": "22.5455,114.0683",
"org": "AS4134 CHINANET-BACKBONE",
"timezone": "Asia/Shanghai",
"readme": "https://ipinfo.io/missingauth"
}
C:\Users\harveymei>
11月 062020
 
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time       : 2020/11/3 14:59
# @Author     : Harvey Mei <harvey.mei@msn.com>
# @FileName   : base36.py
# @IDE        : PyCharm
# @GitHub     :https://github.com/harveymei/

import string


# base10 to base36
def encode(number):
    alphabet = string.digits + string.ascii_lowercase
    value = ''

    while number != 0:
        number, index = divmod(number, len(alphabet))
        value = alphabet[index] + value

    return value or '0'


# base36 to base10
def decode(value):
    return int(value, 36)


# 循环,当number > 0时求商取余,将余数作为字符串切片取值
print(divmod(1024, 36))
print((string.digits + string.ascii_lowercase)[16])
# 'g' + ''

print(divmod(28, 36))
print((string.digits + string.ascii_lowercase)[28])
# 's' + 'g'

# 当number == 0时退出循环
print(divmod(0, 36))
print((string.digits + string.ascii_lowercase)[0])