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 / disable_all_animation.sh
Created August 1, 2014 06:05
Disable all animations of OS X.
# opening and closing windows and popovers
defaults write -g NSAutomaticWindowAnimationsEnabled -bool false
# smooth scrolling
defaults write -g NSScrollAnimationEnabled -bool false
# showing and hiding sheets, resizing preference windows, zooming windows
# float 0 doesn't work
defaults write -g NSWindowResizeTime -float 0.001
@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 / doss.sh
Last active November 28, 2023 12:37
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 / 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"
@lexrus
lexrus / ss_startup.sh
Last active November 13, 2023 13:41
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 / RxTextFieldDelegateProxy.swift
Created February 14, 2018 03:33
RxSwift extension for textFieldShouldReturn of UITextFieldDelegate
//
// RxTextFieldDelegateProxy.swift
//
// Created by Lex Tang on 2/14/18.
// Copyright © 2018 Krunoslav Zaher. All rights reserved.
//
import RxSwift
import RxCocoa
@lexrus
lexrus / HD.txt
Last active July 20, 2023 08:11
All WWDC 2013 Session Videos URLs in https://developer.apple.com/wwdc/videos/ dumped with Chrome. You can download these videos **without** a Apple developer account by running the download.sh script. There is also a sample code downloader here: https://github.com/jfahrenkrug/WWDC-Downloader
http://devstreaming.apple.com/videos/wwdc/2013/710xfx3xn8197k4i9s2rvyb/710/710-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/202xdx2x47ezp1wein/202/202-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/200xdx2x35e1pxiinm/200/200-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/413xdx5x97itb5ek4yex3r7/413/413-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/612xax4xx65z1ervy5np1qb/612/612-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/221xex4xxohbllf4hblyngt/221/221-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/220xbx4xipaxfd1tggxuoib/220/220-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/711xcx4x8yuutk8sady6t9f/711/711-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/404xbx2xvp1eaaqonr8zokm/404/404-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/505xbx4xrgmhwby4oiwkrpp/505/505-HD.mov?dl=1
@lexrus
lexrus / auto-run.swift
Last active March 11, 2023 15:27 — forked from mikeash/auto-run.swift
把这个 swift 文件复制到 /usr/local/bin/ 下,chmod +x /usr/local/bin/auto-run.swift 。然后每次执行 auto-run.swift 都会检查是否需要重新编译,最后会执行编译后的 auto-run.swiftc。需要 Xcode 6.0+,亲测 bash 和 zsh 下可用,fish 下会报错。
/*/../usr/bin/true
source="$0"
compiled="$0"c
if [[ "$source" -nt "$compiled" ]]; then
DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer xcrun swiftc -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -g "$source" -o "$compiled" || exit
fi
"$compiled"
@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 }() }() }