Archive for January, 2011

macports安装scapy遇到滴问题

Friday, January 28th, 2011
公司的无线慢得令人发指,再几次掉线后出现了这样的错误
DEBUG: Backtrace: atlas3.8.3.tar.bz2 does not exist in /opt/local/var/macports/distfiles/atlas
—>  Checksumming atlas3.8.3.tar.bz2
Error: Target org.macports.checksum returned: atlas3.8.3.tar.bz2 does not exist in /opt/local/var/macports/distfiles/atlas
DEBUG: Backtrace: atlas3.8.3.tar.bz2 does not exist in /opt/local/var/macports/distfiles/atlas
while executing
“$procedure $targetname”
Warning: the following items did not execute (for atlas): org.macports.activate org.macports.checksum org.macports.extract org.macports.patch org.macports.configure org.macports.build org.macports.destroot org.macports.install
Log for atlas is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_math_atlas/main.log
Error: Status 1 encountered during processing.
To report a bug, see <http://guide.macports.org/#project.tickets>
zhangdi:local$ sudo port clean –all atlas
—>  Cleaning atlas
zhangdi:local$ port clean –all atlas
—>  Cleaning atlas
Warning: Only cleaning in ~/.macports; insufficient privileges for standard locations
zhangdi:local$ sudo port install atlas
—>  Computing dependencies for atlas
—>  Fetching atlas
—>  Attempting to fetch atlas3.8.3.tar.bz2 from http://downloads.sourceforge.net/math-atlas
—>  Attempting to fetch lapack-3.2.2.tgz from http://www.netlib.org/lapack

—>  Checksumming atlas3.8.3.tar.bz2Error: Target org.macports.checksum returned: atlas3.8.3.tar.bz2 does not exist in /opt/local/var/macports/distfiles/atlasDEBUG: Backtrace: atlas3.8.3.tar.bz2 does not exist in /opt/local/var/macports/distfiles/atlas    while executing”$procedure $targetname”Warning: the following items did not execute (for atlas): org.macports.activate org.macports.checksum org.macports.extract org.macports.patch org.macports.configure org.macports.build org.macports.destroot org.macports.installLog for atlas is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_math_atlas/main.logError: Status 1 encountered during processing.To report a bug, see <http://guide.macports.org/#project.tickets>zhangdi:local$ sudo port clean –all atlas—>  Cleaning atlaszhangdi:local$ port clean –all atlas—>  Cleaning atlasWarning: Only cleaning in ~/.macports; insufficient privileges for standard locationszhangdi:local$ sudo port install atlas—>  Computing dependencies for atlas—>  Fetching atlas—>  Attempting to fetch atlas3.8.3.tar.bz2 from http://downloads.sourceforge.net/math-atlas—>  Attempting to fetch lapack-3.2.2.tgz from http://www.netlib.org/lapack

clean 一下就好了

参考 https://trac.macports.org/ticket/27542

sphinx的autodoc

Monday, January 24th, 2011

修改conf.py 先把项目目录加上

sys.path.append(os.path.abspath(‘d:/wsgi/biz_python’))

# — General configuration —————————————————–

添加扩展 sphinx.ext.autodoc
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named ‘sphinx.ext.*’) or your custom ones.
extensions = ['sphinx.ext.autodoc']

这就可以用了,在文档使用吧

.. function:: foo(x)
foo(y, z)
:module: some.module.name

Return a line of text input from the user.

悲催的解码问题

Wednesday, January 12th, 2011

txt = u’11%u6708%u4EFD%u603B%u7ED3%u4F1A%u8BAE%u901A%u77E5.doc’

>>> print re.sub(r’%u(\w{1,4})’,lambda s: unichr(int(s.group(1), 16)),txt)
11月份总结会议通知.doc

上次遇到的,我很弱智的用了正则,今天知道个原来可以这样

print “%u4f60″.replace(‘%’, ‘\\’).decode(‘unicode_escape’)

MySQL日志设置

Thursday, January 6th, 2011

MySQL日志设置

# logs
log-bin=D:/MySQL/logs/mysql-bin

#expire_logs_days = 10
#max_binlog_size = 100M

log=D:/MySQL/logs/mysql.log
log-error=D:/MySQL/logs/error.log

#log-update=D:/MySQL/logs/update.log  未能成功生成

long_query_time=1
log-slow-queries
log-queries-not-using-indexes

kohana3中的随机查询

Wednesday, January 5th, 2011
ORM的

ORM::factory('some_model')->order_by(DB::expr('RAND()'))->find();

Model的

$this->db->from('table')->select('*')->limit(1)->orderby(null, 'RAND()')->get();