Django绝对简明手册

http://wiki.woodpecker.org.cn/moin/DjangoZipManual

Django 是一个高级 Python web framework,它鼓励快速开发和干净的、MVC设计。它包括一个模板系统,对象相关的映射和用于动态创建管理界面的框架。Django遵守BSD版权。

Javascript 绝对简明手册
http://wiki.woodpecker.org.cn/moin/jsInAWord

Javascript和C++,Java,Python一样是一种博大精深的编程语言.

posted @ 2006-10-27 23:09 张沈鹏 阅读(250) | 评论 (0)编辑 收藏
 
Docbook美化Css完美版,Css就在Css文件夹中

点击下载

Docbook用来生成文档不错,不过写起来太烦.

幸好http://wiki.woodpecker.org.cn/的wiki可以把wiki文档转换为Docbook的代码,而写Wiki格式的文档就舒服多了.

我做了这个Css是为了让Docbook生成的文档读起来舒服一点
大家可以配合CDBE(
Chinese DocBook Environment(CDBE))使用,写文档也很享受:)
http://manual.vingel.com/docs/data/20051013100319/index.html
posted @ 2006-10-24 13:51 张沈鹏 阅读(891) | 评论 (0)编辑 收藏
 
Boost.Asio是利用当代C++的先进方法,跨平台,异步I/O模型的C++网络库
现在完成了的小节

   1. 网络库:VC2005注意
   2. 同步Timer
   3. 异步Timer
   4. 回调函数的参数
   5. 成员函数作为回调函数
   6. 多线程回调同步


文章见
http://wiki.woodpecker.org.cn/moin/Boost


文章是用wiki写的,有不妥大家可以直接改正,谢谢。
posted @ 2006-10-19 00:28 张沈鹏 阅读(1610) | 评论 (0)编辑 收藏
 
找算法,有数据库

GOOGLE上的算法太多太杂,
在专门的数据库中找就方便多了.
我在学校是可以全文下载的.

http://portal.acm.org/portal.cfm
ACM(Association for Computing Machinery,美国计算机学会)创立于1947年,目前提供的服务遍及100余个国家,会员人数达80,000多位专业人士,并于1999年起开始提供电子数据库服务――ACM Digital Library全文数据库。ACM Digital Library全文数据库,收录了美国计算机协会(Association for Computing Machinery)的各种电子期刊、会议录、快报等文献,由iGroup Asia Pacific Ltd代理。2002年10月21日iGroup公司在清华大学图书馆建立了镜像服务器。目前,我校可以访问国内站点和美国主站点。


http://ieeexplore.ieee.org
IEEE/IEE Electronic Library(IEL)数据库提供美国电气电子工程师学会(IEEE)和英国电气工程师学会(IEE)出版的229种期刊、8739种会议录、1646种标准的全文信息。

      IEEE和IEE是世界知名学术机构。IEL数据库包含了二者的所有出版物,其内容计算机、自动化及控制系统、工程、机器人技术、电信、运输科技、声学、纳米、新材料、应用物理、生物医学工程、能源、教育、核科技、遥感等许多专业领域位居世界第一或前列。

      IEL更新速度很快,一般每周更新一次,每月增加25,000篇最新文献。而且,每年IEEE还会有新的出版物加入到IEL中去。
posted @ 2006-10-17 17:42 张沈鹏 阅读(757) | 评论 (2)编辑 收藏
 
一道据说是Google的面试题
题目:有一个整数n,写一个函数f(n),返回0到n之间出现的"1"的个数。比如f(13)=6 ; f(11)=4,算出f(n)=n的n(如f(1)=1)?
我用python写了一份代码,还改写了一份c++代码

python源代码
def count(i):
"""count form 0 to this number contain how many 1
1.you shoul know pow(10,n)-1 contain 1 number is n*pow(10,n-1)
2.use 32123 for example:
from 10000 to 32123 the first digit contain 1 number is 1(0000-9999) = pow(10,4) ,
and from 10000 to 30000 the rest digit contain 1 number is ( firstDigit*4*pow(10,4-1) )
so count(32123)=pow(10,4)+( firstDigit*4*pow(10,4-1) ) + count(2123)

print count(1599985)
1599985

print count(8)
1
"""
if i==0:
return 0
if 9>=i>=1:
return 1
digit=len(str(i))
firstDigit=int(str(i)[0])
if firstDigit>1:
now=pow(10,digit-1)
else:
now=int(str(i)[1:])+1
now+=(digit-1)*pow(10,digit-2) * firstDigit
return now+count(int(str(i)[1:]))

