作者归档:船长

网站作为一个信息供给系统

就目前为止,我对网站作为一个信息供给系统的看法。
当然,网站不止于信息供给功能,人们还可以发布信息和交流信息。

信息供给系统是指一个能向用户提供有用信息的系统。
它是相对的。一个系统能提供的信息对一些用户有价值,对于其他用户可能没有价值。
信息供给系统必需满足两个条件:
1.有价值的信息在系统中存在;

2.用户可以通过某种实际可行的途径得到这部分信息。

信息供给系统的评价标准
对于一个用户,系统属于信息供给系统的条件下,评价它的标准:
1.取得信息的难度(技术难度,视线难度。。)
2.取得信息的用时
3.信息价值的大小,用户最后得到信息后对信息的满意度。信息的相关性,信息的准确度,信息的时效,信息的完整程度。。。

信息供给的途径
1.搜索
优点:直接,快速
缺点:要先得到关键词,很难控制相关性。

2.索引
优点:系统化,用户可以不知道关键词,通过大概的感觉找到信息;可以浏览,让用户得到一片信息,而不是一点
缺点:比较费时(但如果能顺利找到,用户应该不介意)
网页的分类,TAG,导航系统也可以看完一个索引系统。
要使用清晰准确易懂的关键词作为分类名。不要给用户任何“惊喜“
索引分类结构要合理,要让用户一眼能看出来他要的子分类藏哪一主分类之下。
一个终端类目下的条目不应该过多,过多的条目不方便挑选。
索引最好有合理排序功能,通过列表的条件关系,加速信息查找。

信息供给系统的最高目标:
立现你所需,不多,也不少。
立:速度快
现:不费力,主动“现”
你:个性化,针对性
所需:相关性
不多:无干扰信息,无不相关信息
不少:信息量完整。

发表在 信息处理, 站长文档 | 标签为 | 留下评论

女朋友

在嘉陵江边的乱石滩上,伴着潺潺的江水,吹着让人舒心的风,坐着的却是一对沉默着的情侣--男孩低着头,偶尔也会尝试带着笑脸看一眼女孩,但女孩瞪一眼男孩,把绷得紧紧的脸转开一点,继续不搭理他。。。于是男孩只得扫兴地再次慢慢低下头。。。

他们就坐着,坐着。。。宁静得像这就是他们的世界尽头。。。

突然一石子被投向了江里,“咚“的一声,江面上散开了几圈波纹。二人同时转身,看到一个正在散步的人从脚下又拾起一石子,向江面投了出去。。。

女孩看了一会,站起来俯身探了几步,也拾起一块石子,然后随手将它向江面掷了出去,但飞出的石子马上坠落,落在仅几步之遥的江面上。。。

这时男孩带着一块石子向移江边和女孩并站到了一起,举起手中的石子--他没有把石子抛出,而是虔诚地把它送到女孩的前面。。

女孩看了他一眼,又看了一眼他手中的石子,停了一会,还是伸手接过了石子,把它向江面掷了出去。“啪“的一声,石子被摔他们跟前的江边上,溅了男孩一身的水珠。。。

“你太差劲了“,男孩一边擦着脸,一边随手拾起一块石子,“看我的!”
石子在天空划了一道长长的线,消失在了江心。。。

女孩呆了一会,然后马上低头翻了两个大小一样的石子,把其中一个递给男孩,“你等我掷完了再掷,看看你。。。“
”比你远多少?“面对即将到来的挑战,男孩显然有点激动。

男孩话音刚落,女孩刚有点平和的脸马上又绷了起来,她恨恨地向男孩瞪了一眼,转身后却调皮地笑起来“我不要你投近了,也不要你投远了,我要看看你投到的地方离我投的落点能有多近。“

两块石子一前一后落到了江面,泛起了几圈波纹,波纹一边向外扩散一边随着江水荡漾,不一会就从江面上消失了。。。

发表在 某时雨集 | 留下评论

Extreme Programming and Test-Driven Development

Extreme Programming
Extreme Programming (or XP) is a software engineering methodology, the most prominent of several agile software development methodologies.

Extreme Programming Explained describes Extreme Programming as being:
    * An attempt to reconcile humanity and productivity
    * A mechanism for social change
    * A path to improvement
    * A style of development
    * A software development discipline


Test-Driven Development
The goal of TDD is to write clean code that works.

What is Test-Driven Development?
Test-Driven Development (TDD) is a software development technique that involves repeatedly first writing a test case and then implementing only the code necessary to pass the test. Test-driven development is a method of designing software, not merely a method of testing.

In addition to normal “did it pass?” testing, you can go the opposite route. By testing your application where the weak points are, you can fix it before it ever becomes an issue.

Test-Driven Development Cycle
1. Add a test
In order to write a test, the developer must understand the specification and the requirements of the feature clearly.
2. Run all tests and see the new one fail
testing the tests
3. Write some code
It is important that the code written is only designed to pass the test; no further (and therefore untested) functionality should be predicted and ‘allowed for’ at any stage.

KISS
Keep It Simple, Stupid.
Everything should be made as simple as possible, but no simpler.
                    –Albert Einstein

You Ain’t Gonna Need It
‘You Ain’t Gonna Need It’(YAGNI), is a reminder for programmers that one should never add functionality until it is necessary.

4. Run the automated tests and see them succeed
5. Refactor code

Refactoring
A code refactoring is any change to a computer program which improves its readability or simplifies its structure without changing its results.
List of refactorings

    * Encapsulate Field(e.g. providing methods that can be used to read/write to/from the field rather than accessing the field directly.)
    * Extract Method (to turn part of a larger method into a new method. By breaking down code in smaller pieces, it is more easily understandable. This is also applicable to functions)
    * Generalize Type (to making more general or more abstract some subset of the traits of a specific type. An example of generalizing a type would be moving a method from a child to a parent class for common use by all the parent class’ children, not just the original child.)
    * Pull Up (moving a method from a Subclass into a Superclass. )
    * Push Down (moving a method from a SuperClass into a SubClass.)
    * Rename Method (changing the name of a method into a new one that better reveals its purpose).

The cycle is then repeated, starting with another new test to push forward the functionality.

"Test-Driven Development Mantra" is known as red/green/refactor where red means fail and green is pass.

Benefits
By focusing on the test cases first, one must imagine how the functionality will be used by clients (in this case, the test cases). Therefore, the programmer is only concerned with the interface and not the implementation.
It allows a programmer to focus on the task at hand as the first goal is to make the test pass.
Ensuring that all written code is covered by a test.

Limitations
A test-driven development is only as good as its tests.

Reference
http://en.wikipedia.org/wiki/Test-driven_development
http://en.wikipedia.org/wiki/You_Ain%27t_Gonna_Need_It
http://en.wikipedia.org/wiki/Refactoring

Related Resources
Test::Unit – Ruby Unit Testing Framework
A Guide to Testing the Rails
Test Driven Design for Ruby and Rails
Ruby, Rails, Test::Rails Cheat Sheet

发表在 Ruby on Rails | 标签为 , , | 留下评论

开始支持男同性恋

最近在百度贴吧上经常看到有男人发求找同性伴侣的贴子。我一直对这个很反感。这反感来自好几个原因
1.这样的贴子到处都是。几乎不管哪个分类下都可看到。这算广告贴。即使发贴人对伴侣的要求多么强烈,也无论他寻找的是同性还是异性,都不应该做发垃圾广告这种不道德的行为。
2.这些“同性恋“者到处发贴,好像不是在找恋人,而是在找可以发生一夜情(一夜性)的
同性性伴侣。他们的行为给我同性性爱是一种可以随便发生的性关系,我甚至怀疑他们经常随便乱伦。
3.虽然我看过A片中两个女性发生同性行为,但没有,也不想看两个男性发生性行为,甚至带有传统申美观的我去想象那样的场景都会感到无比的呕心。

