Skip to content

Instantly share code, notes, and snippets.

View paicha's full-sized avatar
🎯
Focusing

赖嘉伟Gary paicha

🎯
Focusing
View GitHub Profile
@paicha
paicha / openai-proxy.js
Last active July 2, 2024 07:06
Create an OpenAI API proxy using only 10 lines of code on Cloudflare Worker.
async function handleRequest(request) {
const url = new URL(request.url)
url.host = "api.openai.com"
return fetch(url, { headers: request.headers, method: request.method, body: request.body })
}
addEventListener("fetch", (event) => {
event.respondWith(handleRequest(event.request))
})
@paicha
paicha / translate-srt.py
Created April 3, 2023 08:57 — forked from sunlei/translate-srt.py
使用 ChatGPT Few-shot 翻译 SRT 字幕
import json
import os
import requests
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
OPENAI_BASE_URL = "https://api.openai.com/v1/chat/completions"
def translator(srt):
@paicha
paicha / flex
Created May 21, 2016 06:14 — forked from kmokidd/flex
Adapt android 2.1+ WebView, thanks https://github.com/stevenbenisek/compass-flexbox
/* display:flex; */
.flex { display: -webkit-box; display: -moz-box; display: -ms-flexbox; display: -webkit-flex; display: flex; }
/* row reverse */
.flex.flex--reverse { -webkit-box-orient: horizontal; -moz-box-orient: horizontal; -webkit-box-direction: reverse; -moz-box-direction: reverse; -webkit-flex-direction: row-reverse; -ms-flex-direction: row-reverse; flex-direction: row-reverse; }
/* column */
.flex--clo { -webkit-box-orient: vertical; -moz-box-orient: vertical; -webkit-box-direction: normal; -moz-box-direction: normal; -webkit-flex-direction: column; -ms-flex-direction: column; flex-direction: column; }
/* column reverse*/
.flex--col.flex--reverse { -webkit-box-orient: vertical; -moz-box-orient: vertical; -webkit-box-direction: reverse; -moz-box-direction: reverse; -webkit-flex-direction: column-reverse; -ms-flex-direction: column-reverse; flex-direction: column-reverse; }
/* 子元素之间间距 */
.flex--justify-content--space-between { -webkit-box-pack: justify; -moz-box-pack: justify; -ms-flex-pack: justify
@paicha
paicha / GFW_ADBlock.conf
Created February 21, 2016 12:22 — forked from bao3/GFW_ADBlock.conf
由于 Surge for ios 的条目数量不能过大,导致手机内存不足,所以将 GFW 和 广告过滤集中后进行了人工挑选,压缩在 1万条左右,你仍然可以自己添加大约 900条规则,理论上足够你长久使用了,配置文件默认是直连,方便普通国内用户使用。配置文件中,我自己调整过的、有可能有误伤的条目我都放在了前面,方便你自己修改,不过运行自 2016/01 ~ 2016/02 我自己日常没有遇到问题。有误伤不要怕,打开软件可以自己调试添加。
[General]
#我的注释都是 # 开头,所以如果你用 vim,直接 :g/^#/d 就可以一次性清除所有注释
#开头这段skip包含以下几个目的:1,私网IP跳过,提高内网性能;2,苹果的一些服务跳过,比如公共热点wifi要先测试captive.apple.com。可解决很多内网的 TCP毛病,例如 kodi remote软件无法遥控
skip-proxy = 10.0.0.0/8,169.254/16,172.16.0.0/12,192.168.0.0/16,224.0.0.0/4, localhost, *.local,api.smoot.apple.com,configuration.apple.com,xp.apple.com,smp-device-content.apple.com,guzzoni.apple.com,captive.apple.com,*.ess.apple.com,*.push.apple.com,*.push-apple.com.akadns.net
#下面这一段则是完全跳过 Surge,最重要的一个是让 UDP包可以传输,解决很多内网毛病,例如DLNA,NFS或者btsync等组播类/UDP类应用
bypass-tun = 10.0.0.0/8, 169.254.0.0/16, 172.16.0.0/12, 192.168.0.0/16, 224.0.0.0/4, 0.0.0.0/8, 1.0.0.0/9, 1.160.0.0/11, 1.192.0.0/11, 10.0.0.0/8, 14.0.0.0/11, 14.96.0.0/11, 14.128.0.0/11, 14.192.0.0/11, 27.0.0.0/10, 27.96.0.0/11, 27.128.0.0/9, 36.0.0.0/10, 36.96.0.0/11, 36.128.0.0/9, 39.0.0.0/11, 39.64.0.0/10, 39.128.0.0/10, 42.0.0.0/8, 43.224.0.0/11, 45.64.0.0/10, 47.64.0.0/10, 49.0.0.0/9, 49.128.0.0/11, 49.192.0.0/10, 54.192.0.0/11, 58.0.0.0/9, 58.128.0.0/11, 58.192.0.0/10, 59.32.0.0/11, 5
@paicha
paicha / surge_main.conf
Created October 26, 2015 03:57 — forked from jason5ng32/surge.conf
Surge Configs
// DON'T FORGET TO IMPORT proxy.conf TOO
[General]
loglevel = notify
skip-proxy = 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12,127.0.0.0/24
bypass-tun = 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12,127.0.0.0/24
// DNS OVERRIDE, REMOVE # IF YOU NEED
# dns-server = 223.6.6.6,223.5.5.5,114.114.114.114,114.114.115.115
@paicha
paicha / tmux-cheatsheet.markdown
Created October 24, 2015 10:20 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname