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 / TODO & FIXME for Xcode
Last active December 17, 2015 00:19
Treat // TODO: and // FIXME: as warnings in Xcode.
KEYWORDS="TODO:|FIXME:|\?\?\?:|\!\!\!:"
find "${SRCROOT}" -type f \
\( \
-name "*.h" \
-or -name "*.m" \
-or -name "*.swift" \
\) \
-print0 \
| xargs -0 egrep --with-filename --line-number \
@lexrus
lexrus / constellationByNSDate.c
Created April 27, 2013 15:44
constellationByNSDate the hard way
char *constellationByNSDate(NSDate *date) {
static char *constellations[13] = {"Capricorn","Aquarius","Pisces","Aries","Taurus","Gemini","Cancer","Leo","Virgo","Libra","Scorpio","Sagittarius","Capricorn"};
static unsigned short constellationSeperates[12] = {20,19,21,21,21,22,23,23,23,24,22,22};
unsigned short dateStr[5];
NSLocale *CNLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_Hans_CN"];
[[date descriptionWithLocale:CNLocale] getCharacters:(unichar*)dateStr range:(NSRange){5, 5}];
unsigned short month = (dateStr[0] - '0') * 10 + (dateStr[1] - '0') - 1;
unsigned short day = (dateStr[3] - '0') * 10 + (dateStr[4] - '0');
return constellations[month + (day < constellationSeperates[month] ? 0 : 1)];
}
@lexrus
lexrus / dnsmasq_autoddvpn.conf
Last active December 16, 2015 03:49
My DNSMasq Config For AutoDDVPN
dhcp-option=252,http://10.0.0.100:7777/pac
address=/r/10.0.0.1
address=/z/10.0.0.100
expand-hosts
cache-size=10000
server=/amazonaws.com/8.8.4.4
server=/appspot.com/8.8.4.4
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.lextang.shadowsocks</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/node</string>
<string>/Users/Lex/Dropbox/shadowsocks-nodejs/local.js</string>
@lexrus
lexrus / vim.rb
Last active December 14, 2015 01:59 — forked from uasi/vim.rb
require 'formula'
class Vim < Formula
homepage 'http://www.vim.org/'
url 'ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2'
head 'https://vim.googlecode.com/hg/'
sha256 '5c5d5d6e07f1bbc49b6fe3906ff8a7e39b049928b68195b38e3e3d347100221d'
version '7.3.682'
def features; %w(tiny small normal big huge) end
@lexrus
lexrus / muzix.html
Created December 24, 2012 08:22
My XLST table sorting demo. Required IE 5.0+
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>LeXRus' CodeX | XMLDOM | Transform a XML file with XSLT &amp; XMLDOM</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script xmlns:query="http://query@LexTang.com/namespace/"><!--//XR.Web.Request.Query["expr.(string)"]
var from,num,select,order,sort;
from=parseInt(window.location.href.replace(/.*\?.*from=(\d+)\&?.*/i,"$1")).toString();
num=parseInt(window.location.href.replace(/.*\?.*num=(\d+)\&?.*/i,"$1")).toString();
select=window.location.href.replace(/.*\?.*select=([ \w@=\(\)\[\]\.\*\\\/]+).*/i,"$1").toString();//the Filter of strXPath
@lexrus
lexrus / FREEDOM.wsf
Created December 24, 2012 06:29
有些变态的公司不让员工安装一些 Windows 常用软件~ 这个脚本帮助你骗过运维的远程注册表扫描程序,“非法”安装一些应用。运行后会在桌面上生成已经安装的软件列表,选择哪些要假装删除,然后运行桌面上的这个脚本,运维就扫描不到了。
<job id="TheShawshankHammer">
<script language="JScript" id="env">
var fso = new ActiveXObject("Scripting.FileSystemObject");
var WshShell = WScript.CreateObject("WScript.Shell");
var deskPath = WshShell.SpecialFolders("Desktop");
var arg = WScript.Arguments;
var scriptPath = WScript.ScriptFullName.split('\\').slice(0, -1).join('\\') + '\\';
</script>
<script language="JScript" id="scan">
@lexrus
lexrus / build.py
Last active October 13, 2015 07:08 — forked from rjyo/build.py
OTA builder
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import json
import getopt
import urllib2
import commands
import string
@lexrus
lexrus / appstore.sh
Created October 22, 2012 10:39
Switch keychains for InHouse & AppStore while both certifications have the same name
#!/bin/bash
export MM_KEYCHAIN=(~/Dropbox/mm.keychain)
export MM_INHOUSE_KEYCHAIN=(~/Dropbox/mm_inhouse.keychain)
cp "$MM_INHOUSE_KEYCHAIN" "$MM_INHOUSE_KEYCHAIN.ori"
security delete-keychain "$MM_INHOUSE_KEYCHAIN"
if [[ -f "$MM_KEYCHAIN.ori" ]]; then
@lexrus
lexrus / .gitignore
Created April 10, 2012 05:13
.gitignore
# Exclude the Podspecs
Pods/*
Podfile.lock
# Exclude any PSD/AI source
#*.psd
#*.ai
# Exclude generated files
VersionX-revision.h