Skip to content

Instantly share code, notes, and snippets.

View foru17's full-sized avatar
🎯
Focusing

Luo Lei foru17

🎯
Focusing
View GitHub Profile
@foru17
foru17 / cloudflare-worker-bulk-zip-and-download.ts
Last active September 2, 2024 08:04
zip files and download by cloudlfare worker
// 通过 Cloudflare Worker 批量打包和下载现存文件
// curl -X POST https://your-worker-endpoint/create-zip \
// -H "Authorization: Bearer YOUR_AUTH_SECRET" \
// -H "Content-Type: application/json" \
// -d '{
// "filePaths": [
// "path/to/file1.jpg",
// "path/to/file2.png",
// "path/to/file3.pdf"
// ]
rule-providers:
reject:
type: http
behavior: domain
url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/reject.txt"
path: ./ruleset/reject.yaml
interval: 86400
icloud:
type: http
@foru17
foru17 / git-commit-user-reset.sh
Created March 20, 2024 10:38
reset git user name and email
git filter-branch --env-filter '
OLD_NAME="old_name"
OLD_EMAIL="[email protected]"
CORRECT_NAME="luolei"
CORRECT_EMAIL="[email protected]"
if [ "$GIT_COMMITTER_NAME" = "$OLD_NAME" ] && [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
@foru17
foru17 / remove_duplicates.py
Last active January 23, 2024 19:33
remove duplicates file witch hash check
import os
import re
import hashlib
# 设定工作目录
DIR = "/Volumes/Desktop"
def calculate_hash(filepath):
hasher = hashlib.sha256()
with open(filepath, 'rb') as f:
@foru17
foru17 / cloudflare-workers-proxy-images.ts
Created August 25, 2023 10:49
A Cloudflare Workers script automatically uploads existing images to the Cloudflare Images service.
// Cloudflare Images 鉴权API文档
// https://developers.cloudflare.com/images/cloudflare-images/api-request/
const CF_IMAGES_ACCOUNT_ID: string = "<账号ID>";
const CF_IMAGES_API_KEY: string = "<CLOUDFLARE IMAGES API KEY>";
const CF_IMAGES_BUCKET_NAME: string = "<账号HASH>";
// 白名单域名
@foru17
foru17 / renew-dhcp.sh
Created April 20, 2023 09:25
Auto check and renew dhcp ip
#!/bin/bash
# 记录日志时间
log_time=$(TZ=UTC-8 date +"%Y-%m-%d-%H:%M:%S")
log_dir="/www/wwwlogs/"
server_name="DHCP"
# 获取 ens192 网卡对应的 IP 地址和子网掩码
ipaddr=$(ip addr show ens192 | grep -w inet | awk '{print $2}')
netmask=$(ip addr show ens192 | grep -w inet | awk '{print $2}' | awk -F '/' '{print $2}')
# 判断 IP 地址是否为局域网 IPV4 地址(以 10.x.x.x、172.16.x.x 至 172.31.x.x、192.168.x.x 开头)
@foru17
foru17 / auto-renwal-subconver.sh
Created April 3, 2023 02:06
批量更新节点订阅脚本
#!/bin/bash
# 配合定时脚本使用
# 订阅后台接口,建议自己搭建,参考 https://github.com/tindy2013/subconverter
SERVER_API_URL="https://any.sub.domain/subconver"
# 输出的目录位置, nginx 解析目录
OUTPUT_FOLDER="/www/wwwroot/sub.domain.com"
# bark 推动提醒地址
@foru17
foru17 / nginx-fallback.conf
Last active April 4, 2023 06:07
Nginx 主从兜底配置
server {
listen 80;
listen 443 ssl http2;
server_name demo.domain.com;
index index.php index.html index.htm default.php default.htm default.html;
root /www/wwwroot/demo.domain.com;
recursive_error_pages on;
proxy_intercept_errors on;
@foru17
foru17 / gist:710419a2dbb87b51ebedd3d230bfb255
Created October 22, 2022 13:15
curl 命令分析请求耗时
curl -w " \ntime_namelookup:%{time_namelookup}\ntime_connect: %{time_connect}\ntime_appconnect: %{time_appconnect}\ntime_redirect: %{time_redirect}\ntime_pretransfer: %{time_pretransfer}\ntime_starttransfer: %{time_starttransfer}\n----------\ntime_total: %{time_total}\n" -o /dev/null -s -L "https://www.google.com"
@foru17
foru17 / baidu.js
Created January 9, 2018 07:39
简单的百度搜索结果数量统计api
var cheerio = require('cheerio');
var http = require('http');
var iconv = require('iconv-lite');
var express = require('express');
var app = express();
app.get('/api/baidu/:keyword', function(req, res) {
var keyword = req.param('keyword');
var encodeKey = encodeURIComponent(keyword);
var url = 'http://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=0&rsv_idx=1&tn=baidu&wd=' + encodeKey + '&rsv_pq=d1bc678500027fae&rsv_t=b1baqnanzIu6%2B%2B6jgA5UgJY9hPGjPUfG2I03drYiQCZLKs41hn1TBNqN2tg&rqlang=cn&rsv_enter=1&rsv_sug3=14&rsv_sug1=13&rsv_sug7=100&rsv_sug2=0&inputT=1230&rsv_sug4=1231'