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
" Settings | |
set nohud | |
set nosmoothscroll | |
set noautofocus " The opposite of autofocus; this setting stops | |
" sites from focusing on an input box when they load | |
set typelinkhints | |
let searchlimit = 30 | |
let scrollstep = 70 | |
let barposition = "bottom" |
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
# _*_ coding: utf-8 _*_ | |
# http://stackoverflow.com/questions/12798653/does-setattr-and-getattr-slow-down-the-speed-dramatically | |
# run: time python setattr_test.py | |
class O(object): | |
pass | |
o = O() | |
for i in xrange(10000000): | |
setattr(o, 'a', 1) # python setattr_test.py 1.44s user 0.01s system 99% cpu 1.449 total |
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
Error: jedi-vim failed to initialize Python: jedi#setup_py_version: Vim(pyfile):Traceback (most recent call last): (in function jedi#init_python[3]..<SNR>90_init_python[48]..jedi#setup_py_version, line 18) | |
各种修复, 重装无果, 最后把root权限下的thefuck, colorama 卸载掉, 修复.. | |
https://github.com/davidhalter/jedi-vim/issues/526 |
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
http://stackoverflow.com/questions/11172379/python-and-bpython-using-different-pythonpaths-in-virtualenv | |
在virtualenv里面安装, 或修改 .bash/.zshrc | |
bpython() { | |
if test -n "$VIRTUAL_ENV" | |
then | |
PYTHONPATH="$(python -c 'import sys; print ":".join(sys.path)')" \ | |
command bpython "$@" | |
else |
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
du -hsc * |
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 get_count(q): | |
count_q = q.statement.with_only_columns([func.count()]).order_by(None) | |
count = q.session.execute(count_q).scalar() | |
return count | |
q = session.query(TestModel).filter(...).order_by(...) | |
# Slow: SELECT COUNT(*) FROM (SELECT ... FROM TestModel WHERE ...) ... | |
print q.count() |
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 [ -n "$BASH" ] ; then | |
_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | |
_basepath=$(dirname "$_DIR") | |
fi | |
if [ -n "$ZSH_VERSION" ]; then | |
_DIR="$(dirname $(cd -P -- "$(dirname -- "$0")" && pwd -P))" | |
_basepath=$_DIR | |
fi |
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
Reflecting All Tables at Once | |
The MetaData object can also get a listing of tables and reflect the full set. This is achieved by using the reflect() method. After calling it, all located tables are present within the MetaData object’s dictionary of tables: | |
meta = MetaData() | |
meta.reflect(bind=someengine) | |
users_table = meta.tables['users'] | |
addresses_table = meta.tables['addresses'] |
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
Index: home/moo/workspace/django-trunk/docs/request_response.txt | |
=================================================================== | |
--- /home/moo/workspace/django-trunk/docs/request_response.txt (revision 6657) | |
+++ /home/moo/workspace/django-trunk/docs/request_response.txt (working copy) | |
@@ -588,3 +588,29 @@ | |
That takes care of setting ``handler500`` in the current module. As you can see | |
in ``django/conf/urls/defaults.py``, ``handler500`` is set to | |
``'django.views.defaults.server_error'`` by default. | |
+ | |
+Here is example how to log the exception using Python logging API and |
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
#_*_ coding: utf-8 _*_ | |
""" | |
Mutation Tracking | |
http://sqlalchemy.readthedocs.org/en/rel_0_8/orm/extensions/mutable.html | |
JSONColumn | |
https://bitbucket.org/zzzeek/sqlalchemy/wiki/UsageRecipes/JSONColumn | |
""" |
NewerOlder