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 / svg2png.sh
Created March 31, 2015 06:39
Convert svg files to png.
for f in *.svg; do cairosvg $f -f png -o $f.png; done
@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 / gems.sh
Last active January 18, 2019 09:13
Xcoder 常用工具一键安装
#!/bin/bash
# 解析 xcodeproj 的 Ruby 库 - https://github.com/CocoaPods/Xcodeproj
gem install --no-ri 'xcodeproj'
# xcoderbuild 的 Ruby 封装 - https://github.com/rayh/xcoder
gem install --no-ri 'xcoder'
# Xcode 工程配置工具 - https://github.com/thoughtbot/liftoff
gem install --no-ri 'liftoff'
@lexrus
lexrus / com.shadowsocks.chinadns.plist
Last active May 31, 2018 18:39
LaunchCtl plist of ChinaDNS for El Capitan.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.shadowsocks.chinadns</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/chinadns</string>
<string>-c</string>
@lexrus
lexrus / LTLog.h
Last active February 21, 2016 19:56
My DDLog config
//
// LTLog.h
//
// Created by Lex on 6/29/14.
// Copyright (c) 2014 LexTang.com. All rights reserved.
// https://gist.github.com/lexrus/8c6414e7c0177e9e66ea
//
#import <Foundation/Foundation.h>
@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 / chinadns.conf
Created July 23, 2014 02:18
supervisor config for chinadns
[program:chinadns]
command=/usr/local/bin/chinadns
numprocs=1
autostart=true
autorestart=unexpected
startsecs=2
startretries=3
stdout_logfile=/var/log/chinadns.log
stdout_logfile_maxbytes=2MB
stderr_logfile=/var/log/chinadns.error.log
@lexrus
lexrus / WTF_YOU_MUST_UPGRADE_COCOAPODS.sh
Created May 28, 2014 10:34
Force your little brother to upgrade CocoaPods.
NEW_VER="0.33.1"
POD_VER=`pod --version 2>/dev/null`|| POD_VER=`~/.rbenv/shims/pod --version 2>/dev/null`
if [[ "$POD_VER" != *$NEW_VER ]]; then
echo "error: WTF! You MUST upgrade cocoapods!!!"
exit 1
fi
@lexrus
lexrus / rmsenseless.sh
Last active June 12, 2022 08:41
Remove senseless files from my NAS
#!/bin/bash
find . -name '*.DS_Store' -type f -delete;
find . -name 'Thumbs.db' -type f -delete;
find . -name '*.swp' -type f -delete;
find . -name '*.AppleDouble' -exec rm -rf {} \;
find . -name ".AppleDouble" -print0 | xargs -0 rm -rf;
find . -name ".TemporaryItems" -print0 | xargs -0 rm -rf;
find . -name ".Trashes" -print0 | xargs -0 rm -rf;
find . -name ".afpdeleted*" -print0 | xargs -0 rm -rf;
@lexrus
lexrus / dump_edit_page_url_list_in_ios_dev_center.js
Created January 2, 2014 15:43
Dump edit page url list in iOS Dev Center
$.post(profileDataURL, function(d){d.provisioningProfiles.map(function(o){console.log('https://developer.apple.com/account/ios/profile/profileEdit.action?type=&provisioningProfileId='+o.provisioningProfileId)})});