This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# coding: utf-8 | |
import logging | |
from datetime import datetime | |
import time | |
if __name__ == '__main__': | |
logging.basicConfig(level = logging.DEBUG, | |
format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# coding: utf-8 | |
"""这个脚本实际上是在源码根目录下,递归查找以 .git 结尾的目录,然后做 commit-msg | |
的软链接,commit-msg 是产生 Changed-Id 的一个 hook 脚本 | |
""" | |
import os | |
import itertools | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://python3wos.appspot.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
try: | |
import urllib.request | |
except ImportError: | |
import urllib | |
urllib.request = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo(object): | |
_instance = None | |
def __new__(cls, *args, **kwargs): | |
if cls._instance is None: | |
cls._instance = super(Foo, cls).__new__(cls, *args, **kwargs) | |
return cls._instance | |
class Brog(object): | |
__shared_state = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for name in $(sed -n 's/.* name="\([a-z|A-Z|_]*\)">.*/\1/p' $1) | |
do | |
if ! grep -q $name $2; then | |
sed -i "/$name/ d" $1 | |
fi | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local return_code="%(?..%{$fg[red]%}%? %{$reset_color%})" | |
PROMPT='%{$fg[green]%}%c \ | |
$(git_prompt_info)\ | |
%{$fg[red]%}%(!.#.->)%{$reset_color%} ' | |
PROMPT2='%{$fg[red]%}\ %{$reset_color%}' | |
RPS1='%{$reset_color%} ${return_code} ' | |
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}:: %{$fg[yellow]%}(" | |
ZSH_THEME_GIT_PROMPT_SUFFIX=")%{$reset_color%} " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import warnings | |
def deprecated(func): | |
"""This is a decorator which can be used to mark functions | |
as deprecated. It will result in a warning being emmitted | |
when the function is used.""" | |
def new_func(*args, **kwargs): | |
#warnings.warn("Call to deprecated function %s." % func.__name__, | |
# category=UserWarning, stacklevel=2) | |
warnings.warn("Call to deprecated function %s." % func.__name__, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Python闭包详解 | |
1 快速预览 | |
以下是一段简单的闭包代码示例: | |
def foo(): | |
m=3 | |
n=5 | |
def bar(): | |
a=4 | |
return m+n+a | |
return bar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env sh | |
cmd=$* | |
while [ true ]; | |
do | |
eval $cmd | |
if [ $? -eq 0 ]; then |
OlderNewer