但今天我却突然改变了想法。原因是大街上看到的很帅的女生带着另一个女生。这是经常看到的场景,但今天好像我第一次去思考这个问题!李宇春!新时代到来了!如果我不时地遇到这么帅的女生,这么不帅的我不但不能追她,而且她还带走了另一个女生!(带走一个是乐观估计,像李宇春不知道能带走多少!),这样我不但要同众多的男生竞争本来有限的资源,现在还多了很帅的女生成为新的竞争对手!

在面对这个危难时我突然想起了百度上的那些男同性恋贴,犹如在黑暗中看到了几点灯火!多一个男同性恋不就少于二个竞争对手吗?于是我想大声地呼吁:“你们去搞吧,我也开始支持你们了!!!“

发表在 某时雨集 | 一条评论

杀死那个人

战国春秋,夕阳,大漠。
两个武士一前一后地走着。前者中年,带刀,后者带剑,二十出头。前者越走越慢,后者穷追不舍。
“为什么?”中年回头向青年无奈地大叫。
“我 要 杀 你”青年用一种很平静的口气回答,没有停下脚步。
“为什么?”
青年没有回答。
“为什么!!!!???"中年看着不断向自己走来的青年发疯似的大喊。

青年还是没有回答。这时中年已经在前面不远,“拔 刀 吧“
中年摇了摇头,发出一阵苦笑,继续带着疲惫的身躯前走。
“拔 刀 吧“青年平静地重复了一遍。
中年还是没有理会。但随着一丝诡异的笑容,他脸上露出了杀气,然后继续慢慢前走,脚步轻了许多。
青年见中年不理会,停下了脚步,取出水壶,仰面喝水。
就在这时,飞刀,和中年的大刀前后紧随而来。。。
夕阳下只见一身影闪动了几下。。。
青年的脸上多了一道口子,而他的左手的剑穿过中年的身体,滴着鲜红的血。。。
“这不是鲁国的剑法!”中年不解。
“不 是”青年还是那样的平静,像什么事都没有发生一样。
“你是哪人?”中年突然也平静了。
“广 东“
”你是从哪知道我的?“
”网 上“
”哦!“中年大悟,“是博客。。。我明白了。看来我的确不应该上传那张照片!”
“是的 我见到那张带泪的脸的第一刻就注定了你的死亡“
“为了这个,你追了我几千里路?“
”是的 几千里路和2000多年“
“就为了一个小女孩?”中年发出一阵冷笑。
“不 是为了我自己“,青年一边慢慢地从中年身上拔出他的剑,一边回答道,“为了在你那张照片前显得如此无助和平庸的自己 “
“所以你要杀我?”
“是 的“,青年脸上还是没有任何表情。
“就算在自己的梦中?”
青年张口,却没能说出什么。中年躺下后闭目了。
青年从中年身上扯下一块布,一边擦着剑一边说出了含在嘴里的话,“是的,就算在自己的梦中”。第一次,他的语气显得有点低颤。
擦完剑,青年起身向远方走去。
夕阳下他的影子越来越长,直到化成闹钟的指针。

发表在 某时雨集, 盖世武功 | 留下评论

Question-Driven Learning – the learning skill for information age

Question-Driven Learning(QDL) is an effective learning approach. It means learning by solving questions.

Learning was often taken before questions
At school, or university, learning often is done before the questions is given. At school, Questions(mainly included in the  homework) is given after students have the lesson. And, students attend the school, learn knowledge for years, and after they have graduated, they take jobs. This means they meet practical problems (questions) after the learning.

What is the problem with traditional learn method?
1. The knowledge or skills that are learned before you need may never have chance to be used.  Some may be out of range, (for instance — if you learned Computer Science before you become a English teacher), or some may be outdated (if you learned a Computer Skill before you get a computer related job, four years later).
2. The knowledge information have been growing very fast, especially in the last decades, with the help of computers and other information technologies. Information are exploding. There are just to much to learn before you meet real problem, when you don’t know what you really need.
3. If the question come from real life, not from text books or school teachers, you understand the question in a more realistic way, and as the question/problem either stop you from doing some thing, or by solving it you will get rewarded, you will pay more attention to it and try harder to solve it.
4. The skills and knowledge that are learned by doing, will be longer lasting in your memory.

