Skip to content

Instantly share code, notes, and snippets.

View phlinhng's full-sized avatar

phlinhng

  • Tsinghua University
  • Formosa
View GitHub Profile
@phlinhng
phlinhng / cloudflare-ddns.sh
Last active September 5, 2023 19:46
Cloudflare DDNS Script
#!/bin/bash
zone_name=$1
record_name=$2
api_key=$3
current_ip=`curl -s https://api.ipify.org`
zone_id=`curl -s -X GET "https://api.cloudflare.com/client/v4/zones" \
-H "Authorization: Bearer ${api_key}" -H "Content-Type: application/json" \
| jq -r ".result | .[] | select(.name == \"${zone_name}\") | .id"`
let github2jsdelivr = (_url) => {
regex = {"blob": /(.+)github.com\/(.+)\/(.+)\/blob\/(.+)\/(.+)/,
"tree": /(.+)github.com\/(.+)\/(.+)\/blob\/(.+)\/(.+)/};
if(_url.match(regex.tree)){
return _url.replace(regex.tree, "$1cdn.jsdelivr.net/gh/$2/$3@$4/$5");
}else if(_url.match(regex.blob)){
return _url.replace(regex.blob, "$1cdn.jsdelivr.net/gh/$2/$4@$4/$5");
}else{
return _url;
}
@phlinhng
phlinhng / cfworkers_reverse_proxy.js
Last active July 16, 2021 02:35
fw: universal reverse proxy template
// 需要反代的地址
const upstream = 'api.github.com'
// 反代地址的子路径
const upstreamPath = '/'
// 反代网站的移动端域名
const upstreamMobile = 'api.github.com'
// 是否使用 https
const useHttps = true