Skip to content

Instantly share code, notes, and snippets.

View Cuile's full-sized avatar

瘦了就帅了 Cuile

View GitHub Profile
@Cuile
Cuile / cloud-config.yaml
Last active May 15, 2025 04:56
在PVE 8.3.3上,使用脚本创建debian bookworm QEMU虚拟机,并配置cloud-init命令。
#cloud-config
# 主机名
hostname: dev
fqdn: dev.env
manage_etc_hosts: true
# 软件包
package_update: true
packages:
- qemu-guest-agent
# 命令行
@Cuile
Cuile / init_setup_debian_bookworm.sh
Last active May 15, 2025 06:24
Linux 各发行版初始化配置脚本
#!/bin/bash
# based on cloud-init debian
set -e
# 添加系统判断,即可通过函数运行不同的命令
stdout() {
echo "$(basename $0): $1"
}
installer() {
@Cuile
Cuile / dockerhub.caddy
Last active April 14, 2025 16:22
caddy反向代理dockerhub的设置。
# https://zhul.in/2024/09/21/how-to-reverse-proxy-dockerhub-with-caddy/index.html
http://registry.you.com {
reverse_proxy https://registry-1.docker.io {
header_up Host {http.reverse_proxy.upstream.hostport}
header_down www-authenticate "https://auth.docker.io" "http://auth.you.com"
header_down location "https://production.cloudflare.docker.com" "http://production.you.com"
}
}
@Cuile
Cuile / urllib.parse.urlencode.md
Last active July 29, 2021 08:03
urllib.parse.urlencode 使用详解

urllib.parse.urlencode(query, doseq=False, safe='', encoding=None, errors=None, quote_via=quote_plus) urllib.parse.urlencode 将对象或两元素序列转换为百分比编码的ASCII文本字符串,字符串是由'&'字符分隔的一系列 key=value 对,其中 key 和 value 都使用 quote_via 函数引用。

GET 请求

import urllib
params = urllib.parse.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
url = "http://www.musi-cal.com/cgi-bin/query?%s" % params
with urllib.request.urlopen(url) as f:
 print(f.read().decode('utf-8'))