def little(i):
count_i=count(i)

if i<count_i:

#i reduce 1 , count_i at most reduce 9 ,
#so you at least reduce (count_i-i)/(9-1) to reach i==count_i
#用位数更快
if (count_i-i)/8>1:
return i-(count_i-i)/8

if i>count_i:
#i reduce 1 , count_i at least reduce 0 , so you at least reduce (i-count_i) to reach i==count_i
return count_i

return i-1

def run(i=10*10**(10-1)):
while i>0:
# print i,'=>i-count_i= ',i-count(i)
if i==count(i):
print i,','

i=little(i)

def fastrun(t=10*10**(10-1)):
"""This just list out all this king of element :) But it is fastest and most useful"""
all=[1, 199981, 199982, 199983, 199984, 199985, 199986, 199987, 199988, 199989, 199990, 200000, 200001, 1599981, 1599982, 1599983, 1599984, 1599985, 1599986, 1599987, 1599988, 1599989, 1599990, 2600000, 2600001, 13199998, 35000000, 35000001, 35199981, 35199982, 35199983, 35199984, 35199985, 35199986, 35199987, 35199988, 35199989, 35199990, 35200000, 35200001, 117463825, 500000000, 500000001, 500199981, 500199982, 500199983, 500199984, 500199985, 500199986, 500199987, 500199988, 500199989, 500199990, 500200000, 500200001, 501599981, 501599982, 501599983, 501599984, 501599985, 501599986, 501599987, 501599988, 501599989, 501599990, 502600000, 502600001, 513199998, 535000000, 535000001, 535199981, 535199982, 535199983, 535199984, 535199985, 535199986, 535199987, 535199988, 535199989, 535199990, 535200000, 535200001, 1111111110]
for i in all:
if(t>=i):
print i

print "first test with run() to:111111111"
run(111111111)

print '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'
print "2st test with run() to:10^10"
run()

print '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'
print "3st test with fastrun() to:10^10 , Fastest!!!"
fastrun()


C++代码
-------------------------------------------------------------------------------
#include <cmath>
#include <iostream>

using namespace std;
unsigned long long mypow(int a,int b)
{
unsigned long long sum=1;
for(int i=0;i<b;i++)
sum*=a;
return sum;
}
unsigned long long count(unsigned long long i){
/*
count form 0 to this number contain how many 1
1.you shoul know pow(10,n)-1 contain 1 number is n*pow(10,n-1)
2.use 32123 for example:
from 10000 to 32123 the first digit contain 1 number is 1(0000-9999) = pow(10,4) ,
and from 10000 to 30000 the rest digit contain 1 number is ( firstDigit*4*pow(10,4-1) )
so count(32123)=pow(10,4)+( firstDigit*4*pow(10,4-1) ) + count(2123)
*/
if(i==0)return 0;
if(9>=i and i>=1)return 1;
int digit=1;
unsigned long long firstDigit=i;
while(firstDigit>=10){
firstDigit/=10;
++digit;
}

unsigned long long now;
unsigned long long rest=static_cast<unsigned long long int>(i-(firstDigit*mypow(10,digit-1)));
if(firstDigit>1)now=static_cast<unsigned long long int>(mypow(10,digit-1));
else{now=rest+1;}
now+=static_cast<unsigned long long int>((digit-1)*mypow(10,digit-2) * firstDigit);


return (now+count(rest));
}

unsigned long long little(unsigned long long i)
{
unsigned long long count_i=count(i);

if(i<count_i){

//i reduce 1 , count_i at most reduce 9 , so you at least reduce
//用位数更快
(count_i-i)/(9-1) to reach i==count_i
if ((count_i-i)/8>1)return i-(count_i-i)/8;
}

if(i>count_i){
//i reduce 1 , count_i at least reduce 0 , so you at least reduce (i-count_i) to reach i==count_i
return count_i;
}
return i-1;
}

void run(unsigned long long i=pow(10.0f,10)){
while (i>0){
// print i,'=>i-count_i= ',i-count(i)
if(i==count(i))cout<<i<<"=>"<<count(i)<<'\n';

i=little(i);
}
cout<<"run() finished\n\n";
}

void fastrun(unsigned long long t=pow(10.0f,10)){
//This just list out all this king of element :) But it is fastest and most useful
const unsigned long long all[]={1, 199981, 199982, 199983, 199984, 199985, 199986, 199987, 199988, 199989, 199990, 200000, 200001, 1599981, 1599982, 1599983, 1599984, 1599985, 1599986, 1599987, 1599988, 1599989, 1599990, 2600000, 2600001, 13199998, 35000000, 35000001, 35199981, 35199982, 35199983, 35199984, 35199985, 35199986, 35199987, 35199988, 35199989, 35199990, 35200000, 35200001, 117463825, 500000000, 500000001, 500199981, 500199982, 500199983, 500199984, 500199985, 500199986, 500199987, 500199988, 500199989, 500199990, 500200000, 500200001, 501599981, 501599982, 501599983, 501599984, 501599985, 501599986, 501599987, 501599988, 501599989, 501599990, 502600000, 502600001, 513199998, 535000000, 535000001, 535199981, 535199982, 535199983, 535199984, 535199985, 535199986, 535199987, 535199988, 535199989, 535199990, 535200000, 535200001, 1111111110};
for(int i=0;i!=83;++i){
if(t>=all[i])cout<<all[i]<<'\n';
}
cout<<"fastrun() finished\n\n";
}
int main(int argc, char *argv[])
{
for(;;)
{
unsigned long long i;
cout<<"please input a number:";
cin>>i;
cout<<"run():\n";
run(i);
cout<<"fastrun():\n";
fastrun(i);
}
system("PAUSE");
return EXIT_SUCCESS;

}
posted @ 2006-09-16 10:49 张沈鹏 阅读(1667) | 评论 (8)编辑 收藏
 
     摘要:  http://wiki.woodpecker.org.cn/moin/PyAbsolutelyZipManual最新版 PyAbsolutelyZipManual Python 绝对简明手册 -- zsp007@gmail.com ::-- ZoomQuiet [2006-09-15 04:35:33] Py2.5 绝对简明手册 ...  阅读全文
posted @ 2006-09-14 22:08 张沈鹏 阅读(1510) | 评论 (7)编辑 收藏
 
 Bjam简明教程

Bjam是Boost中一部分,但可以单独下载,我个人觉得比make方便.

单独下载地址
http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=80982

单独下载Bjam后,设置环境变量BOOST_BUILD_PATH到解压目录.

然后要在中user-config.jam选择编译器(就是把注释去掉),
比如
#  Configure gcc (default version)
#     using gcc ;
改为
#  Configure gcc (default version)
     using gcc ;

在Jamroot文件中可以定义要编译的文件和输出的文件名的target.
如:
exe hello : hello.cpp ;
exe hello2 : hello.cpp ;

可以只编译特定的target,如
bjam hello2

bjam可以选择编译版本,如
bjam debug release
bjam release

可以清理指定的版本/target
bjam --clean debug release
bjam --clean hello2

可以指定一些编译方式
bjam release inlining=off debug-symbols=on

可以指定保含头文件的目录
exe hello
    : hello.cpp
    : <include>boost <threading>multi
    ;

可以为整个工程指定头文件
project
    : requirements <include>/home/ghost/Work/boost <threading>multi
    ;

exe hello : hello.cpp ;
exe hello2 : hello.cpp ;
posted @ 2006-08-08 15:02 张沈鹏 阅读(817) | 评论 (0)编辑 收藏
 

Boost.Asio 0.37教程 Timer.1(翻译自Boost.Asio 0.37的文档)

原文http://asio.sourceforge.net/boost_asio_0_3_7/libs/asio/doc/

翻译:张沈鹏 http://blog.csdn.net/zuroc or http://www.cppblog.com/zuroc

Timer.1 - 同步Timer
本章介绍asio如何在定时器上进行阻塞等待(blocking wait).

实现,我们包含必要的头文件.

所有的asio类可以简单的通过include "asio.hpp"来调用.

#include <iostream>
#include <boost/asio.hpp>

此外,这个示例用到了timer,我们还要包含Boost.Date_Time的头文件来控制时间.

#include <boost/date_time/posix_time/posix_time.hpp>

使用asio至少需要一个boost::asio::io_service对象.该类提供了访问I/O的功能.我们首先在main函数中声明它.

int main()
{
boost::asio::io_service io;

下一步我们声明boost::asio::deadline_timer对象.这个asio的核心类提供I/O的功能(这里更确切的说是定时功能),总是把一个io_service对

象作为他的第一个构造函数,而第二个构造函数的参数设定timer会在5秒后到时(expired).

boost::asio::deadline_timer t(io, boost::posix_time::seconds(5));

这个简单的示例中我们演示了定时器上的一个阻塞等待.就是说,调用boost::asio::deadline_timer::wait()的在创建后5秒内(注意:不是等待

开始后),timer到时之前不会返回任何值.

一个deadline_timer只有两种状态:到时,未到时.如果boost::asio::deadline_timer::wait()在到时的timer上调用,会立即return.

t.wait();

最后,我们输出理所当然的"Hello, world!"来演示timer到时了.

std::cout << "Hello, world!\n";

return 0;
}