How to do it?
When problems come, ask, search (google) the learn the related knowledge, come up ways to solve the problem. If the problem doesn’t be solved, ask, search and learn more, or skip this problem, deal with another (hope it’s an easier one), after time when by, more problems will be solved. And, always review the questions and solutions, think what you have learned from them, and if necessary, note them down.

And, Still, you need to Learn before the question!
Why? Because Question-Driven Learning has its weakness.
1. If you want to do something, and you meet tons of problems, and you have hundreds of questions want to ask, you should not ask  these questions, instead,  take a book about the subject,  perfectly  a basic, fundamental one, leaving the details behind, and understand this thing you want to do by reading/scanning the book. After you have a specific question about the subject, then you are ready to ask or search.
2. If you don’t know what to do, what to ask or what to search. Reading books or taking an essential course about the subject will be necessary.

发表在 成败几何 | 标签为 | 留下评论

REST and ActiveResource

REST (Representational State Transfer)
REST is An Architectural Style
It uses the following standards:

    *  HTTP
    * URL
    * XML/HTML/GIF/JPEG/etc (Resource Representations)
    * text/xml, text/html, image/gif, image/jpeg, etc (MIME Types)
The Whole WWW is a REST system!

RESTful

RESTafarians

HTTP methods: PUT, GET, POST and DELETE.
database operations: CREATE, READ, UPDATE, DELETE (CRUD)

URI -> Resource
REST Is a Conversation
The verbs of the REST conversation are the aforementioned request methods, while the nouns are URIs, A URI should be only a pointer to a resource.
e.g.
GET "/books/1"
DELETE "/books/1"

URI,URL and URN
A Uniform Resource Identifier (URI), is a compact string of characters used to identify or name a resource.

A Uniform Resource Locator (URL) is a URI that, in addition to identifying a resource, provides means of acting upon or obtaining a representation of the resource by describing its primary access mechanism or network "location".

Uniform Resource Name (URN) is a URI that identifies a resource by name in a particular namespace. (e.g. urn:isbn:0-395-36341-1)

Web service, a software system designed to support interoperable Machine to Machine interaction over a network.

Remote Procedure Call (RPC)

REST Is Design
A clear approach to controller-design that’ll reduce complexity for the implementer and result in an application that behaves as a much better citizen on the general web.

REST gives us a framework for simple but extensible application design.

