Cloudflare 低延迟 IP 地址历史记录

IP 地址已发送已接收丢包率平均延迟下载速度 (MB/s)
104.17.74.8044050.2813.02
104.25.213.24644050.6212.35
104.16.107.2544050.1812.31
104.18.230.2744049.5112.01
104.17.73.8244050.0610.79
104.24.49.7444050.4810.28
104.18.37.6044049.413.79
104.24.19.3144050.823.14
104.17.212.144049.290.46
104.25.193.21444052.520.07
2022.4.5

IPv4

173.245.48.0/20
103.21.244.0/22
103.22.200.0/22
103.31.4.0/22
141.101.64.0/18
108.162.192.0/18
190.93.240.0/20
188.114.96.0/20
197.234.240.0/22
198.41.128.0/17
162.158.0.0/15
104.16.0.0/13
104.24.0.0/14
172.64.0.0/13
131.0.72.0/22

IPv6

2400:cb00::/32
2606:4700::/32
2803:f800::/32
2405:b500::/32
2405:8100::/32
2a06:98c0::/29
2c0f:f248::/32

群晖Nas安装pip只需两行命令

Python2.7匹配的pip

wget https://bootstrap.pypa.io/pip/2.7/get-pip.py

Proxy request sent, awaiting response... 200 OK
Length: 1908226 (1.8M) [text/x-python]
Saving to: 'get-pip.py'

get-pip.py          100%[===================>]   1.82M   738KB/s    in 2.5s
python get-pip.py

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting pip<21.0
  Downloading pip-20.3.4-py2.py3-none-any.whl (1.5 MB)
     |████████████████████████████████| 1.5 MB 352 kB/s
Collecting setuptools<45
  Downloading setuptools-44.1.1-py2.py3-none-any.whl (583 kB)
     |████████████████████████████████| 583 kB 3.3 MB/s
Collecting wheel
  Downloading wheel-0.36.2-py2.py3-none-any.whl (35 kB)
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-20.3.4 setuptools-44.1.1 wheel-0.36.2

最终目的是装requests,搞定!

pip install requests

Collecting requests
  Downloading requests-2.25.1-py2.py3-none-any.whl (61 kB)
     |████████████████████████████████| 61 kB 249 kB/s
Collecting chardet<5,>=3.0.2
  Downloading chardet-4.0.0-py2.py3-none-any.whl (178 kB)
     |████████████████████████████████| 178 kB 613 kB/s
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.4-py2.py3-none-any.whl (153 kB)
     |████████████████████████████████| 153 kB 2.5 MB/s
Collecting idna<3,>=2.5
  Downloading idna-2.10-py2.py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB 2.2 MB/s
Collecting certifi>=2017.4.17
  Downloading certifi-2020.12.5-py2.py3-none-any.whl (147 kB)
     |████████████████████████████████| 147 kB 6.1 MB/s
Installing collected packages: chardet, urllib3, idna, certifi, requests
Successfully installed certifi-2020.12.5 chardet-4.0.0 idna-2.10 requests-2.25.1 urllib3-1.26.4

[W:pyppeteer.chromium_downloader] start chromium download. Download may take a few minutes.

urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='storage.googleapis.com', port=443): Max retries exceeded with url: /chromium-browser-snapshots/Win_x64/588429/chrome-win32.zip (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000002225ACF2C50>: Failed to establish a new connection: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。',))

提示SSL错误
解决办法:
编辑 C:\Users\XXXX\AppData\Roaming\Python\Python36\site-packages\pyppeteer\chromium_downloader.py,把https://storage.googleapis.com改为http://storage.googleapis.com即可

Chromium路径C:\Users\XXXX\AppData\Local\pyppeteer\pyppeteer\local-chromium\588429\chrome-win32

[W:pyppeteer.chromium_downloader] start chromium download.
Download may take a few minutes.
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████| 136913619/136913619 [00:13<00:00, 10093738.83it/s]
[W:pyppeteer.chromium_downloader]
chromium download done.
[W:pyppeteer.chromium_downloader] chromium extracted to: C:\Users\XXXX\AppData\Local\pyppeteer\pyppeteer\local-chromium\588429

PVE(Proxmox VE)快照和备份有什么区别?

备份

可以理解为克隆,备份文件之间是完整且独立的,Proxmox VE 备份始终是完整备份-包含VM / CT配置和所有数据,占用空间较大。备份后可以删除虚拟机,然后从备份文件恢复虚拟机,[备份👉快照模式] 只是虚拟机备份模式中的一种,以最小的不一致风险为代价,提供了最低的操作停机时间。它通过执行 Proxmox VE 实时备份来工作,该备份在VM运行时复制数据块。

快照

快照的数据(存储开销)是基于上一次快照的数据变化部分,而不是像备份那样复制一份完整虚拟机生存数据,占用空间较小,不能通过快照恢复被删除的虚拟机,快照不能脱离原始虚拟机运行,还原快照也就是把虚拟机从”创建快照时的状态(包括RAM数据)“还原到创建快照的时候,类似“时间机器”。

建议在为运行中的VM拍摄快照时包括RAM或使用QEMU Guest Agent,以避免不一致。

时间机器:如果备份磁盘已满,则最早的备份会被删除。

首次备份可能需要很长时间,只会备份自上次备份以来有变动的文件,因此将来的备份速度会加快。

https://support.apple.com/zh-cn/HT201250

Dism++安装镜像提示:指定缓冲区中包含类型错误的数据,怎么办?

使用 WIndows 安装器WinNTSetup安装同样报错“应用系统映像失败!指定的缓冲区中包含类型错误的数据。”

常见问题

问: Dism++安装镜像提示:指定缓冲区中包含类型错误的数据,怎么办?

答: 下载的系统镜像文件不完整,请重新下载。

问: 系统镜像的MD5值是正确的,但还是提示
指定缓冲区中包含类型错误的数据 

答: 硬盘问题,逻辑坏道或者物理坏道导致的。更换硬盘,重新下载文件解决。

问: C盘格式化了,但是镜像无法安装,出现错误,本地已经没有其他系统镜像了,也没有第二台电脑,怎么办?

答: 可以去就近网吧重新下载镜像,记得校验系统镜像。

问: 开机提示BOOTMGR is missing / NTLTR is missing,怎么办?

答: 系统引导丢失,进入PE后使用DISM++修复系统引导即可。

问: 装系统时强制关机,然后开机后黑屏无信号,确定显卡插槽视频线都是好的,怎么办?

答: 尝试将机器完全断电,扣掉主板上的CMOS电池,等待十秒钟后再装回,然后开机即可。

让 JVM 抛出一个 OutOfMemoryError 内存溢出错误

本机内存溢出

DirectMemory容量可以通过-XX:MaxDirectMemorySize指定。

import java.lang.reflect.Field;
import sun.misc.Unsafe;

public classDirectMemoryOOM {
    private static final int _1MB = 1024 * 1024;

    public static void main(String[] args) throws IllegalArgumentException,
            IllegalAccessException {
        Field unsafeField = Unsafe.class.getDeclaredFields()[0];
        unsafeField.setAccessible(true);
        Unsafe unsafe = (Unsafe) unsafeField.get(null);

        while (true) {
            try {
                unsafe.allocateMemory(_1MB);
            } catch (OutOfMemoryError er) {
                System.out.println(er.toString());
                System.exit(0);
            }
        }
    }
}

// java.lang.OutOfMemoryError

为什么有时不声明 throws 也可以编译通过

RuntimeException不需要强制对其进行声明和捕获。可以认为Checked exception就是要强制程序员去处理这个异常(不管你throws多少层,终归要在某个地方catch),而Runtime exception则没有这个限制,可以自由选择是否catch

// 定义的是一个必检异常
class HexFormatException extends Exception { }

// 定义的是一个运行时异常
class BinaryFormatException extends NumberFormatException {}

NumberFormatException extends IllegalArgumentException

IllegalArgumentException extends RuntimeException

Proxmox VE(PVE)硬盘扩容,支持EMMC

pve,esxi都是用lvm管理分区,可以使用lvm扩容分区

  • 启动emmc里的pve
  • 扩充的是local-lvm(local主要是VZDump备份文件, ISO镜像, 容器模板,local-lvm主要是 磁盘映像, 容器)
  • 使用putty、xshell一类的软件通过ssh进pve,端口22,用户名root,密码是安装pve时设置的密码

扩容前

检查可能出现的情况

fdisk -l

如果提示

GPT PMBR size mismatch (67108863 != 121634815) will be corrected by write.

执行

apt-get update
apt-get install parted
parted -l

Fix

扩容分区

安装需要的软件

apt-get update
apt-get install parted

执行

fdisk -l

提示

GPT PMBR size mismatch (67108863 != 121634815) will be corrected by write.
Disk /dev/sda: 58 GiB, 62277025792 bytes, 121634816 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 0C17A6FD-69E2-401F-97C8-209F38118AC9

Device       Start      End  Sectors  Size Type
/dev/sda1       34     2047     2014 1007K BIOS boot
/dev/sda2     2048  1050623  1048576  512M EFI System
/dev/sda3  1050624 67108830 66058207 31.5G Linux LVM


Disk /dev/mapper/pve-swap: 3.9 GiB, 4160749568 bytes, 8126464 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/pve-root: 7.8 GiB, 8321499136 bytes, 16252928 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

查看系统内硬盘名称(这一步可省略)

lsblk

提示

NAME               MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk1            179:0    0 58.2G  0 disk
├─mmcblk1p1        179:1    0 1007K  0 part
├─mmcblk1p2        179:2    0  512M  0 part /boot/efi
└─mmcblk1p3        179:3    0 57.8G  0 part
  ├─pve-swap       253:0    0  3.6G  0 lvm  [SWAP]
  ├─pve-root       253:1    0  7.3G  0 lvm  /
  ├─pve-data_tmeta 253:2    0    1G  0 lvm
  │ └─pve-data     253:4    0 44.9G  0 lvm
  └─pve-data_tdata 253:3    0 44.9G  0 lvm
    └─pve-data     253:4    0 44.9G  0 lvm
mmcblk1boot0       179:8    0    4M  1 disk
mmcblk1boot1       179:16   0    4M  1 disk

如果是emmc,硬盘名称是mmcblk1,执行

parted /dev/mmcblk1

如果是非emmc,硬盘名称是sda,执行

parted /dev/sda

提示

GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)

