2021年1月

github局部部分下载,zip打包

1、安装SVN
2、获取路径地址,将'/tree/master'替换为'/trunk/'
3、svn checkout 新的地址

实例,下载NUCLEO-G070RB的官方项目
https://github.com/STMicroelectronics/STM32CubeG0/tree/master/Projects/NUCLEO-G070RB
结果也不知道是否checkout结束
svn: E130003: The XML response contains invalid XML

sudo apt-get install zip
zip -r NUCLEO-G070RB.zip NUCLEO-G070RB/

参考文献:
https://blog.csdn.net/nqwzl/article/details/98741155
https://cloud.tencent.com/developer/article/1619411
https://my.oschina.net/u/4344027/blog/3393697
DownGit项目
http://t.cn/RfyGcPX
https://github.com/MinhasKamal/DownGit
https://minhaskamal.github.io/DownGit/

Go和Excel

获取包
go get github.com/360EntSecGroup-Skylar/excelize(不需要,程序自动获取v2)
建立test.go

package main

import (
    "fmt"

    "github.com/360EntSecGroup-Skylar/excelize/v2"
)

func main() {
    f := excelize.NewFile()
    // 创建一个工作表
    index := f.NewSheet("Sheet2")
    // 设置单元格的值
    f.SetCellValue("Sheet2", "A2", "Hello world.")
    f.SetCellValue("Sheet1", "B2", 100)
    // 设置工作簿的默认工作表
    f.SetActiveSheet(index)
    // 根据指定路径保存文件
    if err := f.SaveAs("Book1.xlsx"); err != nil {
        fmt.Println(err)
    }
}

go mod init main
go run test.go
生成Book1.xlsx,包含两个Sheet

- 阅读剩余部分 -

关于nginx的proxy_pass

常用配置

location /api {
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass http://192.168.1.11:8070/;
}

服务在192.168.1.11:8070的/api/路径下
如果配置8070/需要访问/api/api/才能访问到
如果配置中不带/就可以/api/访问到了
替换时location /newapi时需要配置/api,不带结尾的/
总结proxy_pass后尽量不要带/
如果不替换,配置是否带/api似乎差别不大

跨域问题Access-Control-Allow-Origin

Access-Control-Allow-Origin是HTML5中定义的一种解决资源跨域的策略。

他是通过服务器端返回带有Access-Control-Allow-Origin标识的Response header,用来解决资源的跨域权限问题。

add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';

最好不跨

speedtest网络测速

https://github.com/sivel/speedtest-cli/

python speed.py --csv-header
Server ID,Sponsor,Server Name,Timestamp,Distance,Ping,Download,Upload,Share,IP Address
python speed.py --csv
5145,Beijing Unicom,Beijing,2021-01-11T04:49:04.392496Z,1.673922445212346,5.547,628723539.378605,55826659.160589784,,公网IP

python speed.py
Retrieving speedtest.net configuration...
Testing from China Unicom Beijing (公网IP)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Beijing Unicom (Beijing) [1.67 km]: 6.337 ms
Testing download speed................................................................................
Download: 625.72 Mbit/s
Testing upload speed................................................................................................
Upload: 56.08 Mbit/s

python speed.py --json
{
"client": {"rating": "0", "loggedin": "0", "isprating": "3.7", "ispdlavg": "0", "ip": "公网IP", "isp": "China Unicom Beijing", "lon": "经度", "ispulavg": "0", "country": "CN", "lat": "纬度"},
"bytes_sent": 70762496, "download": 596758926.7716337, "timestamp": "2021-01-11T04:56:33.105784Z", "share": null, "bytes_received": 409373932, "ping": 5.535, "upload": 55883940.61967305,
"server": {"latency": 5.535, "name": "Beijing", "url": "http://bj3.unicomtest.com:8080/speedtest/upload.php", "country": "China", "lon": "经度", "cc": "CN", "host": "bj3.unicomtest.com:8080", "sponsor": "Beijing Broadband Network", "lat": "纬度", "id": "5505", "d": 1.673922445212346}
}