This file contains hidden or 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): | |
... def bar(self): | |
... print 'hello' | |
... | |
... | |
... | |
>>> class_name = 'Foo' | |
>>> globals()[class_name] | |
<class '__main__.Foo'> | |
>>> _() |
This file contains hidden or 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
{% if ctx.tags %} | |
<p class=tags>This entry was tagged | |
{% for tag in ctx.tags|sort(case_sensitive=true) %} | |
{%- if not loop.first and not loop.last %}, {% endif -%} | |
{%- if loop.last and not loop.first %} and {% endif %} | |
<a href="{{ link_to('tag', tag=tag) }}">{{ tag }}</a> | |
{%- endfor %} | |
{% endif %} |
This file contains hidden or 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
def textList(listtext, sep1=', ', sep2=', and '): | |
return sep1.join(listtext[:-2]+['']) + sep2.join(listtext[-2:]) |
This file contains hidden or 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
>>> from pyramid_simpleform import Form | |
>>> from pyramid_simpleform.renderers import FormRenderer | |
>>> import formencode | |
>>> class ForgotPWSchema(formencode.Schema): | |
... email = formencode.validators.Email(not_empty=True) | |
... | |
>>> form = Form(request, schema=ForgotPWSchema) | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
NameError: name 'request' is not defined |
This file contains hidden or 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
#file are located in /resources | |
#eg to open /resources/sample.pdf -> http://www.mysite.com/MyFiles/sample.pdf | |
#location configuration in nginx.conf | |
location ^~ /resources/ { | |
internal; | |
root /path/to/myapp; | |
} | |
This file contains hidden or 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
pip freeze | cut -d = -f 1 | xargs echo pip install -U |
This file contains hidden or 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
for x in `gem list --no-versions`; do gem uninstall $x; done |
This file contains hidden or 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
ssh error: | |
ssh_exchange_identification: Connection closed by remote host | |
fix: | |
sudo echo "sshd:ALL" >> /etc/hosts.allow |
This file contains hidden or 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
语言文件 po 和 mo 的互相转换 | |
=========================== | |
apt-get install gettext | |
1, mo to po | |
msgunfmt xxx.mo -o xxx.po | |
2, po to mo |
This file contains hidden or 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
pip install -e git://github.com/bitly/bitly-api-python.git#egg=bitly_api |