2009/12 31
web2pyTM Enterprise Web Framework 企业级web框架

Free and open source full-stack enterprise framework for agile development of fast, scalable, secure and portable database-driven web-based applications. Written and programmable in Python .
web2py是完全免费开源的企业级web开发框架, 具有快速开发,可扩展,安全,组建式数据库驱动等特点。语言:python。

以上文字是web2py的首页给出的。也试用了一番,感觉并不佳。主要缺陷:

1. 开发一个应用,文件夹太多。新的app的scaffold代码中将包含有十几个文件夹。过于复杂
2. 多个应用中,难以共享数据。比如auth表,只能在一个app中进行。在其他app中难以调用
3. 文档过少。看源码,数据有虚拟字段的功能,但在各个文档中,都没有提到
4. 出错信息体验太糟糕。出错了直接显示错误结果就好了,非得给个链接,造成一次额外的点击。
5. 代码方面import很糟糕,大量的import *,导致在eclipse的源代码分析中,出现大量的类缺失错误

优点:
1. 修改表结构后,系统会自动同步数据库
2. 后台编辑器很棒,对代码的修改很方便。但我并不习惯直接在web页面中修改源代码,这个安全性隐患太大了,给不便于版本管理。也许处于beta接管的hg组件能便于管理,未测试。
3. 数据库在线设计功能不错,但还不够完善,导入功能不能用,导出的代码需要作修改才能使用。(忽然发现这个是GAE的,和WEB2PY没什么关系)
4. 从代码上看,考虑了GAE。
5. shell功能不错,可以在web中使用shell。

个人感觉web2py比较糟糕,无法实现其标榜的企业开发。
整体上,web2py给我的感觉是过度设计,过度依赖于web。包括web编辑源码。web使用shell。这个对专业开发没有意义。
在文档上的缺少,很致命。是我抛弃他的最主要原因。

Posted by rollenc

Last modified on 2009-12-31 21:17
2009/12 30
介绍
BeansDB 是一个主要针对大数据量、高可用性的分布式KeyValue存储系统,采用HashTree和简化的版本号来快速同步保证最终一致性(弱),一个简化版的Dynamo。

它采用类似memcached的去中心化结构,在客户端实现数据路由。目前只提供了Python版本的客户端,其它语言的客户端可以由memcached的客户端稍加改造得到。

特性

高可用:通过多个可读写的用于备份实现高可用
最终一致性:通过哈希树实现快速完整数据同步(短时间内数据可能不一致)
容易扩展:可以在不中断服务的情况下进行容量扩展。
高性能:异步IO和高性能的KeyValue数据TokyoCabinet
可配置的可用性和一致性:通过N,W,R进行配置
简单协议:Memcache兼容协议,大量可用客户端


性能

在小数据集上,它跟memcached一样快:

网址
主页:http://code.google.com/p/beansdb/
SVN源码: http://beansdb.googlecode.com/svn/trunk/
Defined tags for this entry:

Posted by rollenc

Last modified on 2009-12-30 10:06
2009/12 28
bpython is a fancy interface to the Python interpreter for Unix-like operating systems (I hear it works fine on OS X). It is released under the MIT License. It has the following features:

In-line syntax highlighting.
Readline-like autocomplete with suggestions displayed as you type.
Expected parameter list for any Python function.
"Rewind" function to pop the last line of code from memory and re-evaluate.
Send the code you've entered off to a pastebin.
Save the code you've entered to a file.
Auto-indentation.


Install:

$ sudo apt-get install python-pygments $ curl http://bpython-interpreter.org/releases/bpython-0.9.5.2.tar.gz $ tar zxvf bpython-0.9.5.2.tar.gz $ cd bpy* $ sudo python setup.py install

Or use easy_install simplely,

$ sudo easy_install bpython

Usage:
$ bpython

Sceenshot:




For more, see the bpython home or just skip right to the screenshots.





Defined tags for this entry:

Posted by rollenc

