Skip to content

Instantly share code, notes, and snippets.

Avatar

Zhou Hao upbit

View GitHub Profile
@upbit
upbit / pexpect_ssh.py
Last active Aug 29, 2015
python-pexpect demo
View pexpect_ssh.py
import pexpect # download from https://github.com/pexpect/pexpect
def remote_ssh_cmd(ip, cmd, user="root", passwd=""):
ssh = pexpect.spawn('ssh %s@%s "%s"' % (user, ip, cmd))
r = ''
try:
i = ssh.expect(['password: ', 'continue connecting (yes/no)?'])
if i == 0 :
ssh.sendline(passwd)
elif i == 1:
@upbit
upbit / hosts_to_dnsmasq.py
Created Aug 28, 2014
将hosts中的网站,转为dnsmasq的conf规则
View hosts_to_dnsmasq.py
# -*- coding: utf-8 -*-
HOSTS = """
# 将gfw hosts内容粘贴到这里
"""
BLACK_LIST = """com.co.jp
akamaihd.net
angrybirds.com
@upbit
upbit / update_imouto.host.sh
Last active Aug 29, 2015
MacOS用的imouto.host自动更新脚本
View update_imouto.host.sh
#!/bin/bash
IMOUTO_HOST="https://www.dropbox.com/sh/lw0ljk3sllmimpz/AAC-n6LmtWbdlKQRbdEa0QUoa/imouto.host.7z?dl=1"
# download hosts file
curl -L -o imouto.host.7z ${IMOUTO_HOST}
# unzip
./7za x imouto.host.7z imouto.host.txt
awk '{ if (NR==1) sub(/^\xef\xbb\xbf/,""); print }' imouto.host.txt > imouto.host.txt
View dumpObj.py
# -*- coding: utf-8 -*-
##
## dump object to string
##
# XXX - ''.join([(len(`chr(x)`)==3) and chr(x) or '.' for x in range(256)])
__vis_filter = """................................ !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[.]^_`abcdefghijklmnopqrstuvwxyz{|}~................................................................................................................................."""
def hexdump(buf, length=16):
"""form dpkt: Return a hexdump output string of the given buffer."""
@upbit
upbit / Makefile
Created Nov 21, 2014
Makefile for libCocoaHTTPServer.a
View Makefile
######################################
# Common Static library Makefile
######################################
TARGET := libCocoaHTTPServer.a
SRC_DIR := Core Core/Categories Core/Mime Core/Responses Extensions/WebDAV \
Vendor/CocoaAsyncSocket Vendor/CocoaLumberjack Vendor/CocoaLumberjack/Extensions
HEADER_DIR := include/
# > make clean && make && make headers
View gist:b025c6a4c907aa026194
GET /?qt=cen&b=12376380.95%2C3574010.31%3B12376380.95%2C3574010.31&l=12&ie=utf-8&oue=1&res=api&callback=BMap._rd._cbk50813 HTTP/1.1
Host: api.map.baidu.com
Connection: keep-alive
Accept: */*
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.111 Safari/537.36
Referer: http://api.map.baidu.com/lbsapi/getpoint/index.html
Accept-Encoding: gzip, deflate, sdch
Accept-Language: zh-CN,zh;q=0.8,en;q=0.6
Cookie: BAIDUPSID=B43CC9CA4D0E53EA8F712095BDAE5BB3; BDUSS=zl6MHBXYlZEZFRwSGlkallzeExVbENGQi1PcXFxbXdhNW05Yng2a01IcTlFLU5VQVFBQUFBJCQAAAAAAAAAAAEAAACK0zQHdXBiaXQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAL2Gu1S9hrtUV; BAIDUID=DE16C72A2F375E80190C332AC83BF0E0:SL=0:NR=10:FG=1; cflag=65279%3A2
@upbit
upbit / itnl_idev.sh
Last active Aug 29, 2015
expect and connect with itnl 2022 port
View itnl_idev.sh
#/bin/bash
killall itnl 2>&1 > /dev/null
itnl --tunnel &
expect -c "
set timeout 30
spawn ssh -p2022 root@127.0.0.1
expect {
\"*yes/no*\" {send \"yes\r\"; exp_continue}
@upbit
upbit / .gitconfig
Created Mar 18, 2015
GitHub config for China
View .gitconfig
[url "git@github.com:"]
# Always use GitHub SSH protocol to push.
# Allows use of git:// for public repositories with push access
#pushInsteadOf = git://github.com/
pushInsteadOf = https://github.com/
[url "https://github.com/"]
# Use HTTP for GitHub instead of git:// or git@
# Enable this in networks where git:// or git@ are blocked.
#insteadOf = git://github.com/
#insteadOf = git@github.com:
@upbit
upbit / SLNovel2Txt.md
Created Mar 30, 2015
转换空之文库(轻国阅读Android)sln文档格式为txt
View SLNovel2Txt.md

SLNovel2Txt

转换空之文库(轻国阅读Android)sln文档格式为txt Script to convert Sora.SLNovel to txt

  • 使用方法
  1. 安装Python并下载 slnovel_to_txt.py 到任意文件夹中
@upbit
upbit / lldb_debug.sh
Created Mar 30, 2015
lldb远程调试
View lldb_debug.sh
on iOS:
/Developer/usr/bin/debugserver *:1234 -a "RankingLog"
on Mac:
lldb
(lldb) platform select remote-ios
(lldb) process connect connect://192.168.1.100:1234
【lldb命令】