Skip to content

Instantly share code, notes, and snippets.

@tianying484
tianying484 / xcrun_openurl
Last active August 29, 2015 14:26 — forked from sodabiscuit/xcrun_openurl
Open Some Application Scheme URL in the Booted iOS Simulator.
#!/bin/sh
xcrun simctl list | grep 'Booted' | awk -F "[()]" '{ for (i=2; i<NF-1; i+=2) print $i }' | xargs -J {} xcrun simctl openurl '{}' $1
#!/bin/bash
XCODE_UUID=$(defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID)
PLUGIN_PATH="$HOME/Library/Application Support/Developer/Shared/Xcode/Plug-ins"
for plugin in "$PLUGIN_PATH"/*.xcplugin ; do
defaults write "${plugin}"/Contents/Info DVTPlugInCompatibilityUUIDs -array-add $XCODE_UUID
done
@tianying484
tianying484 / install-ljitrocks.sh
Last active August 29, 2015 14:26 — forked from jnwhiteh/install-ljitrocks.sh
Install luajit+luarocks in sandboxed environment
#!/usr/bin/env bash
set -e
die() {
echo "$1";
exit 1;
}
# Fetch and install LuaJIT/LuaRocks into the local directory
@tianying484
tianying484 / openconnect.md
Last active August 29, 2015 14:27 — forked from moklett/openconnect.md
OpenConnect VPN on Mac OS X

Unfortunately, the Cisco AnyConnect client for Mac conflicts with Pow. And by "conflicts", I mean it causes a grey-screen-of-death kernel panic anytime you connect to the VPN and Pow is installed.

As an alternative, there is OpenConnect, a command-line client for Cisco's AnyConnect SSL VPN.

Here's how to get it set up on Mac OS X:

  1. OpenConnect can be installed via homebrew:

     brew update
    

brew install openconnect

@tianying484
tianying484 / cert-client.sh
Last active August 26, 2015 11:23 — forked from bao3/cert-client.sh
这是几个用来签发证书的脚本,请注意这需要你安装了gnutls才可以,主要当时是为了ocserv而写,纯偷懒。基本上,你只要用 ./cert-client.sh you-user-name 这种格式,就可以自动生成 you-user-name-key.pem/ your-user-name-cert.pem /your-user-name.p12
#! /bin/sh
#! /usr/bin/expect -f
certtool --generate-privkey --outfile $1-key.pem
sed -i "1ccn = "${1}"" client.tmpl
sed -i "3cemail = ${1}@abc.org" client.tmpl
certtool --generate-certificate --load-privkey $1-key.pem --load-ca-certificate ca-cert.pem --load-ca-privkey ca-key.pem --template client.tmpl --outfile $1-cert.pem
openssl pkcs12 -export -inkey $1-key.pem -in $1-cert.pem -name "$1 VPN Client Cert" -certfile ca-cert.pem -out $1.cert.p12
@tianying484
tianying484 / profile.xml
Last active August 26, 2015 11:23 — forked from bao3/profile.xml
用于 ocserv的profile.xml,会自动被思科客户端读取。这个配置文件有两个服务地址( VPN Server和 Full VPN Server),前者是区分路由模式的,后者是同一台服务不同端口的完全走VPN的模式。你可以在此基础上加入休眠后自动恢复项等等,但是请切记,一旦你改错了这个文档就会造成服务器不认证书或者客户端干脆禁止你连接。救赎的方法。。。。可耻的匿了。
<?xml version="1.0" encoding="UTF-8"?>
<AnyConnectProfile xmlns="http://schemas.xmlsoap.org/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.xmlsoap.org/encoding/ AnyConnectProfile.xsd">
<ClientInitialization>
<UseStartBeforeLogon UserControllable="false">false</UseStartBeforeLogon>
<StrictCertificateTrust>false</StrictCertificateTrust>
<RestrictPreferenceCaching>false</RestrictPreferenceCaching>
<RestrictTunnelProtocols>IPSec</RestrictTunnelProtocols>
<BypassDownloader>true</BypassDownloader>
<WindowsVPNEstablishment>AllowRemoteUsers</WindowsVPNEstablishment>
@tianying484
tianying484 / ocserv.route.conf
Last active August 26, 2015 11:23
cisco anyconnect ocserv.conf的路由选择,使用粗略路由。请注意,新的ocserv已经支持 no route命令,因此你可以指定中国的路由不经过vpn咯(这次没有展示,下次不上)
route = 23.0.0.0/255.0.0.0
route=31.13.0.0/255.255.0.0
route = 54.0.0.0/255.0.0.0
route=64.0.0.0/255.0.0.0
route=68.0.0.0/255.248.0.0
route=69.0.0.0/255.0.0.0
route = 74.0.0.0/255.0.0.0
route = 93.0.0.0/255.0.0.0
route = 96.0.0.0/255.0.0.0
#route = 100.0.0.0/248.0.0.0
#route = 8.0.0.0/252.0.0.0
#route = 16.0.0.0/248.0.0.0
# 23.239 ip.cn (linnode),so sad
# 23.0 instagram & facebook CDN.If You Do Not Use ip.cn,
# replace the two line below with :
route = 23.0.0.0/255.0.0.0
#route = 23.0.0.0/255.128.0.0
#route = 23.174.0.0/255.192.0.0
route = 31.13.0.0/255.255.0.0
#route = 50.0.0.0/255.0.0.0
@tianying484
tianying484 / ss-redir 透明代理.md
Last active September 14, 2015 03:41 — forked from wen-long/ss-redir 透明代理.md
ss-redir 透明代理.md

##ss-redir 的 iptables 配置(透明代理)

透明代理指对客户端透明,客户端不需要进行任何设置就使用了网管设置的代理规则

创建 /etc/ss-redir.json 本地监听 7777 运行ss-redir -v -c /etc/ss-redir.json

iptables -t nat -N SHADOWSOCKS
# 在 nat 表中创建新链
iptables -t nat -A SHADOWSOCKS -p tcp --dport 23596 -j RETURN
# 23596 是 ss 代理服务器的端口,即远程 shadowsocks 服务器提供服务的端口,如果你有多个 ip 可用,但端口一致,就设置这个
@tianying484
tianying484 / vpn-script-osx
Last active September 17, 2015 03:48
vpnc-script for OS X
#!/bin/sh
#
# Originally part of vpnc source code:
# © 2005-2012 Maurice Massar, Jörg Mayer, Antonio Borneo et al.
# © 2009-2012 David Woodhouse <dwmw2@infradead.org>
#
# This program 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 2 of the License, or
# (at your option) any later version.