ActiveResource
RailsConf Keynote: David Heinemeier Hansson Video the World of Resources
online video: http://www.scribemedia.org/2006/07/09/dhh/
download address: http://downloads.scribemedia.net/rails2006/01_dh_hansson.m4v
(the slides http://www.loudthinking.com/lt-files/worldofresources.pdf)

David Heinemeier Hansson’s blog on ActiveResources
http://www.loudthinking.com/arc/000593.html

script/generate scaffold_resource

http://www.xfront.com/REST-Web-Services.html
http://en.wikipedia.org/wiki/Representational_State_Transfer
http://en.wikipedia.org/wiki/Uniform_Resource_Identifier
http://en.wikipedia.org/wiki/Web_service
Rails Cookbook

发表在 Ruby on Rails, 信息处理 | 留下评论

Web Services on Rails note

By Kevin Marshall

The Basics
APIs(application programming interface)

three architectures:
Representational State Transfer (REST)
Simple Object Access Protocol (SOAP)
Extensible Markup Language Remote Procedural(XML-RPC)
(SOAP grew out of XML-RPC)

SOAP
Web service signatures are really just data types that the service either expects or returns.
WSDL(Web Service Description Language)
a WSDL file is an XML document that defines the interface to a SOAP service.

REST
URL, http
The world wide web itself can be considered a REST system.

Searching Yahoo using REST
need:
1.Connect( net lib)
2.store
3.Parse results ( REXML lib)

Yahoo! web service API (up to 5,000 requests/IP per day)

Google AJAX Search API

use the CGI library to escape our search term, ensuring that the search term is safe for use in our HTTP GET request:
query = CGI.escape("SEARCH TEXT")

https://www.google.com/accounts/NewAccount?continue=http://api.google.com/createkey&followup=http://api.google.com/createkey:

Searching Google Using SOAP or SOAP with WSDL Files
UTF-8 can contain special characters that Ruby can’t handle in a string, causing our driver to throw an XSD::ValueSpaceError error upon invocation. To avoid this problem, we manually set our encoding to UTF-8 using the XSD library.
XSD::Charset.encoding = ‘UTF8′

Displaying Photos from Flickr Using XML-RPC

Building Web Service Servers
Make sure you turn off layouts for the methods you’ll be using in your service
Associate RXML templates with the methods in your controllers, instead of RHTML templates
xml is an XML document object that’s available in any RXML template
xml.name("Kevin", :id => 1, "age" => "31")
# creates <name id="1" age="31">Kevin</name>

 xml.exampledata do
     xml.name("Kevin")
 end
 # creates <exampledata><name>Kevin</name></exampledata>

SOAP and XML-RPC Web Service Servers
ActionWebService (AWS)
 script/generate web_service YOURSERVICE YOURMETHOD1 YOURMETHOD2

 three dispatching options, :direct, :delegated, or :layered.
web_service_dispatching_mode:direct
:delegated or :layered is the best way to go for any large or complex web service
With :delegated, clients use a distinct URL for each method in the API
With :layered, clients use the same URL for all attached methods and rely on AWS to route the request based on information passed in its header

:expects and :returns symbols
Ruby types (:string, :int, :bool, :float, :time, :datetime, :date, and :base64), or the names of ActiveRecord::Base or ActionWebService::Struct classes (for example, Greeting or Account), or a single element array to represent arrays of objects (for example, [:string] to represent an array of Strings or [Account] to represent an array of ActionWebService::Struct Account objects).

 raise "Access denied!"

发表在 Ruby on Rails | 留下评论

将日志系统换成了typo

以前的日志系统是基于asp+mssql的。功能上来说很满足我的须要,简单好用。即便这样我也无时不刻想把它换成typo,经过几天的努力,终于如愿以偿了。

为什么要转成TYPO?
typo基于Ruby on Rails语言,而自己正在学习使用ror,所以很希望在使用中熟悉别人的代码写作方法。而且typo可以在linux+mysql+apache的服务器上使用,我准备将使用更多的linux空间,最后去掉windows的服务器。所以我处心积虑地要转向typo.

转向typo

typo是为大多是国外在使用,国内很少用,原因是多方面的。1它要用到rails平台,现在比较难找到空间,2它的功能对国内用户来说不友好,3它到目前只有英文版(4.1开始正在做多语言功能)。

换成typo时我做的第一步就是修改typo系统,
1.将typo和fckeditor整合,去掉textfilter的功能,这样更方便我的使用习惯。
2.改进图片上传功能,使图片上传马上显示出来,这样我就可以copy进fckeditor去,而不用写代码引用图片。
3.修改链接显示样式,本来想改成和原来的blog系统一样,但发现原来的blog使用html后缀,现在所有html文件被过滤了,所以只能改成大概和原来的链接一样。
4.本来想找个好看点的theme,但找来找去竟然没有一个让人满意的,这时怀念起来原来的界面,于是改!将原来的界面搬到了typo上!

比较费时的是数据转换,写了个程序转换,现在转过了所有的文章(个别文章的站内链接还有点问题),对文章分类进行了整理(typo支持一篇文章同属于多个分类)。所有的评论没有转换,还好本来评论就不多。

发表在 其它 | 留下评论

MirrorMask, 2005

MirrorMask, 2005
http://www.imdb.com/title/tt0366780/
一部充满幻想的英国电影。画面真是太奇幻了,可惜的是故事没有一点新意。
6


不知道这是哪里,看起来不错的地方。

发表在 电影评论 | 留下评论