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 –permanen
t
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])
10月 302020
 
# -*- coding:utf-8 -*-
# 类是一系列具有共同特征和行为的事物的抽象概念的总和
# 在类里面赋值的变量就是类的变量,专有术语称之为类的属性(Class Attribute)

class CocaCola:  # Class names should use CamelCase convention
    formula = ['caffeine', 'sugar', 'water', 'soda']


# 类的实例化
# 将类赋值给变量的过程称之为类的实例化,被实例化后的对象称之为实例
coke_for_me = CocaCola()  # PEP 8: E305 expected 2 blank lines after class or function definition, found 1
coke_for_you = CocaCola()

# 类属性引用
# 在类的名字后输入.后IDE自动联想类中的属性
# 类的属性会被所有类的实例共享
print(CocaCola.formula)
print(coke_for_me.formula)
print(coke_for_you.formula)

for element in coke_for_me.formula:
    print(element)

# 实例属性
coke_for_china = CocaCola()
coke_for_china.local_logo = '可口可乐'

print(coke_for_china.local_logo)
C:\Users\harveymei\PycharmProjects\mod3736\venv\Scripts\python.exe C:/Users/harveymei/PycharmProjects/mod3736/howto.py
['caffeine', 'sugar', 'water', 'soda']
['caffeine', 'sugar', 'water', 'soda']
['caffeine', 'sugar', 'water', 'soda']
caffeine
sugar
water
soda
可口可乐

Process finished with exit code 0
10月 292020
 
# -*- coding:utf-8 -*-
import string

# 输出所有标点符号!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
print(string.punctuation)
# https://docs.python.org/zh-cn/3/library/stdtypes.html#str.strip
# strip()方法返回原字符串的副本,移除其中的前导和末尾字符。不指定参数则移除空格。
# https://docs.python.org/zh-cn/3/library/string.html#string.punctuation
# 字符串常量,返回被视为标点符号的 ASCII 字符所组成的字符串
# https://docs.python.org/zh-cn/3/library/functions.html#func-set
# set()函数,返回集合对象。
# set()函数创建一个无序不重复元素集,可进行关系测试,删除重复数据,还可以计算交集、差集、并集等。


path = 'C:/Users/harveymei/Desktop/news.txt'

with open(path, 'r') as text:
    # 循环读取分割单词赋值变量写入列表并对元素去除标点符号并转换为小写
    words = [raw_word.strip(string.punctuation).lower() for raw_word in text.read().split()]
    words_index = set(words)  # 使用set()函数将列表中的字符去重复后赋值变量
    # 循环获取列表元素作为key,并将words列表中元素计数值作为value,生成字典并赋值变量
    counts_dic = {index: words.count(index) for index in words_index}

# https://docs.python.org/zh-cn/3/library/functions.html#sorted
# 根据 iterable 中的项返回一个新的已排序列表。
# 具有两个可选参数,它们都必须指定为关键字参数。
# key 指定带有单个参数的函数,用于从 iterable 的每个元素中提取用于比较的键 (例如 key=str.lower)。 默认值为 None (直接比较元素)。
# reverse 为一个布尔值。 如果设为 True,则每个列表元素将按反向顺序比较进行排序。
# https://docs.python.org/zh-cn/3/howto/sorting.html#key-functions
# key 形参用来指定在进行比较前要在每个列表元素上调用的函数(或其他可调用对象)。
# https://docs.python.org/zh-cn/3/reference/expressions.html?highlight=lambda#lambda
# lambda 表达式(有时称为 lambda 构型)被用于创建匿名函数。

for word in sorted(counts_dic, key=lambda x: counts_dic[x], reverse=True):  # 循环对字典中元素按照计数值反向排序并赋值变量
    print('{} -- {} times'.format(word, counts_dic[word]))  # 使用格式化字符串打印单词及对应计数值
C:\Users\harveymei\PycharmProjects\mod3736\venv\Scripts\python.exe C:/Users/harveymei/PycharmProjects/mod3736/static.py
!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
the -- 14 times
a -- 4 times
in -- 4 times
and -- 4 times
that -- 4 times
leads -- 2 times
created -- 2 times
practice -- 2 times
such -- 2 times
china -- 2 times
has -- 2 times
said -- 2 times
legislature -- 2 times
party -- 2 times
li -- 2 times
experience -- 2 times
process -- 2 times
is -- 2 times
adding -- 2 times
government -- 2 times
roles -- 2 times
good -- 2 times
governance -- 2 times
cpc -- 2 times
due -- 2 times
work -- 2 times
formulation -- 2 times
their -- 2 times
of -- 2 times
play -- 2 times

Process finished with exit code 0