Skip to content

Instantly share code, notes, and snippets.

View lexrus's full-sized avatar
🏠
Working from home

Lex Tang lexrus

🏠
Working from home
View GitHub Profile
@lexrus
lexrus / glm
Last active October 21, 2025 05:19
/usr/local/bin/glm
#!/bin/bash
export ANTHROPIC_AUTH_TOKEN=___REPLACE_ME_WITH_YOUR_ZAI_API_KEY___
export ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic
export API_TIMEOUT_MS=3000000
export ANTHROPIC_DEFAULT_HAIKU_MODEL=glm-4.5-air
export ANTHROPIC_DEFAULT_SONNET_MODEL=glm-4.6
export ANTHROPIC_DEFAULT_OPUS_MODEL=glm-4.6
$HOME/.claude/local/claude --dangerously-skip-permissions
@lexrus
lexrus / AI_007_prompt.en.txt
Last active November 3, 2025 08:58
AI 通宵干活 prompt
__This is the requirements section, please replace it yourself__
Above are the requirements, below are the decision-making requirements:
- I'm going to sleep now, all product and technical decisions are under your control, I'll come to review the results tomorrow morning
- I'll sleep for about 8 hours, so don't rush to produce results, take your time with all the details, don't save tokens, getting it right is most important
- When you encounter uncertainties, first check the documentation in context7, if still uncertain, search online
- Execute all subtasks in phases, run unit tests after each phase is completed, to avoid having to start over after completing everything only to find it doesn't work
- Don't get hung up on the UI part, try to use mainstream conventional approaches, I'll polish the details tomorrow, you just focus on getting the functionality working
@lexrus
lexrus / ss_startup.sh
Last active September 18, 2025 02:51
ss_startup.sh
#!/bin/sh
#
# This startup script initializes a Shadowsocks server in Debian 11.
# It's compatible with DigitalOcean, Linode and Vultr.
#
# Author: @lexrus https://github.com/lexrus
#
# Get $100 free credit for VPS with my referral links:
# DigitalOcean: https://m.do.co/c/3eb5cf371fc9
# Linode: https://www.linode.com/lp/refer/?r=9f144941e797d495a10c2841c3137ce1acde5f15
@lexrus
lexrus / Xcode_comment.swift
Created September 23, 2022 16:02
Alternative Swift comment blocks for Xcode
func pleaseRetweet() {
let isMocking = //* // <- please try remove the first slash
true
// */ false
print(isMocking)
//* // <- please try remove the first slash
print("不")
@lexrus
lexrus / self.swift
Created September 5, 2022 15:33
self.swift
import Foundation
class `Self` {
/// 我是谁,我从哪里来,我要到哪去
lazy var `self`: Self? = { [weak self] in
guard let self = self else { return { [weak self] in { [weak self] in { [weak self] in { [weak self] in { [weak self] in self }() }() }() }() }() }
guard let self = { [weak self] in self }() else { return { [weak self] in { [weak self] in { [weak self] in { [weak self] in self }() }() }() }() }
guard let self = { [weak self] in { [weak self] in self }() }() else { return { [weak self] in { [weak self] in { [weak self] in self }() }() }() }
guard let self = { [weak self] in { [weak self] in { [weak self] in self }() }() }() else { return { [weak self] in { [weak self] in self }() }() }
// Public domain - https://gist.github.com/nolanw/dff7cc5d5570b030d6ba385698348b7c
import Foundation
extension URLRequest {
/**
Configures the URL request for `multipart/form-data`. The request's `httpBody` is set, and a value is set for the HTTP header field `Content-Type`.
- Parameter parameters: The form data to set.
@lexrus
lexrus / doss.sh
Last active June 2, 2024 15:24
A tiny script to initialize a new Shadowsocks server in DigitalOcean.
#!/bin/bash
#
# This macOS bash script helps you initialize a new Shadowsocks server with doctl in seconds.
# Original author: lexrus https://github.com/lexrus
#
# You can get $100 free credit for create VPS in DigitalOcean with my referral link:
# https://m.do.co/c/3eb5cf371fc9
#
# Please intall and authorize doctl before running this script.
# https://github.com/digitalocean/doctl
@lexrus
lexrus / naive_cam.py
Created December 26, 2021 07:22
Record videos for every single minute. Minimum requirements: Raspberry Pi Zero W and 12GB free space.
import picamera
from time import sleep
import datetime as dt
camera = picamera.PiCamera(resolution=(1024, 640), framerate=15)
camera.start_preview()
sleep(2)
camera.annotate_background = picamera.Color('black')
camera.annotate_text = dt.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
@lexrus
lexrus / delete_all_imessage_conversations.applescript
Last active January 26, 2024 16:12
Delete all iMessage conversations. Compatible with macOS Monterey. Please check Reduce motion before launch this apple script.
# System Preferences -> Accessibility -> Display -> Reduce motion
tell application "Messages" to activate
tell application "Messages"
set chatCount to (count of chats)
end tell
tell application "System Events"
tell process "Messages"
@lexrus
lexrus / ForkWeeklyReport.sh
Last active November 28, 2023 09:58
Fork custom command which export weekly report of current git user.
cd $path
DATE=`date -v-6d +"%Y-%m-%d"`
AUTHOR=`git config user.name`
LOG=`git log --branches --pretty=format:"\n%ad: %s" --date=short --after=$DATE --author="$AUTHOR"`
CHANGES=`git log --branches --date=short --after=$DATE --author="$AUTHOR" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "本周贡献代码: +%s行, -%s行, 总行数: %s\n", add, subs, loc }' -`
WEEKSTART=`date -v"monday" +"%-m月%d"`
TODAY=`date +"%-m月%d"`
REPORT="【周报】$WEEKSTART ~ $TODAY \n\n$CHANGES\n$LOG\n"