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 / proxy-rule.ini
Last active April 11, 2024 09:40
proxy rule
mixed-port: 7890
allow-lan: true
mode: rule
log-level: debug
ipv6: false
#dns: #DNS 设置一般无需打开,如果你坚持想用,请确保你知道在做什么
#enable: true
#listen: 0.0.0.0:53
#ipv6: false
#default-nameserver:
@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="old_email@gmail.com"
CORRECT_NAME="luolei"
CORRECT_EMAIL="i@luolei.org"
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 / 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 / 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 / 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 / markdownvideo.html
Created June 7, 2014 06:17
在Markdown中添加视频方法
<video id="video" controls="" preload="none" poster="http://media.w3.org/2010/05/sintel/poster.png">
<source id="mp4" src="http://media.w3.org/2010/05/sintel/trailer.mp4" type="video/mp4">
<source id="webm" src="http://media.w3.org/2010/05/sintel/trailer.webm" type="video/webm">
<source id="ogv" src="http://media.w3.org/2010/05/sintel/trailer.ogv" type="video/ogg">
<p>Your user agent does not support the HTML5 Video element.</p>
</video>
@foru17
foru17 / jsopenapp.js
Created December 23, 2014 09:13
通过js调用Android APP的方法
tryOpenQV: function(url) {
var targetOpenUrl = 'tenvideo2://?action=4';
var targetDownloadUrl = 'http://mcgi.v.qq.com/commdatav2?cmd=4&confid=107&platform=aphone';
if (!IsAndroid) {
targetDownloadUrl = 'https://itunes.apple.com/cn/app/id458318329?mt=8';
}
setTimeout(function() {
var startTime = (new Date).valueOf();
if (IsAndroid) {