完整的代码:
#include <iostream>
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>

int main()
{
boost::asio::io_service io;

boost::asio::deadline_timer t(io, boost::posix_time::seconds(5));
t.wait();

std::cout << "Hello, world!\n";

return 0;
}

posted @ 2006-08-06 16:06 张沈鹏 阅读(896) | 评论 (0)编辑 收藏
 

Boost.Asio 0.37简介(翻译自Boost.Asio 0.37的文档的首页)
原文:http://asio.sourceforge.net/boost_asio_0_3_7/libs/asio/doc/

翻译:张沈鹏 http://blog.csdn.net/zuroc or http://www.cppblog.com/zuroc

Boost.Asio是利用当代C++的先进方法,跨平台,异步I/O模型的C++网络库.

入门

这个教程介绍了客户端-服务器端的一些基本概念,同时给出了一个示例的小程序.

小程序可以启示Boost.Asio在复杂程序中的应用.

附注

Boost.Asio的大部分功能没有必要编译Boost中的其他库,仅仅需要它们的头文件.然而read_until和async_read_until的重载需要Boost.Regex库(注意:MSVC 或 Borland C++的用户需要在用户设置中加入-DBOOST_ALL_NO_LIB来防止与Boost.Date_Time和Boost.Regex的自动链接)

需要OpenSSL才可以启用SSL支持,但Asio的其他部分不需要它.

已经测试的平台和编译器:

* Win32 using Visual C++ 7.1 and Visual C++ 8.0.
* Win32 using Borland C++Builder 6 patch 4.
* Win32 using MinGW.
* Win32 using Cygwin. (__USE_W32_SOCKETS must be defined.)
* Linux (2.4 or 2.6 kernels) using g++ 3.3 or later.
* Solaris using g++ 3.3 or later.
* Mac OS X 10.4 using g++ 3.3 or later.
* QNX Neutrino 6.3 using g++ 3.3 or later.

原理:

Boost.Asio可以让程序员用C++的程序体系取代那种需要使用system底层操作的网络编程.特别的值得注意的是,Boost.Asio试图解决一下一些问题.

*可移植性.
库可以支持并提供一系列常用操作系统的一致行为.

*可测量性:
库允许并鼓励开发者在网络编程中检测成百或成千并发的连接数.库在各个平台的实现要用这种机制来最优的实现这种可测量性.

*效率:
库要支持 分散-聚合I/O(scatter-gather I/O) 之类的技术,允许协议的 最小量(minimise) 的数据交换.

*伯克利(Berkeley) sockets模型:
该模型的API被广泛的采用和理解,被许多文献介绍.其他程序语言通常使用类似网络API的接口.

*易用:
降低新手使用该工具的入门障碍,胜于框架和模式.也就是说,试图最简化前端的学习,仅仅需要理解一些基本规则和指导方针.此外,库的用户仅需要理解使用到的特定函数.

*可以作为进一步抽象的基础:
库应该允许其他库的开发者进行更高层的抽象,比如:实现常用的协议Http.

尽管当前的Boost.Asio的实现主要关注的是网络,但异步I/O可以被扩展到其他系统资源,比如 文件.

posted @ 2006-08-06 14:14 张沈鹏 阅读(888) | 评论 (0)编辑 收藏
 

由boost网络库说起...

文末这篇Email是2006-03-22的,而今天已经2006-8-5日了,我看到asio的soureforge的主页上说.

20 June 2006 - asio version 0.3.7 (development) released.
This release includes major interface changes arising out of the Boost review of asio.
The asio library was accepted into Boost and will appear in a future Boost release.

不过Boost release到现在还是

boost 1.33.1 December 5, 2005.

asio不知道还要等到什么时候才在Boost release放出,真是望穿秋水啊.
C++0x标准也是这样,等就一个字.
由此而观,国外C++社区真是小心谨慎,稳定第一,在他们的理念中C++更类似于一件艺术品.反观Java,.Net的日新月异,可以说是功能第一,方便第二,速度第三.商业与学院的区别真是不辨自明.

而在我的理念中,对于面向普通桌面用户(不是专业/行业软件)的由于功能的类似(即使你有一个很有创意的软件,不出几天就会有软件的翻版),界面和速度可能就是生存的关键.对与C++的Gui这一块,我感觉是极端不适应(也许是我水平太差),幸而firefox和Google的一些小程序提供有了一种新的界面思路:一个后台服务+一个微型web服务器+网页界面.利用Ajax技术可以写出很好界面来(我写了一个默写单词软件网页界面的试验品,兼容firefox和IE6,下载地址:
http://groups.google.com/group/go2program/browse_thread/thread/5ee588253b70df77
中的附件 source.rar
)

