Skip to content

Instantly share code, notes, and snippets.

View ergatea's full-sized avatar

Xiaoping Tang ergatea

View GitHub Profile
@ergatea
ergatea / sub paths
Last active December 10, 2015 17:18
迭代查找整个子目录,找出所有的子文档的路径
def get_sub_time_paths(folder, root_vpath):
""" 迭代查找整个子目录,找出所有的子文档的路径 """
result = []
for obj in folder.values(True, False):
dc = obj.metadata
if isinstance(obj, Folder):
result.extend(get_sub_time_paths(obj, root_vpath))
elif isinstance(obj, Page):
result.append((
@ergatea
ergatea / gist:4487615
Created January 8, 2013 20:26
Shadowsocks 启动脚本
Shadowsocks 启动脚本
# insserv -v -d /etc/init.d/shadowsocks
=====================
#!/bin/sh
### BEGIN INIT INFO
# Provides: shadowsocks
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
@ergatea
ergatea / via-ssh.sh
Created January 9, 2013 17:56 — forked from vitex/via-ssh.sh
#!/bin/sh
########################################################################
#
# Usage: via-ssh.sh [-v] [-d] [USER@]SERVER[:PORT]
#
# -v Provide verbose output.
# -d Send all UDP on the DNS port 53 to 127.0.0.1.
# USER User name to use for SSH; default is current user.
# SERVER Server to use for SSH.
@ergatea
ergatea / shadowsocks
Last active December 10, 2015 22:48
Shadowsocks 启动脚本
Shadowsocks 启动脚本
insserv -v -d /etc/init.d/shadowsocks
#!/bin/sh
### BEGIN INIT INFO
# Provides: shadowsocks
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop:
@ergatea
ergatea / com.tang.shadowsocks.plist
Created January 10, 2013 19:13
shadowsocks startup for osx
<?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>KeepAlive</key>
<true/>
<key>OnDemand</key>
<false/>
<key>Label</key>
<string>com.tang.shadowsocks.startup</string>
@ergatea
ergatea / tunnel.sh
Last active December 11, 2015 02:28
tunnel for iptables,redsocks
#!/bin/bash -x
if [ -z "$1" ]; then echo Argument needed. >&2; exit 1; fi
if [ -z "$(pidof redsocks)" ]; then echo Redsocks requied >&2; exit 2; fi
DEF_IF="$(/sbin/route -n |awk '/^0.0.0.0/{print $8}')"
if [ -z "$DEF_IF" ]; then echo Cannot get default interface >&2; exit 3; fi
echo "Starting tunnel to $1..."
@ergatea
ergatea / routes.py
Last active December 11, 2015 02:39
debian route 更新脚本
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import urllib
import math
import subprocess
def external_cmd(cmd):
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
[supervisord]
logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (log level;default info; others: debug,warn,trace)
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024)
@ergatea
ergatea / init.sh
Created January 19, 2013 15:58
Sublime Text SublimeCodeIntel plugin auto
#!/bin/bash
# This hook is run after a new virtualenv is activated.
# setup python interpretor and sitepackages
# for Sublime Text's SublimeCodeIntel plugin.
# codeintel looks in the root of any folder opened via `subl foldername`
# for project/.codeintel/config
# put the project directory
@ergatea
ergatea / zerowall.sh
Created January 20, 2013 14:02
shell gfwlist
#!/bin/bash
cat << EOF
/*
* Proxy Auto-Config file generated by autoproxy2pac
* Rule source: http://autoproxy-gfwlist.googlecode.com/svn/trunk/gfwlist.txt
* Last update: Sat, 16 Jun 2012 16:35:28 GMT
*/