Skip to content

Instantly share code, notes, and snippets.

View tshu-w's full-sized avatar
🤯
Exploring

Tianshu Wang tshu-w

🤯
Exploring
View GitHub Profile
@tshu-w
tshu-w / image_crawler.py
Created June 16, 2023 08:27
Image Crawler for WDC product images.
#!/usr/bin/env python
import itertools
import json
import logging
import os
import re
import shutil
import sys
import zlib
@tshu-w
tshu-w / .MitM4OpenAI.md
Last active March 12, 2024 10:43
OpenAI API 全局请求重定向

使用 MitM 加代理工具实现 OpenAI API 请求全局重定向

Surge (macOS Only)

  1. 在 Surge 中安装 CA 证书并使用 AIProxy.sgmodule 模块。

Clash + MitMProxy

  1. 安装 MitmProxy 以及 CA 证书
  2. 后台运行 MitMProxy 并设定重定向规则,例如:screen mitmproxy --map-remote '|//api.openai.com/|//api.aiproxy.io/' -k
  3. 在 Clash 中添加配置,将 api.openai.com 的请求走 HTTP 8080 端口代理,并开启增强模式
@tshu-w
tshu-w / backup-overleaf.sh
Created December 30, 2022 13:43
Backup Community Edition Overleaf Project
#!/usr/bin/env sh
HOST="overleaf.cipsup.cn"
PROJECT_ID="627220cc14ecd4008b9ae727"
DIRECTORY="$HOME/Library/CloudStorage/OneDrive-Personal/Backups/Overleaf/$PROJECT_ID"
OUTPUT="main_`date +"%Y-%m-%dT%H%M"`.zip"
COOKIE="$OVERLEAF_COOKIE"
curl "http://$HOST/project/$PROJECT_ID/download/zip" \
-H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Safari/605.1.15" \
@tshu-w
tshu-w / EmacsClient.scpt
Created August 8, 2022 08:16
EmacsClient.app on macOS
on open location address
if {address starts with "org-protocol"} then
do shell script "zsh -c 'ec \"" & address & "\"'"
else
do shell script "zsh -c 'ec --eval '\"'\"'(browse-url \"" & address & "\")'\"'\"''"
end if
end open location
on open filenames
set args to ""
@tshu-w
tshu-w / config.js
Last active June 7, 2022 05:37
Surfingkeys Settings
settings.scrollStepSize = 100
settings.focusAfterClosed = "last"
settings.hintAlign = "left"
@tshu-w
tshu-w / arXiv_titlatorizer.js
Last active January 16, 2021 08:15
arXiv title fixer
// ==UserScript==
// @name Arxiv titlatorizer
// @namespace Titlatorizer
// @version 0.1
// @description Set correct tab <title> on arXiv pages.
// @author Tianshu Wang
// @match https://arxiv.org/pdf/*
// @grant GM_xmlhttpRequest
// ==/UserScript==
//
@tshu-w
tshu-w / lang-org.el
Last active January 12, 2021 13:34
Emacs Org Capture or Agenda in a new Frame and quit after finishing.
;;; System interaction function
(defun supress-frame-splitting (&rest r)
(let ((frame-name (frame-parameter nil 'name)))
(when (or (equal "capture" frame-name)
(equal "agenda" frame-name))
(delete-other-windows))))
(defun org-capture-finalize@after (&rest r)
(when (equal "l" (plist-get org-capture-plist :key))
(run-at-time 0 nil #'osx-switch-back-to-previous-application))
@tshu-w
tshu-w / huxiu.js
Last active October 22, 2019 13:34
Redirect m.huxiu.com to www.huxiu.com by Tampermokey
// ==UserScript==
// @name Redirect Huxiu Mobile Link
// @namespace https://gist.github.com/TshuW/136f461b93dc258f6322b496fd656717
// @version 0.1
// @description Redirect m.huxiu.com to www.huxiu.com
// @author Tshu Wang
// @match m.huxiu.com/article/*
// @grant none
// ==/UserScript==
@tshu-w
tshu-w / SpaceFn.json
Last active May 10, 2024 05:50
Karabiner Elements config to simulate SpaceLauncher (https://ke-complex-modifications.pqrs.org/?q=spacefn%20plus)
{
"title": "SpaceFN",
"rules": [
{
"description": "SpaceFN: Space enables SpaceFN mode (see: https://geekhack.org/index.php?topic=51069.0 & https://spacelauncherapp.com)",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "spacebar"
@tshu-w
tshu-w / stdc++.h
Created January 22, 2018 09:12
Linux GCC 4.8.0 /bits/stdc++.h header definition.
// C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.