1/12/2009

快速在Ubuntu 8.10 安装 lamp开发环境

在日常开发中,我们主要使用LAMP,Ubuntu提供了简单的,快速的配置该服务器环境的方法,步骤如下:

1 使用tasksel安装LAMP套件

sudo tasksel install lamp-server

2 基于ZF的开发要使用rewrite 模块,所以在终端中执行

sudo a2enmod rewrite

指令后,即启用了 Mod_rewrite 模块。

3 配置虚拟目录位置(修改红色部分)




<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /home/edwin/Zend/workspaces/DefaultWorkspace/Member-shouxi/Public
<directory>
Options FollowSymLinks
AllowOverride None
</directory>
<directory home/edwin/zend/workspaces/defaultworkspace/shouxi/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<directory usr="" lib="" bin="">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined

Alias /doc/ "/usr/share/doc/"
<directory usr="" share="" doc="">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</directory>

</VirtualHost>


4 重启apache 即可


在 Ubuntu 8.10下设置静态IP和虚拟机

步骤1-卸载 Gnome Network Manager:这是必须的一步,因为不卸载的话,不过你如何设置,重启后都会被重置。这个就是Bug所在之处。

用下列命令卸载:

sudo update-rc.d -f NetworkManager remove

这会禁用并且卸载Gnome Network Manager应用程序。然后你需要重启

步骤2-手动修改网络配置:这步你需要手动编辑网络配置文件。

2.1-手动修改网络配置文件:

sudo gedit /etc/network/interfaces

加入(或者修改)下列行:

auto lo eth0
iface lo inet loopback
iface eth0 inet static
address 192.168.1.96
netmask 255.255.255.0
gateway 192.168.1.1

auto eth0:0
iface eth0:0 inet static
address 192.168.1.97
netmask 255.255.255.0
gateway 192.168.1.1

auto eth0:1
iface eth0:1 inet static
address 192.168.1.98
netmask 255.255.255.0
gateway 192.168.1.1

保存修改。

2.2-手动修改DNS配置文件:

sudo nano /etc/resolv.conf

加入(或者修改)下列行:

# Generated by NetworkManager
nameserver 192.168.1.1
nameserver 202.106.46.151

保存修改。

2.3- 手动重启网络服务:

sudo /etc/init.d/networking restart

返回结果如下:

*Reconfiguring network interfaces… [OK]

现在,你可以在终端里输入ipconfig命令来查看你修改的结果。如果不对,你还需要重启下。

设置apache的虚拟机
1 在workspace里添加doucument root
2 在/etc/apache2/sites-available 创建虚拟机配置文件 192.168.1.96, 内容如下:


<VirtualHost 192.168.1.97:80>
ServerAdmin webmaster@localhost

DocumentRoot /home/edwin/Zend/workspaces/DefaultWorkspace/ZfProjects-Main/Public

Options FollowSymLinks
AllowOverride None


Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all


ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all


ErrorLog /var/log/apache2/192.168.1.97.error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/192.168.1.97.access.log combined

Alias /doc/ "/usr/share/doc/"

Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128


<VirtualHost *:80>

3 重启apache 服务
sudo a2ensite 192.168.1.97
sudo /etc/init.d/apache2 restart

1/03/2009

Pseudocode Guidline