Last modified on 2009-12-29 23:43
2009/12 21
原文: http://blog.s9y.org/archives/211-Serendipity-1.5-released.html

Serendipity团队很自豪的发布了Serendipity 1.5版本。 之前的beta版本在多数情况下都能正常工作,现在是最终发布的时候了:)
The Serendipity Team is proud to present the final release of Serendipity 1.5. While the earlier beta versions are proven to work fine for many people, it was finally time to package up a real release. ;)

本版本改变了密码存储机制,使用salted后的SHA1代替了原来简单的MD5编码。这一改变后,黑客将无法通过数据库破解原密码。另一个改变是增加了PHP5.3的兼容性。
This version mainly addresses login security by changing our method how passwords are stored to use salted SHA1 checksums instead of plain MD5 checksums. This makes password retrieval (rainbow attacks, see special blog posting) through the database virtually impossible. Another thing is improved PHP 5.3 compatibility.

对于使用Xinha 所见即所得编辑器的用户来讲,现在可以通过自定义"my_custom.js"来修改编辑器面板的样式了。该文件在template目录下(在htmlarea/子目录下我们已经准备了一个默认的草稿文件供你参考或还原)。
For users of our Bundled WYSIWYG-Editor Xinha users now have the ability to easily customize the appearance of this panel through a "my_custom.js" file inside the template directory (a draft of such a file can be found as fallback default in the htmlarea/ subdirectory).

我们给开发者提供了一个很酷的新功能,在模板中可以注册插件API,来执行一些特殊的需求。本功能不需要安装任何事件组件。
One cool new feature for developers is that now also templates can register themselves inside the plugin API hooks to execute specific things, that don't require installation of an event plugin.

其他新的内容:
新的事件API钩子
修正了PDF缩略图
拖拽组件时,边框将可以自动滚动调整
支持UTC时区
增强了Smarty函数,将S9Y打造成CMS江更为简单
快速搜索中,如果返回结果过少,将启用通配符搜索 (译者注:这个功能使得S9Y支持中文搜索了)
在Akismet新支持Typepad 反垃圾邮件验证
Other news include:
new event API hooks
fixed PDF thumbnail generation
ability to auto-scroll on borders when Drag/Dropping plugins
UTC server time zone support
improvements in the Smarty functions to easier use Serendipity as a CMS for individual entry output.
quicksearch improvements for doing a wildcard-search when too few searchresults were found on a fixed searchterm
support for Typepad anti-spam server-checks, additionally to Akismet

在1.5beta-1之后的主要更新包括:
兼容PHP5.3.0
禁止上传含有.PHP.的文件,避免apache启用 MimeMagic-Modules产生的安全漏洞
实验PDO,支持SQLite
改进了评论管理,增加了一些有用的工具

Minor improvements since the 1.5-beta1 release:
more PHP 5.3.0 compatibility improvements
Disallow uploading any files that contain ".php." in the filename for extra security with Apache MimeMagic-Modules
expermiental PDO:SQlite support
usability improvements for the comment moderation panel (bottom-navigation, removed border increase)

之前的各个版本可以很容易的升级到最新的版本。解压,上传,然后访问你的管理面板进行数据库升级就可以了。在使用旧密码进行第一次登录后,S9Y将使用新的格式存储你的密码。在更新之前,请先做好备份,并认真阅读升级文档。
The current release can be easily installed on any previous Serendipity installation. Just unpack, upload and visit your admin panel to perform possible database upgrades. Upon first login with an old password, Serendipity will store your old password in the new format - please be sure to make a backup of your Database prior to upgrading, and read the upgrade pointers on Upgrading Serendipity.

祝你使用S9Y愉快。有任何问题,请将它发布到我们的论坛上。
Have fun using Serendipity, and let us know on the Forums if you have any issues!

Posted by rollenc

Last modified on 2009-12-21 22:03
2009/12 17
My Env:
Ubuntu 8.04
python 2.5

