Skip to content

Instantly share code, notes, and snippets.

View ninehills's full-sized avatar

Tao Yang ninehills

View GitHub Profile
@ninehills
ninehills / sshgfw
Created July 30, 2010 05:03 — forked from fuckgfw/sshgfw
linux下ssh翻墙断线重连
#!/usr/bin/expect
set timeout 60
spawn /usr/bin/ssh -D 7070 -g username@yourserver.com
#这里的 username 为你自己的用户名,yourserver.com 为你自己的服务器域名或ip
expect {
"password:" {
send "password\r"
#将第二个 password 改为你自己的密码
}
#!/bin/sh
xmodmap - <<EOF
remove Lock = Caps_Lock
keysym Escape = Caps_Lock
keysym Caps_Lock = Escape
add Lock = Caps_Lock
EOF
upstream ghs {
ip_hash;
server ghs.google.com;
server 72.14.203.121;
server 72.14.207.121;
server 74.125.43.121;
server 74.125.47.121;
server 74.125.53.121;
server 74.125.77.121;
server 74.125.93.121;
@ninehills
ninehills / 12306.user.js
Created January 7, 2012 08:24 — forked from quietlynn/12306.user.js
12306 Auto Query => A javascript snippet to help you book ticket
/*
12306 Auto Query => A javascript snippet to help you book tickets online.
Copyright (C) 2011 Jingqin Lynn
Includes jQuery
Copyright 2011, John Resig
Dual licensed under the MIT or GPL Version 2 licenses.
http://jquery.org/license
Includes Sizzle.js
@ninehills
ninehills / supervisord.sh
Created April 28, 2012 02:11 — forked from danmackinlay/supervisord.sh
an init.d script for supervisord
#! /bin/sh
### BEGIN INIT INFO
# Provides: supervisord
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
@ninehills
ninehills / new_bashrc.sh
Created August 11, 2012 10:09 — forked from josephwecker/new_bashrc.sh
Replace .bashrc, .bash_profile, .profile, etc. with something much more clean, consistent, and meaningful.
#!/bin/bash
# License: Public Domain.
# Author: Joseph Wecker, 2012
#
# Are you tired of trying to remember what .bashrc does vs .bash_profile vs .profile?
# Are you tired of trying to remember how darwin/mac-osx treat them differently from linux?
# Are you tired of not having your ~/.bash* stuff work the way you expect?
#
# Symlink all of the following to this file:
# * ~/.bashrc
@ninehills
ninehills / check_google_ip.py
Created August 25, 2012 10:37
check_google_ip
#!/usr/bin/env python
# coding:utf-8
import sys
import os
import re
import gevent
import gevent.monkey
import gevent.timeout
gevent.monkey.patch_all()
@ninehills
ninehills / dns_resolve.py
Created October 3, 2012 18:34
dns_resolve
import os
import re
import socket
import struct
def dns_resolve(host, dnsserver):
assert isinstance(host, basestring) and isinstance(dnsserver, basestring)
index = os.urandom(2)
hoststr = ''.join(chr(len(x))+x for x in host.split('.'))
data = '%s\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00%s\x00\x00\x01\x00\x01' % (index, hoststr)
@ninehills
ninehills / baidu_fanyi.py
Created October 5, 2012 13:23 — forked from binux/baidu_fanyi.py
百度翻译api
# -*- encoding: utf-8 -*-
# author: binux<17175297.hk@gmail.com>
import re
import time
import json
import requests
class BaiduFanYiAPI(object):
"""
@ninehills
ninehills / gist:3883375
Created October 13, 2012 05:39 — forked from exhuma/gist:2136677
Bash completion for fabric
#
# Bash completion for fabric
#
function _fab_complete() {
local cur
if [[ -f "fabfile.py" || -d "fabfile" ]]; then