执行

print

提示

(parted) print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 62.3GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name  Flags
 1      17.4kB  1049kB  1031kB                     bios_grub
 2      1049kB  538MB   537MB   fat32              boot, esp
 3      538MB   34.4GB  33.8GB                     lvm

(parted)

扩容LVM,执行

resizepart 3 100%

quit

提示

(parted) resizepart 3 100%
(parted) quit
Information: You may need to update /etc/fstab.

更新物理卷的大小,LVM所在驱动器

如果是emmc,执行

pvresize /dev/mmcblk3

非emmc,执行

pvresize /dev/sda3

提示

Physical volume "/dev/sda3" changed
1 physical volume(s) resized or updated / 0 physical volume(s) not resized

扩容逻辑卷,执行

cat /etc/pve/storage.cfg

提示

dir: local
        path /var/lib/vz
        content iso,vztmpl,backup

lvmthin: local-lvm
        thinpool data
        vgname pve
        content rootdir,images

执行

lvdisplay

提示

--- Logical volume ---
  LV Path                /dev/pve/swap
  LV Name                swap
  VG Name                pve
  LV UUID                ArHV9L-H5ZI-M4gs-Gj1M-4bFV-qbWO-K2VYk4
  LV Write Access        read/write
  LV Creation host, time proxmox, 2020-07-02 19:06:14 +0800
  LV Status              available
  # open                 2
  LV Size                <3.88 GiB
  Current LE             992
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Logical volume ---
  LV Path                /dev/pve/root
  LV Name                root
  VG Name                pve
  LV UUID                L1MtJ0-LX2s-JfVn-5bTY-WdM8-jfxZ-Gi2oTD
  LV Write Access        read/write
  LV Creation host, time proxmox, 2020-07-02 19:06:14 +0800
  LV Status              available
  # open                 1
  LV Size                7.75 GiB
  Current LE             1984
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

  --- Logical volume ---
  LV Name                data
  VG Name                pve
  LV UUID                AYiySQ-K6O5-Ye17-XAtF-m154-tRoG-mljDuL
  LV Write Access        read/write
  LV Creation host, time proxmox, 2020-07-02 19:06:15 +0800
  LV Pool metadata       data_tmeta
  LV Pool data           data_tdata
  LV Status              available
  # open                 0
  LV Size                <14.00 GiB
  Allocated pool data    0.00%
  Allocated metadata     1.58%
  Current LE             3583
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:4

执行

pvs

lvextend -l +100%FREE /dev/pve/data

提示

Size of logical volume pve/data_tdata changed from <14.00 GiB (3583 extents) to 43.87 GiB (11231 extents).
Logical volume pve/data_tdata successfully resized.

扩容成功,可在pve控制端网页查看

根据凸多边形顶点坐标来计算面积的算法与实现

把凸多边形划分成若干个三角形,取多边形的一个顶点为三角形共同顶点

double x0 = x.get(0);
double y0 = y.get(0);

三角形个数 = 坐标对数 – 2

// 每个三角形的三条边 i从0开始
double s1 = Math.sqrt(Math.pow(x0 - x.get(i + 1), 2) + Math.pow(y0 - y.get(i + 1), 2));
double s2 = Math.sqrt(Math.pow(x0 - x.get(i + 2), 2) + Math.pow(y0 - y.get(i + 2), 2));
double s3 = Math.sqrt(Math.pow(x.get(i + 1) - x.get(i + 2), 2) + Math.pow(y.get(i + 1) - y.get(i + 2), 2));
// 每个三角形的面积
double s = (s1 + s2 + s3) / 2;
double area = Math.pow((s * (s - s1) * (s - s2) * (s - s3)), 1.0 / 2);