原文:《Pseudocode 》by Naomi Nishimura
刘建文略译(http://blog.csdn.net/keminlau)

In the text and lectures, algorithms will often be expressed in pseudocode, a mixture of code and English (for specific not necessarily good examples of particular pseudocodes, see p. 17 of the course text, or the examples in the books The Design and Analysis of Computer Algorithms by Aho, Hopcroft, and Ullman, Addison-Wesley, 1974, Computer Algorithms: Introduction to Design and Analysis by Baase, 1978, and Fundamentals of Computer Algorithms by Horowitz and Sahni, Computer Science Press, 1984). While understanding pseudocode is usually not difficult, writing it can be a challenge.

伪代码是英语与代码的混合物,理解伪代码不难,但是编写伪代码则很具有挑战性。

Why use pseudocode at all? Pseudocode strikes a sometimes precarious balance between the understandability and informality of English and the precision of code. If we write an algorithm in English, the description may be at so high a level that it is difficult to analyze the algorithm and to transform it into code.

If instead we write the algorithm in code, we have invested a lot of time in determining the details of an algorithm we may not choose to implement (as we typically wish to analyze algorithms BEFORE deciding which one to implement). The goal of writing pseudocode, then, is to provide a high-level description of an algorithm which facilitates analysis and eventual coding (should it be deemed to be a “good” algorithm) but at the same time suppresses many of the details that vanish with asymptotic notation. Finding the right level in the tradeoff between readability and precision can be tricky……

为什么一定要使用伪代码?(因为)伪代码平衡了英语(自然语言)的易理解性和非形式所带来的模糊性与代码的精确性之的矛盾。如果我们使用英语(自然语言)编写算法,那么算法描述可能太过高层而很难对算法进行分析并转化成实际代码;如果我们用代码编写算法,我们得花大量的时间在一些我们可能最终不会实现的代码细节上(缘于我们一般在实现算法之前看对算法逻辑进行分析)。编写伪代码(以一个适当的表述高度描述算法)的目的是为了便于算法分析并最终实现编码,但同时抑制住在渐近记法(asymptotic notation)被抹去的大量细节。在可读性与精确性之间找到一个适当的平衡点是相当的困难(tricky:问题难以处理,需要莫大的心力)的……

Just as a proof is written with a type of reader in mind (hence proofs in undergraduate textbooks tend to have more details than those in journal papers), algorithms written for different audiences may be written at different levels of detail. In assignments and exams for the course, you need to demonstrate your knowledge without obscuring使变模糊 the big picture with unneeded detail. Here are a few general guidelines for checking your pseudocode:

好比一个(数学)证明有预定的读者类型一样,面对不同的读者,算法的编写详细程度也不同。以下是指导伪代码编写的参考原则:
1. Mimic模仿 good code and good English. Using aspects of both systems means adhering to the style rules of both to some degree. It is still important that variable names be mnemonic, comments be included where useful, and English phrases be comprehensible (full sentences are usually not necessary).

仿照好代码或好英文(的表述方式)。意思是说在某种程度上吸收二者在表述上的优点。比如,使用易记的变量名、适当的使用注释和使用好理解的英语短语等。 2. Ignore unnecessary details. If you are worrying about the placement of commas, you are using too much detail. It is a good idea to use some convention to group statements (begin/end, brackets, or whatever else is clear), but you shouldn't obsess about syntax.

忽略不必要的细节。如果你频繁地使用逗号,意味着你写得太细了。使用begin/end或括号给组合多条语句是不错的主意,不过不能被语法分心。
3. Don't belabour无必要的解释 the obvious. In many cases, the type of a variable is clear from context; unless it is critical that it is specified to be an integer or real, it is often unnecessary to make it explicit.

不要对很显然的东西作解释。很多时候,变量的类型在上下文中是很明显的,除非它的特定类型(比如是整数或实数)是至关重要,不然没必要显式说明它的类型。

4. Take advantage of programming shorthands. Using if-then-else or looping structures is more concise than writing out the equivalent in English; general constructs that are not peculiar to a small number of languages are good candidates for use in pseudocode. Using parameters in specifying procedures is concise, clear, and accurate, and hence should not be omitted from pseudocode.

使用编程的短记(shorthands)工具。使用if-then-else 或循环结构比用英语表达更简洁;一些通用的语言构造也可在伪代码中使用(FIXME)。给函数指定参数是简洁、明了和准确的,不应该在伪代码中去除。

5. Consider the context. If you are writing an algorithm for quicksort, the statement "use quicksort to sort the values" is hiding too much detail; if we have already studied quicksort in class and later use it as a subroutine in another algorithm, the statement would be appropriate to use.

考虑上下文。如果你正为一个快速排序写一个算法,那么语句“use quicksort to sort the value”就隐藏了太多的细节了;如果你已经学习过快速排序算法,而现在把它作为一个另一个算法的子过程,那么可以用那句语句来表述。

6. Don't lose sight of the underlying model. It should be possible to “see through” your pseudocode to the model below; if not (that is, you are not able to analyze the algorithm easily), it is written at too high a level.

不迷惑于算法底下的模型。看透你的伪代码底下的模型是可能的,如是不行,证明编写的太高层次了(不够详细),那样你很难分析算法。

7. Check for balance. If the pseudocode is hard for a person to read or difficult to translate into working code (or worse yet, both!), then something is wrong with the level of detail you have chosen to use.

检验(可读性与精确性)平衡性。如果伪代码很难读懂或很难翻译成源代码,那么你的伪代码编写的详细程度必定在什么地方出了问题了。

(author: Naomi Nishimura)

Kemin said:
b.弱智的人玩IDE,聪明的人玩编程语言,智慧的人玩伪代码,当然还有更高的级别,想知道?去问上帝吧。
Kemin said:
b. 看来伪代码是亲自然语言多一点,还是亲源代码多一点是没准的,也没必须太准,太受限,因为只要代码读者能花点时间进入状态,进入问题的上下文,那即便是很 “烦人”很magic的源代码也看得懂,不然自然语言并且有人讲解也听不懂看不明。所以伪代码的抽象level去到哪不是一成不变的,因人而异。
参考

* http://en.wikipedia.org/wiki/Pseudocode
* http://www.coderookie.com/2006/tutorial/the-pseudocode-programming-process/
* 伪代码的使用 http://www.comp.nus.edu.sg/~xujia/mirror/algorithm.myrice.com/algorithm/pseudocode.htm
* PSEUDOCODE STANDARD http://users.csc.calpoly.edu/~jdalbey/SWE/pdl_std.html
* 算法描述中的'Pseudocode Conventions' http://bigwhite.blogbus.com/logs/2443206.html

1/01/2009

ubuntu 连接windows远程桌面

sudo apt-get install rdesktop
rdesktop 192.168.0.1

-f 全屏
-a 16位色
默认端口是3389(linux 22 sh)
注意:windows 的服务中的 Terminal Servies 需要开启。我的电脑 右键 属性 远程中,勾选 允许远程用户链接到此计算机。另外,退出的时候选择注销,而不是关机!

更多参数:
-u xxxxxx 登录用户,可选
-p xxxxxx 登录密码,可选
-r clipboard:PRIMARYCLIPBOARD 重要,剪贴板可以与远程桌面交互
-a 16 颜色,可选,不过最高就是16位
-z 压缩,可选
-g 1024x768 分辨率,可选,缺省是一种比当前本地桌面低的分辨率
-P 缓冲,可选
-r disk:wj=/home/magicgod 映射虚拟盘,可选,会在远程机器的网上邻居里虚拟出一个映射盘,功能很强,甚至可以是软盘或光盘
-r sound:off 关闭声音,当然也可以把远程发的声音映射到本地来。