- NodeBox - a nice lib to create images of graph networks
- Python Image Library
- BeautfulSoup - HTML parser
- mechanize - automated web browsing
| [alias] | |
| lg1 = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all | |
| lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all | |
| lg = !"git lg1" |
| First, clone a remote Git repository and cd into it: | |
| $ git clone git://example.com/myproject | |
| $ cd myproject | |
| Next, look at the local branches in your repository: | |
| $ git branch | |
| * master | |
| But there are other branches hiding in your repository! You can see these using the -a flag: | |
| $ git branch -a |
| _foo() | |
| { | |
| local cur prev opts | |
| COMPREPLY=() | |
| cur="${COMP_WORDS[COMP_CWORD]}" | |
| prev="${COMP_WORDS[COMP_CWORD-1]}" | |
| opts="--help --verbose --version" | |
| if [[ ${cur} == -* ]] ; then | |
| COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) |
| #!/usr/bin/env python | |
| # Describe classes, methods and functions in a module. | |
| # Works with user-defined modules, all Python library | |
| # modules, including built-in modules. | |
| import inspect | |
| import os, sys | |
| INDENT=0 |
| def addItem(theIndex, word, pagenumber): | |
| theIndex.setdefault(word, [ ]).append(pagenumber) | |
| #the above method equals to the following | |
| def addItem(theIndex, word, pagenumber): | |
| if word in theIndex: | |
| theIndex[word].append(pagenumber) | |
| else: | |
| theIndex[word] = [pagenumber] |
| arr = [[1,2,3],[4,5,6],[7,8,9],[10,11,12]] | |
| print [[r[col] for r in arr] for col in rage(len(arr[0]))] | |
| #another simple but confuding way | |
| print map(list, zip(*arr)) |
| class IOManipulator(object): | |
| def __init__(self, function=None): | |
| self.function = function | |
| def do(self, output): | |
| self.function(output) | |
| def do_endl(stream): | |
| stream.output.write('\n') | |
| stream.output.flush() |
| def words_of_file(thefilepath, line_to_words=str.split) | |
| the_file = open(thefilepath) | |
| for line in the_file: | |
| for word in line_to_words(line): | |
| yield word | |
| the_file.close() | |
| for world in worlds_of_file(thefilepath): | |
| dosomethingwith(word) |
| import string | |
| def translator(frm='', to='', delete='', keep=None): | |
| if len(to) == 1: | |
| to = to * len(frm) | |
| trans = string.maketrans(frm, to) | |
| if keep is not None: | |
| allchars = string.maketrans('', '') | |
| delete = allchars.translate(allchars, keep.translate(allchars,delete)) | |
| def translate(s): |