主题:16    

2006/05/06

设计模式资料

 

Principles of Object-Oriented Software Development

2nd edition 

 http://www.cs.vu.nl/~eliens/online/oo/contents.html

其中关于 Reactor 的一篇介绍:

slide: The Reactor pattern

The abstract layout of the software architecture needed to realize the pattern is depicted in slide reactor-structure. The reactor environment must allow for binding handlers to particular types of events. In addition, it must be able to receive events, and select a handler to which the event can be dispatched.


原文网址: http://www.cs.vu.nl/~eliens/online/oo/I/2/reactor.html

 

 

阿涂 发表于 2006-05-06 14:03   阅读( 1279) 评论( 0) 引用( 6) 技术

2006/05/04

good article of mutilcast over tcp/ip

从网络以及操作系统层面讲解了 multcast 的原理以及编程模型,值得一看. 

  This HOWTO tries to cover most aspects related to multicast over TCP/IP networks. So, a lot of information within it is not Linux-specific (just in case you don't use GNU/Linux... yet). Multicast is currently an active area of research and, at the time of writing, many of the "standards" are merely drafts. Keep it in mind while reading the lines that follow.

http://www.tldp.org/HOWTO/Multicast-HOWTO.html

阿涂 发表于 2006-05-04 15:01   阅读( 1254) 评论( 0) 引用( 0) 技术

2006/04/30

关于 unicast, multicast, broadcast

 

 

	      1.unicast、broadcast、multicast在討論MBone之前,一定要先
了解unicast、broadcast、multicast三種傳輸方式的差異。以
Ethernet網路架構而言,封包(Packet)在同一個subnet中傳遞時
,以收方地址來判別該由那台主機接收;若在不同的subnet時,就
要透過路由器(Router)根據收方地址,把這個packet送往收方主
機所在的另一個subnet上。這就是Internet上最普遍、一對一方式
傳送的unicast。

另一類傳輸模式為一對多模式,分為broadcast和multicast 二種
。當broadcast時,同一subnet上所有主機都會收到broadcast
packet。但是broadcast packet會被subnet router擋下來,不會傳
送到另一個subnet,否則網路就會被broadcast packet癱瘓了。

multicast是一對一個群組(group)的傳輸模式,不同於
broadcast的是,同一subnet中只有參加multicast group的主機才
會收到封包,其他的主機就不會受到無謂的干擾,而且multicast
packet會透會mrouter(multicast router)的運作將封包送到另一
個subnet的multicast group。另一方面,multicast和broadcast相
同的特性是,不管接收封包的主機有幾台,都只有一個資料流,也
就是說,同一個subnet裏,不管接收主機的數量,所需的頻寬都是
一樣的。

2.IP multicasting:multicast究竟是如何辦到的呢? 在TCP/IP
的環境中,IP address被分為五大類,如圖一。

(圖一)

(有關Class E部份,目前仍有爭議,還在討論中尚未確定)

以第一個位元start bits的不同,可分為Class A、B、C、D、E
五大類。其中Class D的start bits為"1110",範圍從224.0.0.0~
239.255.255.255,這段位址不屬於任何主機,是特別保留給
multicast address。當一部主機要送multicast packet到某一個
group的主機時,他們之間要先選定一個閒置的Class D IP,並避免
和其他群組的multicast packet IP相同。然後這個multicast
packet送出時,網路上參與這個group的主機,除了接收屬於自己IP
的packet之外,也會接收自這個Class D IP的packet。於是達成了
multicast的目的了。

 参考原文:http://www.ascc.sinica.edu.tw/nl/86/1321/03.txt

阿涂 发表于 2006-04-30 16:22   阅读( 1643) 评论( 1) 引用( 0) 技术

2006/04/20

关于 dom 和 javascript 相关的站点

包含 blog, article 等

http://www.domscripting.com/

阿涂 发表于 2006-04-20 18:41   阅读( 473) 评论( 0) 引用( 0) 技术

一个不错的关于 behaviour Presentation

http://adactio.com/atmedia2005/

 

阿涂 发表于 2006-04-20 18:40   阅读( 464) 评论( 0) 引用( 0) 技术

DOM Scripting: Unobtrusive JavaScript at Its Best

关于 Javascript 和 Dom 相关的脚本描述 ,确切的说是书评

There are changes afoot in the world of JavaScript programming. The JavaScript language is no longer seen as something used to create "nifty" little scripts to jazz up your Web site. It's now used for many important things, and can work with other languages, such as XML and PHP. It's also very powerful when used to interact with Web pages using the Document Object Model (DOM).

DOM Scripting: Web Design with JavaScript and the Document Object Model shows how this can be accomplished. The book is written by Jeremy Keith and is targeted specifically at Web designers. Its purpose is not to be a reference book, but is aimed at teaching the basics of DOM scripting. Here, Jeremy does a good job.

The book begins with a brief history of JavaScript, covers the basics of JavaScript syntax, and then moves right into working with the DOM. Jeremy writes what is called "unobtrusive JavaScript." This means that the JavaScript code is separated from the Web page and is controlled through the use of CSS classes and ids. For instance, to create a popup window, the code, placed in an external file, would generally look like this:

	function newWindow(link) {  var bookWindow;  // Next two lines should be on one line  bookWindow = window.open(link, "new1",    "width=240,height=360,scrollbars,resizable");  if (bookWindow.open) {    bookWindow.close;  }  bookWindow.focus();}
	

In the actual Web page, the code to call the script would be (all on one line):

	<a href="newWindow.html" script_onclick="newWindow('this.href');  return false;">Link for New Window</a>
	

If we use the method Jeremy teaches, we would place this code in an external file:

	function doPopups() {  if (!document.getElementsByTagName) return false;  var links=document.getElementsByTagName("a");  for (var i=0; i < links.length; i++) {    if (links[i].className.match("popup")) {      links[i].onclick=function() {      // Next two lines should be on one line        window.open(this.href, "",          "top=40,left=40,width=500,height=625");        return false;      }    }  }}window.onload=doPopups;
	

Then we would just add the CSS declaration class="popup" to a link, e.g.,

	<a href="newWindow.html" class="popup">Link for New Window</a>
	

Now that's unobtrusive JavaScript! This script, as well as others, are detailed in the book. In fact, there are some excellent scripts in the book that you may be able to apply to your own Web sites. Along the way, Jeremy explains everything in easy-to-understand language.

Jeremy's scripting techniques take into account those browsers that don't have JavaScript support or have it turned off. That means making scripts that degrade gracefully. If your scripts can't run in your visitor's browser, they're of little use if there's no alternative method for interacting with your visitor. Sometimes you can expect your visitors to have JavaScript enabled. For instance, if you create a Web site that is focused on the JavaScript language, you can reasonably expect that your visitors will have JavaScript turned on in their browser. It's a site about JavaScript, right? You wouldn't go to an auto dealership to buy a car and not have a valid driver's license would you? However, if you're building other types of Web sites — e-commerce, reference, news, etc., — you can't assume that your scripts can be accessed by your visitors. That's why writing scripts that degrade gracefully becomes important.

The book also includes a chapter on the future of DOM scripting and a nice reference section, as well. The reference section is also available as a free podbook.

The book has its own Web site, which includes an informative blog. In addition, the Web site that is created using the scripts in the book can be found there. There are a few errors in the book which are listed on the Web site.

Overall, the book is well written and comprehensive. Keep in mind, however, that this book focuses on DOM scripting and doesn't cover JavaScript in its entirety. Nevertheless, Jeremy will have you up and running with your own DOM-related scripts in no time at all. If you design Web sites and want to add another dimension to it, check out this book. You won't be disappointed.

阿涂 发表于 2006-04-20 18:36   阅读( 504) 评论( 0) 引用( 0) 技术

2006/04/06

Implementing Mutual Exclusion for AJA(ZT)

With the increasingly popular AJAX paradigm, a browser page can make requests for server data in the background while the user interface continues to be active in the foreground (hence the "asynchronous" in AJAX). However, the problem exists that these two activities are typically accessing common JavaScript and DOM data structures simultaneously. The classic solutions to this concurrent programming problem are not supplied by JavaScript. This article describes the author's new adaptation of a proven mutual exclusion mechanism that works around the limitations of JavaScript.

Why Mutual Exclusion?

Any time there are multiple threads of program logic that access the same data, and execute at the same time, problems arise. Programs normally assume that the data with which they are interacting is not changing underneath them. The portions of code that access these shared data structures are known as critical sections, and the practice of only letting one run at a time is known as mutual exclusion. This situation arises in AJAX applications when the code, asynchronously handling the reply from an XMLHttpRequest, manipulates data that is also being used by the user interface code. This common data could be JavaScript variables implementing an MVC data model and/or the DOM of the web page itself. The logic of each will break if either is making uncoordinated changes to shared data.

"Wait," you say, "why haven't I run into this problem?" Unfortunately, these kinds of problems are timing dependent (a.k.a. race conditions), so they don't always (or even ever) occur. They are probabilistic based on a number of factors. To be robust, rich internet applications need to prevent this situation by ensuring that these problems can't occur.

So, a mutual exclusion mechanism is needed to ensure that only one critical section will start and finish before another is started. In most mainstream computer languages and execution frameworks, there are (often several) mutual exclusion mechanisms provided, but alas, not in browser-side JavaScript. While there are classic algorithms that implement mutual exclusion without requiring special support from the language or environment, even these expect some basics that are missing from JavaScript and browsers like Internet Explorer. The classic algorithm that follows will then be adapted to work around these browser and language limitations.

更详细内容: http://www.onjava.com/pub/a/onjava/2006/04/05/ajax-mutual-exclusion.html

阿涂 发表于 2006-04-06 11:22   阅读( 386) 评论( 0) 引用( 0) 技术

2006/04/05

一个基于LAMP的开源 Tagging Engine

http://getluky.net/freetag/

关于项目描述:

Description

Freetag is an easy tagging and folksonomy-enabled plugin for use with MySQL-PHP applications. It allows you to create tags on existing database schemas, and access and manage your tags through a robust API.

作者访谈:

http://tagsonomy.com/

 

 

阿涂 发表于 2006-04-05 23:24   阅读( 776) 评论( 0) 引用( 0) 技术

2006/03/15

一篇 Linux 环境下安装 apache 2.0.x + ruby + rails + fastcgi 很具体的向导

原文网址:

http://wiki.rubyonrails.com/rails/pages/HowtoSetupApacheWithFastCGIAndRubyBindings

 

How to install Apache, Ruby, RubyGems, Rails, and FastCGI? under Linux

  1. Become root and go to a directory to work in
    		su rootcd /usr/local/src
    		
  2. Download all of the needed files. These versions may be out of date, so you might want to go find the latest.
    		wget http://xyz.lcs.mit.edu/ruby/ruby-1.8.2.tar.gzwget http://rubyforge.org/frs/download.php/3700/rubygems-0.8.10.tgzwget http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gzwget http://www.fastcgi.com/dist/mod_fastcgi-2.4.2.tar.gzwget http://mirrors.ccs.neu.edu/Apache/dist/httpd/httpd-2.0.53.tar.gz
    		
  3. Install Ruby
    		tar -zxvf ruby-1.8.2.tar.gzcd ruby-1.8.2./configuremakemake testmake installcd ..
    		
  4. Install Ruby Gems
    		tar -zxvf rubygems-0.8.10.tgzcd rubygems-0.8.10ruby setup.rb    :Install required dependency rake? [Yn]  yInstall required dependency activesupport? [Yn]  yInstall required dependency activerecord? [Yn]  yInstall required dependency actionpack? [Yn]  yInstall required dependency actionmailer? [Yn]  yInstall required dependency actionwebservice? [Yn]  y    :cd ..
    		
  5. Install Apache (if needed—if you have an existing Apache installation & know what you are doing this step can be skipped)
    		tar -zxvf httpd-2.0.53.tar.gzcd httpd-2.0.53./configure --enable-rewrite --enable-cgimakemake installcd ..
    		
  6. Install FastCGI?
    		tar -zxvf fcgi-2.4.0.tar.gz cd fcgi-2.4.0./configuremakemake install
    		
  7. Install mod_fastcgi for Apache (note that this assumes you are using Apache-2.x, etc.; if you are using Apache 1.3, DSOs, etc. read the INSTALL file.
  8. Install Rails
    		gem install rails
    		
  9. Install the fcgi gem
    		gem install fcgi
    		

    On FreeBSD, If you receive “ERROR: While executing gem” stating “checking for fcgiapp.h… no” then you will have to run the gem install with alternate syntax:
    		gem install fcgi -- --with-fcgi-include=/usr/local/include --with-fcgi-lib=/usr/local/lib
    		
  10. Edit your Apache configuration (typically found somewhere like /usr/local/apache2/conf/httpd.conf or /etc/httpd/conf/httpd.conf) and add these lines:
    		<Directory /var/www/>    AllowOverride all</Directory>LoadModule fastcgi_module modules/mod_fastcgi.soAddHandler fastcgi-script .fcgi<VirtualHost *:80>    ServerAdmin webmaster@example.com    DocumentRoot /var/www/rails/testapp/public    ServerName www.example.com    ErrorLog /var/log/httpd/testapp-error_log    CustomLog /var/log/httpd/testapp-access_log common    Options Indexes ExecCGI FollowSymLinks    RewriteEngine On</VirtualHost>
    		
  11. Start Apache
    		/usr/local/apache2/bin/apachectl start
    		
  12. Go to http://www.example.com and see the Rails welcome page.
  13. Set up a database for Rails in database.yml (or see HowToUseRailsWithoutADatabase).
  14. Create a simple controller for testing Rails
    		cd /var/www/rails/testapp/publicrm index.htmlcd ..script/generate controller home index
    		
  15. Go to www.example.com/home/index and see a default view, running with normal cgi.
  16. Enable FastCGI?
    1. Edit /var/www/rails/testapp/public/.htaccess and change dispatch.*cgi* to dispatch.*fcgi*
    2. Edit /var/www/rails/testapp/public/dispatch.fcgi (in rails 0.13.1 this is within the rails installation: lib/fcgi_handler.rb) and change
      			require 'fcgi'
      			

      to
      			require 'rubygems'require_gem 'fcgi'
      			
  17. Go to www.example.com/home/index and see a default view again, but with fcgi

Troubleshooting Suggestions
Make sure that you delete any ruby session files in your /tmp directory before switching to dispatch.fcgi. If you tested with cgi, there might be some with different permission that what apache (fastcgi) can read and will cause issue.

If you want to see if fastcgi is working with ruby, try pasting the following into test.fcgi (in your rails/public dir). You will need to make sure the file has 755 permissions (chmod 755 test.fcgi).

			#!/usr/local/bin/rubyrequire 'cgi'require 'rubygems'require_gem 'fcgi' FCGI.each_cgi do |cgi|    content = ''    env = []    cgi.env_table.each do |k,v|      env << [k,v]    end    env.sort!    env.each do |k,v|      content << %Q(#{k} => #{v}<br>\n)    end    cgi.out{content} end

The above test was working but I didn´t get the dispatcher running under apache2 (self built) until i changed the dependencies of rails-0.14.1/lib/fcgi_handler.rb to:

			require 'cgi'require 'rubygems'require_gem 'fcgi'require 'logger'require 'dispatcher'require 'rbconfig'class RailsFCGIHandler...

 

I don´t know why this is like this (why the dependencies in the dispatcher should be wrong) but it helped.


I’ve been bitten by two things with the Apache configuration: I had MultiViews on, and I was redirecting /some/url.html to /some/url because I don’t want file extensions in my URLs. The second rule causes endless redirect looping with standard Rails’ .htaccess, and MultiViews interferes badly with Rails’ caching. So, keep MultiViews off, and be careful with those redirects. —Matijs van Zuijlen



I have yet to get Apache fcgi working Windows XP SP2. I’ve got Apache working with Rails but it’s slow as mud. I’ve downloaded all the software that I can find and put in the http.conf file the recommended Apache configuration but can’t tell if fcgi is working or not.

Does anyone have a simple step by step recipe to get Apache (v2) on Windows XP Prof running fcgi? I found a test page for Rails but it doesn’t render the link

			<html>  <head>    <title>Ajax Demo</title>    <%= javascript_include_tag "prototype" %>  </head>  <body>    <h1>What time is it?</h1>    <div id="time_div">      I don't have the time, but      <%= link_to_remote( "click here",                         :update => "time_div",                         :url =>{ :action => :say_when }) %>      and I will look it up.    </div>  </body></html>
			

 

I get the page minus the “click here” link????


For anyone trying to get fastcgi working after installing the gem version of the ruby fastcgi lib, I found uninstalling it, then loading the library version and building it, fixed all problems. Download from here http://raa.ruby-lang.org/project/fcgi/ read the README and build and install, and fastcgi starts working.

阿涂 发表于 2006-03-15 20:12   阅读( 2624) 评论( 5) 引用( 6) 技术

2006/03/07

Architectural Styles and the Design of Network-based Softwar

关于网络应用程序架构不错的文章

http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm

阿涂 发表于 2006-03-07 11:34   阅读( 589) 评论( 0) 引用( 0) 技术

您的浏览器可能不支持Frame, 优友地带需要使用Frame才能显示正常页面!