Skip to content

Instantly share code, notes, and snippets.

View ninehills's full-sized avatar

Tao Yang ninehills

View GitHub Profile
@ninehills
ninehills / 360buy.rb
Created November 6, 2012 17:32 — forked from mimosz/.gitignore
京东商品价格解析
# -*- encoding: utf-8 -*-
require 'mini_magick'
require 'rtesseract'
require 'nokogiri'
require 'nestful'
require 'csv'
require 'pp'
class Buy360
def initialize(url='')
@ninehills
ninehills / colors.sh
Created October 16, 2012 03:01
echo terminal color code
#!/bin/bash
#
# This file echoes a bunch of color codes to the
# terminal to demonstrate what's available. Each
# line is the color code of one forground color,
# out of 17 (default + 16 escapes), followed by a
# test use of that color on all nine background
# colors (default + 8 escapes).
#
@ninehills
ninehills / fabric.plugin.zsh
Created October 14, 2012 08:48 — forked from AdrienLemaire/fabric.plugin.zsh
zsh-completion for Fabric in Oh-my-zsh
#compdef fab
_targets() {
_describe -t commands "fabric targets" target_list
}
output_levels=(
'status: Status messages, i.e. noting when Fabric is done running, if the user used a keyboard interrupt, or when servers are disconnected from. These messages are almost always relevant and rarely verbose.'
'aborts: Abort messages. Like status messages, these should really only be turned off when using Fabric as a library, and possibly not even then. Note that even if this output group is turned off, aborts will still occur – there just won’t be any output about why Fabric aborted!'
'warnings: Warning messages. These are often turned off when one expects a given operation to fail, such as when using grep to test existence of text in a file. If paired with setting env.warn_only to True, this can result in fully silent warnings when remote programs fail. As with aborts, this setting does not control actual warning behavior, only whether warning messages are printed or hidden.'
@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
@ninehills
ninehills / baidu_fanyi.py
Created October 5, 2012 13:23 — forked from binux/baidu_fanyi.py
百度翻译api
# -*- encoding: utf-8 -*-
# author: binux<[email protected]>
import re
import time
import json
import requests
class BaiduFanYiAPI(object):
"""
@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 / sh_window.sh
Created September 13, 2012 13:25
并行执行文件中的命令的shell脚本
#!/bin/sh
# Usage: $0 <max_cmd> <cmdfile/stdin>
# max_cmd: 同时执行的命令数
# cmdfile/stdin: 标准输入或者命令文件,一条命令一行
set -u
max_cmd=$1
cmd_file=${2:--}
cur=0
line=1
for ((;;)) do
@ninehills
ninehills / .screenrc
Created September 5, 2012 05:56
screenrc example
#close the startup message
startup_message off
term linux
setenv LC_CTYPE zh_CN.GBK
setenv TERM linux
#set a biger buffer
#defscrollback 1024
defscrollback 2048
caption always "%{=u .r} %-w%<%{=ub .Y}%n %t%{=u .r}%+w "
@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 / 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