所有在cpp@codingnow.com中高人的指点下我知道了asio.从而有了上面这些感慨.

下面是我翻译的关于宣布asio成为boost一员的Email,这是我第一次逐字逐句的翻译.水平有限(6级没过),望多指教.

原文:Jeff Garland
翻译:张沈鹏 http://blog.csdn.net/zuroc or http://www.cppblog.com/zuroc

大家好-
我很高兴的宣布asio(注:网络库)正式成为boost库的一员.正如其他Boost库的审查一样,asio的审查产生了许多的讨论,观点和争辩.评价归结于赞美,包括在工程中成功运用的例子,严肃的(库结构)设计方面的意见.公平的说,在我看来,asio是了一个通用,可靠的库,已经可以被加入Boost库--提供了开发者强烈要求的关键领域的应用.

当然,一如往常,asio还谈不上完美--不少关键性的问题这次审评并没有考虑.在此我仅列举审评中许多的意见中的一部分:

- 修正动态内存分配的问题
- 更改接口以在运行时ipv4和ipv6的无缝切换
- 改进以适应强类型的socket接口(????什么意思,请高手指教)

Chris已经获知了大量关于动态内存分的配解决方案,并且我会就接口和其他方面的问题在Boost的邮件列表上进行跟踪讨论以期能尽善尽美.

其他可以作为进一步增强重要的改进包括:

- 尽可能减少c风格的接口
- 和iostream进一步的整合
- 性能优化
- 改进文档(不要成为Boost w/o this one //???怎么翻译)

Chris has a much longer list of changes garnered from the review and is well on his way to addressing many of them.
Chris有着一个更长的针对审评意见的改进计划表,同时他与建议者有着很好的连续.

注意,有几个讨论是关于性能的,这是asio所涉及领域的核心问题.其中一个就是上面提到的动态内存分配.一般而言,审评者对此的期望很高.然而,在审评讨论之后,在我的印象中许多开发者发现asio只要改进内存分配,它的表现就已经足够胜任重要的工程.(但)我希望Chris在开发asio余下的时间里,可以采纳审评者的一些其他方面的性能意见.

再一次我为Boost社区延迟公布审评结果而抱歉.这次推迟完全是由于我的时间安排问题,与asio无关.再次感谢所有的审评者的贡献,尤其向Chris为Boost添加asio而作出的巨大努力致敬.

原文:
From: Jeff Garland

All -

I'm pleased to announce that asio has been accepted into Boost. As usual with a Boost review, the asio review generated plenty of discussion, issues, and controversy. Comments ranged from high praise,including success stories of projects in production, to serious design concerns and issues. On balance, in my judgment, asio provides a generally solid library that is ready for inclusion into the Boost library -- providing key functionality in an area that developers have a strong need.

Of course, like anything else, asio is not perfect -- a number of key issues were uncovered during the review. In terms of required changes I'm only going to cite a few:

- Fixes to dynamic memory allocation issues
- Interface changes to support ipv4 and ipv6 seamlessly at runtime
- Improvements to support strongly typed socket interfaces

Chris has communicated a couple possible solutions to the memory allocation issue and I'll ask that the interface and other changes for this issue continue to be discussed on the Boost list so consensus can be achieved on the best resolution.

Other key improvements that should be explored as future enhancements include:

- Possible removal of some of the c-style interfaces
- Exploration of higher level iostream integrations
- Performance improvements
- Improved documentation (wouldn't be Boost w/o this one)

Note that there were several threads and discussions about performance,which is particularly critical for the domain covered by asio. One of the performance issues is the dynamic memory allocation issue cited above. In general, the reviewers have extremely high expectations here. However, after reviewing the discussion and library it's my belief that
many developers will find asio performance sufficient to build significant projects with only the memory allocation changes. I expect Chris will be able to address some of the other performance issues cited by reviewers in asio over time.

Once again I'll apologize to the Boost community for the delay in the review results. The delay was entirely due to my own personal scheduling issues and should not reflect on asio in any way. Thanks again to all the reviewers for their effort and especially to Chris for his tremendous effort in bringing asio to Boost!

Jeff

posted @ 2006-08-05 23:45 张沈鹏 阅读(731) | 评论 (0)编辑 收藏
仅列出标题
共7页: 1 2 3 4 5 6 7