Step:
1. sudo apt-get install python-subversion python-mysqldb
2. sudo easy_install Trac
3. sudo useradd trac
4. sudo su trac
5. trac-admin /home/trac/luochunhui.com initenv
Project Name [My Project]> Blog
Database connection string [sqlite:db/trac.db]> mysql://username:password@localhost/trac
Repository type [svn]> svn
Path to repository [/path/to/repos]> /home/svn/blog

6. nohup tracd --port 8290 -b trac.luochunhui.com /home/trac/luochunhui.com/ &
7. exit
visit trac.luochunhui.com:8290


Next: auth & use nginx

8. sudo su tracd
9. cd /home/trac
10. trac-admin luochunhui.com/ permission remove anonymous BROWSER_VIEW CHANGESET_VIEW FILE_VIEW LOG_VIEW MILESTONE_VIEW REPORT_SQL_VIEW REPORT_VIEW ROADMAP_VIEW SEARCH_VIEW TICKET_VIEW WIKI_VIEW TIMELINE_VIEW
11. trac-admin luochunhui.com/ permission add authenticated BROWSER_VIEW CHANGESET_VIEW FILE_VIEW LOG_VIEW MILESTONE_VIEW REPORT_SQL_VIEW REPORT_VIEW ROADMAP_VIEW SEARCH_VIEW TICKET_VIEW WIKI_VIEW TIMELINE_VIEW
12. htpasswd -c conf/trac.htpasswd username
13. killall tracd
14. nohup tracd --port 8290 -b trac.luochunhui.com /home/trac/luochunhui.com --basic-auth="*",/home/trac/luochunhui.com/conf/trac.htpasswd,trac.luochunhui.com &
15. exit //exit trac user
14. sudo vi /etc/nginx/sites-available/trac.luochunhui.com
upstream trac_rollenc { server trac.luochunhui.com:8290; } server { listen 80; server_name trac.luochunhui.com; access_log /var/log/nginx/trac.access.log main; error_log /var/log/nginx/trac.error.log info; location / { proxy_pass http://trac_rollenc; # include /etc/nginx/proxy.conf; } }
15. sudo ln -sf /etc/nginx/sites-available/trac.luochunhui.com /etc/nginx/sites-enable/trac.luochunhui.com
16. sudo nginx -t
17. sudo /etc/init.d/nginx restart

visit trac.luochunhui.com
and you will see some error message because the anonymous is deny.
click "login" and input your username and password.
Enjoy it.

ALL DONE.

Posted by rollenc

Last modified on 2009-12-17 14:55
2009/12 6


脑残啊,脑残!
杯具啊,杯具!

Posted by rollenc

Last modified on 2009-12-12 15:06
2009/12 1
1. Cache
Direct execution can use MySQL cache when two sqls are the absolutely same .
Prepared execution can't use MySQL cache, even if no placeholders were employed.

2. Speed
Direct execution query need to be parsed every time.
Prepared execution query is parsed only once.
Prepared statements might not provide a performance increase in some situations. For best results, test your application both with prepared and nonprepared statements and choose whichever yields best performance.


3. Network
Direct execution sends all the query to MySQL services.
Prepared execution sends twice, The first is for prepared query, then the arguments.
If you call a prepared more than once, prepared execution can reduce the network traffic.

4. Safe
Direct execution might cause a sql inject if the programmer doesn't handle the unsafe input rightly and carefully.
Prepared execution is safe because the query and the arguments are split.


Ref:
1. http://dev.mysql.com/doc/refman/5.0/en/c-api-prepared-statements.html
2. http://dev.mysql.com/doc/refman/5.0/en/query-cache-operation.html

Defined tags for this entry:

Posted by rollenc

Last modified on 2009-12-01 13:50
2009/11 9
Requirement:

Linux ( Ubuntu 9.10 )
vncserver (sudo apt-get install vnc4server )
firefox

Command:
$ vncserver -geometry 800x800 -depth 24 #start a virtual screen New 'rollenc-Ubuntu:1 (rollenc)' desktop is rollenc-Ubuntu:1 Starting applications specified in /home/rollenc/.vnc/xstartup Log file is /home/rollenc/.vnc/rollenc-Ubuntu:1.log $ DISPLAY=:1 firefox "http://www.luochunhui.com/" & [1] 21489 Xlib: extension "RANDR" missing on display ":1.0". Xlib: extension "Generic Event Extension" missing on display ":1.0". Xlib: extension "Generic Event Extension" missing on display ":1.0". Xlib: extension "Generic Event Extension" missing on display ":1.0". Xlib: extension "Generic Event Extension" missing on display ":1.0". #wait few senconds and then shot and save $ DISPLAY=:1 import -window root -resize 800x800 lj-shot.jpg #So lj-shot.jpg is the shot result. #close firefox and vncserver $ kill 21489 # the pid of firefox $ vncserver -kill rollenc-Ubuntu:1

Posted by rollenc

Last modified on 2009-11-09 13:31
2009/08 25

Posted by rollenc

Last modified on 2009-08-25 17:31
2009/08 5
【转】高级PHP应用程序漏洞审核技术
Converting from Subversion to Mercurial
三种流行操作系统的内核比较
Serendipity 1.5 beta 1 This blog is using s9y 1.5 now.

Posted by rollenc

Last modified on 2009-08-24 22:54
2009/07 7








上面都是宝宝在第三天时的照片.



这一张第四天的照片.好狠的眼神!



这是7月7号的,第十一天的照片.脸长胖了.眼巴巴的,好可怜的样子.5555

Posted by rollenc

Last modified on 2009-07-08 02:00
2009/05 31
购物搜索的前景分析
Google购物搜索 Google的中文版终于推出了。不知道会带来什么影响。。。
Displaying row number (rownum) in MySQL
A B2B site for Telecommunication Products and Companies
16 PHP Frameworks To Consider For Your Next Project

Posted by rollenc

Last modified on 2009-06-10 09:41
2009/04 24
用途: 当业务需要调用一个比较耗时外部资源时使用, 最常见的是从外部API获取相关内容

使用方法:
1. 建立外部资源脚本。 如示例中使用t.sh。 当然, 也可以直接使用curl等命令行
2. 准备好参数, 提供给pipe脚本
2. 使用popen调用脚本。 调用之后,就不用关心了。
3. 开始其他的和pipe不相关的逻辑处理
4. 其他处理完成之后, 使用fgets等方式,获取popen的数据


示例代码:

php程序:
# get argument for pipe here if it has.

#start pipe
echo 'call popen start: '. date("H:i:s"), "\n";
$pipe = popen(dirname(__FILE__) . '/t.sh', 'r');
echo 'call popen end: '. date("H:i:s"), "\n";

#Other code here
sleep(5);
echo "Here is my code. time: " . date("H:i:s"), "\n";

#read pipe result
while ($s = fgets($pipe,1024)) {
    echo $s;
}


pipe脚本:
echo 1, `date +%T`;
sleep 1;
echo 2, `date +%T`;
sleep 10;
echo 3, `date +%T`;


输出如下:
call popen start: 10:16:40
call popen end: 10:16:40
Here is my code. time: 10:16:45
1, 10:16:40
2, 10:16:41
3, 10:16:51


代码方面, 我们有三个sleep。
php中一个 sleep 5,
sh中两个sleep, 10+1
如果使用串行的方式, 那么用时应该是10+1+5 = 16秒。
而使用pipe方式, 用时仅为:max(php, pipe) = max(5,11) = 11秒。

PS:很抱歉,空间服务商看起来不喜欢popen这个字眼, 所以只能将起替换成全角的了。请在使用时,替换一下吧:)
Defined tags for this entry:

Posted by rollenc

Last modified on 2010-04-06 23:19
2009/04 21
程序员的8个级别,你想成为哪一种?

自己给自己的评价,是第四阶段:
工作杰出的程序员

你做为一个软件工程师的职业生涯非常的成功,因为你的工作能力相当杰出,你从来不会为找不到一份你满意的好工作好发愁,你的同事也非常尊敬你,每一家你工作过的公司都因为你的加盟而在某些方面得到了增强。


而问题也很明确,正好是今年的我在思考的问题:

你接下来的方向在哪呢?


接下来方向在哪里呢?

想了半年了, 还没有结果。所以,半年来一事无成。

1. 停留。
正如上文说的, 从来不会为找不到一份你满意的好工作好发愁。 也许这样也很好,也是不少人追求得一种境界。所谓“知我者谓我心忧,不知者谓我何求”, 不少人认为我很优秀了, 已经得到了这样的一个水平。而自己,却始终担心着, 接下来,我该如何?
没有人给我答案。 只是知道, 自己不能停留。

2. 行动。 将自己已经具备的能力作为行动, 转化为直接的经济价值。
在去年的一些性格分析中,了解到自己的性格偏向于思考型。 而提升方向是将提高自己的执行力。 将自己的想法转变为实际行动。今年的开初,也重点在这一方面。 做了一些垃圾站和一个手机资源网站的雏形。但结果真的很糟糕。自己毛糙的性格,在执行上不太得力。拍脑袋,丢三落四,后期推翻前期的规划。自己的行动总在一个怪圈中绕弯弯。
不得志。

3. 钻研。 继续去了解更多的技术细节,技术实现,技术解决方法等等。
从性格上说, 这是自己的一种消极表现。在不得志的情况下, 喜欢封闭自己, 将自己陷入技术中, 学习, 研究, 乐此不彼。 同时也会去隔离外部的一切交流,沟通。
这种性格和方式, 是我目前能够获得“工作杰出的程序员”这一个自我评价的源泉, 继续发扬,得到的, 是“知名程序员”, 还是程序员30岁的尴尬?
不确定。yanger给我建议是去成为一个“知名程序员”,因为我真的适合做程序。 这句话应该是赞扬的话,我却常常会将其理解对为自己性格弱点的一种讽刺。

4. 性格转变
我真的适合做程序。 但是我怕遇到老程序员的尴尬,也不甘于去做一个老程序员。目标是架构师。技术是核心, 而不可避免的, 要学会沟通, 要学会领导。
提前准备着一些东西是否必要, 是否是我目前急需准备的东西。
我想是的。 很多人却告诉我不是。


迷失了。 从来没有像这样迷失过。

接下来方向在哪里呢?

静下来,放慢脚步,等等灵魂的脚步,看看他怎么说。。。

期待你的声音,请告诉我,

接下来方向在哪里呢?

Posted by rollenc

Last modified on 2009-04-26 23:59
2009/04 21
更换Mysql数据目录后, mysql服务器无法启动。
解决方法记录如下

1. 停止mysql服务
sudo /etc/init.d/mysql stop

2. 修改my.cnf文件,将
datadir = /var/lib/mysql
改为
datadir = /www/mysql

3. 移动文件
sudo mv /var/lib/mysql /www/

4. 重启mysql服务
sudo /etc/init.d/mysql restart

5 发现启动不了。查看系统信息:
Apr 21 11:03:16 rollenc-Ubuntu kernel: [ 7105.064106] type=1503 audit(1240282996.414:72): operation="inode_permission" requested_mask="rw::" denied_mask="rw::" fsuid=113 name="/www/mysql/ibdata1" pid=13604 profile="/usr/sbin/mysqld"

Google之后, 发现这是mysql在Ubuntu下的bug。 部分版本会出现。解决方法

6. 安装apparmor
sudo apt-get install apparmor
sudo touch /etc/apparmor.d/disable/usr.sbin.mysqld
sudo /etc/init.d/apparmor start

7. 编辑apparmor配置文件, 将其中的 /var/lib/mysql 修改为/www/mysql
sudo vi /etc/apparmor.d/*mysqld
sudo /etc/init.d/apparmor restart

8. 重新启动服务
sudo /etc/init.d/mysql restart

9 Done,一切正常。


Posted by rollenc

Not modified

(Page 2 of 34, totaling 505 entries)