jQuery.validate API-中文 详细

Posted by Jerry in javascript | Leave a comment

名称

返回类型

描述

validate(options)

返回:Validator

验证所选的FORM

valid()

返回:Boolean

检查是否验证通过

rules()

返回:Options

返回元素的验证规则

rules(“add”,rules)

返回:Options

增加验证规则

rules(“remove”,rules)

返回:Options

删除验证规则

removeAttrs(attributes)

返回:Options

删除特殊属性并且返回他们

Custom selectors

:blank

返回:Validator

没有值的筛选器

:filled

返回:Array <Element >

有值的筛选器

:unchecked

返回:Array <Element >

没选择的元素的筛选器

Utilities

jQuery.format

(template,argument ,argumentN…)

返回:String

用参数代替模板中的 {n}

 

Validator:

validate方法返回一个Validator对象,它有很多方法, 让你能使用引发校验程序或者改变form的内容. validator对象有很多方法,但下面只是列出常用的

form()

返回:Boolean

验证form返回成功还是失败

element(element)

返回:Boolean

验证单个元素是成功还是失败

resetForm()

返回:undefined

把前面验证的FORM恢复到验证前原来的状态

showErrors(errors)

返回:undefined

显示特定的错误信息

 

Validator functions:

setDefaults(defaults)

返回:undefined

改变默认的设置

addMethod(name,method,message)

返回:undefined

添加一个新的验证方法. 必须包括一个独一无二的名字,一个JAVASCRIPT的方法和一个默认的信息

addClassRules(name,rules)

返回:undefined

增加组合验证类型 在一个类里面用多种验证方法里比较有用

addClassRules(rules)

返回:undefined

增加组合验证类型 在一个类里面用多种验证方法里比较有用,这个是一下子加多个

 

内置验证方式:

required()

返回:Boolean

必填验证元素

required(dependency-expression)

返回:Boolean

必填元素依赖于表达式的结果

required(dependency-callback)

返回:Boolean

必填元素依赖于回调函数的结果

remote(url)

返回:Boolean

请求远程校验。url通常是一个远程调用方法

minlength(length)

返回:Boolean

设置最小长度

maxlength(length)

返回:Boolean

设置最大长度

rangelength(range)

返回:Boolean

设置一个长度范围[min,max]

min(value)

返回:Boolean

设置最大值

max(value)

返回:Boolean

设置最小值

email()

返回:Boolean

验证电子邮箱格式

range(range)

返回:Boolean

设置值的范围

url()

返回:Boolean

验证URL格式

date()

返回:Boolean

验证日期格式(类似30/30/2008的格式,不验证日期准确性只验证格式)

dateISO()

返回:Boolean

验证ISO类型的日期格式

dateDE()

返回:Boolean

验证德式的日期格式(29.04.1994 or 1.1.2006

number()

返回:Boolean

验证十进制数字(包括小数的)

digits()

返回:Boolean

验证整数

creditcard()

返回:Boolean

验证信用卡号

accept(extension)

返回:Boolean

验证相同后缀名的字符串

equalTo(other)

返回:Boolean

验证两个输入框的内容是否相同

phoneUS()

返回:Boolean

验证美式的电话号码

 

validate ()的可选项:

debug:进行调试模式(表单不提交):

$(“.selector”).validate

({

   debug:true

})

把调试设置为默认:

$.validator.setDefaults({

   debug:true

})

submitHandler:

通过验证后运行的函数,里面要加上表单提交的函数,否则表单不会提交

$(“.selector”).validate({

   submitHandler:function(form) {

$(form).ajaxSubmit();

   }

})

ignore:

对某些元素不进行验证

$(“#myform”).validate({

   ignore:”.ignore”

})

rules:

自定义规则,key:value的形式,key是要验证的元素,value可以是字符串或对象

$(“.selector”).validate({

   rules:{

     name:”required”,

     email:{

       required:true,

       email:true

     }

   }

})

messages:

自定义的提示信息key:value的形式key是要验证的元素,值是字符串或函数

$(“.selector”).validate({

   rules:{

     name:”required”,

     email:{

       required:true,

       email:true

     }

   },

   messages:{

     name:”Name不能为空“,

     email:{

       required:”E-mail不能为空“,

       email:”E-mail地址不正确

     }

   }

})

groups:

对一组元素的验证,用一个错误提示,error Placement控制把出错信息放在哪里

$(“#myform”).validate({

  groups:{

    username:”fname lname”

  },

  errorPlacement:function(error,element) {

     if (element.attr(“name”) == “fname” || element.attr(“name”) == “lname”)

       error.insertAfter(“#lastname”);

     else

       error.insertAfter(element);

   },

   debug:true

})

Onubmit Boolean 默认:true

是否提交时验证

$(“.selector”).validate({

   onsubmit:false

})

onfocusout Boolean 默认:true 

是否在获取焦点时验证

$(“.selector”).validate({

   onfocusout:false

})

onkeyup Boolean 默认:true 

是否在敲击键盘时验证

$(“.selector”).validate({

   onkeyup:false

})

onclick Boolean 默认:true

是否在鼠标点击时验证(一般验证checkbox,radiobox

$(“.selector”).validate({

   onclick:false

})

focusInvalid Boolean 默认:true

提交表单后,未通过验证的表单(第一个或提交之前获得焦点的未通过验证的表单)会获得焦点

$(“.selector”).validate({

   focusInvalid:false

})

focusCleanup Boolean 默认:false

当未通过验证的元素获得焦点时,并移除错误提示(避免和 focusInvalid.一起使用)

$(“.selector”).validate({

   focusCleanup:true

})

errorClass String默认:”error”

指定错误提示的css类名,可以自定义错误提示的样式

$(“.selector”).validate({

   errorClass:”invalid”

})

errorElement String 默认:”label”

使用什么标签标记错误

$(“.selector”).validate

   errorElement:”em”

})

wrapper String

使用什么标签再把上边的errorELement包起来

$(“.selector”).validate({

   wrapper:”li”

})

errorLabelContainer Selector

把错误信息统一放在一个容器里面

$(“#myform”).validate({

   errorLabelContainer:”#messageBox”,

   wrapper:”li”,

   submitHandler:function() { alert(“Submitted!”) }

})

 

showErrors:

跟一个函数,可以显示总共有多少个未通过验证的元素

$(“.selector”).validate({

   showErrors:function(errorMap,errorList) {

        $(“#summary”).html(“Your form contains ” + this.numberOfInvalids() + ” errors,see details below.”);

        this.defaultShowErrors();

   }

})

errorPlacement:

跟一个函数,可以自定义错误放到哪里

$(“#myform”).validate({

  rrorPlacement:function(error,element) {  error.appendTo(element.parent(“td”).next(“td”));

   },

   debug:true

 

})

success:

要验证的元素通过验证后的动作,如果跟一个字符串,会当做一个css,也可跟一个函数

$("#myform").validate({
        success:"valid",
        submitHandler:function()
        { alert("Submitted!") }
})

highlight:

可以给未通过验证的元素加效果,闪烁等

 

 

addMethod(name,method,message)方法:

参数name是添加的方法的名字

参数method是一个函数,接收三个参数(value,element,param) value是元素的值,element是元素本身 param是参数,我们可以用addMethod来添加除built-in Validation methods之外的验证方法 比如有一个字段,只能输一个字母,范围是a-f,写法如下:

$.validator.addMethod("af",function(value,element,params){
   if(value.length>1){
    return false;
   }
   if(value>=params[0] && value<=params[1]){
    return true;
   }else{
    return false;
   }
},"必须是一个字母,且a-f");
//用的时候,比如有个表单字段的id="username",则在rules中写
username:{
   af:["a","f"]
}

addMethod的第一个参数,就是添加的验证方法的名子,这时是af

addMethod的第三个参数,就是自定义的错误提示,这里的提示为:"必须是一个字母,a-f"

addMethod的第二个参数,是一个函数,这个比较重要,决定了用这个验证方法时的写法

如果只有一个参数,直接写,如果af:"a",那么a就是这个唯一的参数,如果多个参数,用在[],用逗号分开

 

meta String方式:

<span style="font-size: 12px; line-height: 18px; white-space: normal;">
$("#myform").validate({ meta:"validate", submitHandler:function() { alert("Submitted!") } })
</span>
<script type="text/javascript" src="js/jquery.metadata.js"></script>
<script type="text/javascript" src="js/jquery.validate.js"></script>
<form id="myform">
<input class="{validate:{ required:true,email:true }}" type="text" name="email" />
<input type="submit" value="Submit" /></form>

可视区域(可见区域)图片加载,图片延迟加载 javascript lazyload

Posted by jerry.jobs in javascript | Leave a comment

在页面加载区域较大时,并不是所有的图片用户都会浏览到。
如果同步加载用户却不曾浏览到,这就造成资源浪费。
何不搜索可视区域图片并异步加载。

下图为浏览器网页坐标系。
1、A方框为可视区域;
2、红色小方框分别为 1 2 3 号图片(图片使用Php加载,请放入Php环境执行);
3、leftTop(ltx,lty) 代表可视区域左上角坐标;
4、rightBottom(rbx,rby) 代表可视区域右下角坐标;
5、targetPoint (offset.left,offset.top) 代表图片左上角坐标;

示例代码展示流程:
注意:count.log文件将记录当前已读取的图片,在展示前请用可提示更新的编辑器打开(如:EditPlus)。
1、打开页面即可看到 1号图片 (count.log 记录为 1);
2、将滚轮向下拖动则可看到 2号图片;(count.log 记录为 1 2);
2、将滚轮向上并向右拖动则可看到 3号图片;(count.log 记录为 1 2 3,1号图片不会重复加载);
主要脚本:

 


// 注意本方法建立在jquery基础之上,必先加载jquery

function lazyLoad(){
    jQuery("img[src^='#']").each(function(){
        var img = jQuery(this);
        var win = jQuery(window);
        /*
        leftTop(ltx,lty)
        rightBottom(rbx,rby)
        targetPoint (offset.left,offset.top)
        */
        var offset = img.offset();
        var ltx = win.scrollLeft(); // left top x
        var lty = win.scrollTop(); // left top y

        var rbx = win.scrollLeft()  + win.width(); // right bottom x
        var rby = win.scrollTop() + win.height(); // right bottom y
        if (offset.left >= ltx && offset.left <= rbx
                      && offset.top >= lty && offset.top <= rby ) {
            img.attr("src",img.attr("src").substr(1));
        }
    });
}

jQuery(window).scroll( function() {
    lazyLoad();
});

jQuery(function() {
    lazyLoad();
});

下载演示例子: imageLazyLoad

apache虚拟主机 配置 apache绑定域名 教程

Posted by Jerry in Knowledge | Leave a comment

今天一个朋友问我apache怎么绑定域名,我跟他说了一下,查apache官方文档很简单,但是他说,会者不难!那好吧,我写一个教程也方便他下次忘记了可以再来看一下。
接下来我们相对于虚拟主机我也不用解释了,不懂的看链接自己看。
我们接下来要做的就是查看文档来确定一下怎么用(我们以2.2版本为例子来说明)。

<VirtualHost> and </VirtualHost> are used to enclose a group of directives that will apply only to a particular virtual host. Any directive that is allowed in a virtual host context may be used. When the server receives a request for a document on a particular virtual host, it uses the configuration directives enclosed in the <VirtualHost> section. Addr can be:

大概意思就是:

<VirtualHost></VirtualHost>用于封装一组仅作用于特定虚拟主机的指令。任何在虚拟主机配置中可以使用的指令也同样可以在这里使用。当服务器接受了一个特定虚拟主机的文档请求时,它会使用封装在<VirtualHost>配置段中的指令。Addr可以是:

  • 虚拟主机的IP地址
  • 虚拟主机IP地址对应的完整域名
  • 字符”*“,仅与”NameVirtualHost *“配合使用以匹配所有的IP地址
  • 字符串”_default_“,与基于IP的虚拟主机联用以捕获所有没有匹配的IP地址
#使用这个之前 先要写上这句话。
NameVirtualHost ip:prot  # ip是监听的ip就是域名解释到的ip 当然也可以监听所有ip就是“*”,端口通常使用80也

<VirtualHost 127.0.0.1>
     ServerAdmin    webmaster@host.foo.com      #  网站管理员邮箱
     DocumentRoot   /www/docs/host.foo.com      #  网站目录
     ServerName     host.foo.com                #  网站域名
     ErrorLog       logs/host.foo.com-error_log #  错误日志   关于日志级别这里不多说。
     TransferLog    logs/host.foo.com-access_log# 访问日志记录名子和地址。
</VirtualHost>
把以上代码加入到http.conf的最后,重启apache服务就生效。
比如你要在您本地测试这个您可能 这么来。

  1. 找到windows中的host文件,位置是 (C:\WINDOWS\system32\drivers\etc\host) 。
  2. 加入新的域名和映射IP 例如: www.test.com   127.0.0.1
  3. 配置apche把 ServerName 后成对应成 www.test.com
  4. 重启apache服务  打开浏览器测试。
注意事项
  1. 你可绑定多个域名,但是这些域名只能在你这台电脑中使用(原因您自己想)。
  2. 您访问的域名得配置到apache以后重启apache服务。
  3. 您必需监听到 127.0.0.1这个ip或者是您的内,如果您在host中映射的是您的内网ip 那apache也应该是监听到您的内网ip。通常情况我们会监听所有的ip,如果有特别的要求分开绑定。
  4. apache配置中的  NameVirtualHost *:80 一般这么写 这一条一定不能忘记了。
over.
绑定多少 域名那就重复  VirtualHost 节点即可。










JAVA转换人民币大写,财务处理JAVA转换金额人民币大写

Posted by Jerry in java | Leave a comment

java 转化金额成人民币大写通用方法工具类

package cn.classd.util;

/**
 * programmed by HuangHeliang 2009.04.15 10:20:51
 */
public final class ChangeRMB {

	// 每个数字对应的大写
	private static final String[] num = { "零", "壹", "贰", "叁", "肆", "伍", "陆",
			"柒", "捌", "玖", };

	// 从低到高排列的单位
	private static final String[] bit = { "圆", "拾", "佰", "仟", "万", "拾", "佰",
			"仟", "亿", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿" };

	// 金额里面的角和分
	private static final String[] jf = { "角", "分" };

	/**
	 * 处理金额的整数部分,返回"...圆整"
	 *
	 * @param integer
	 * @return String
	 * @throws Exception
	 */
	public static String praseUpcaseRMB(String integer) throws Exception {
		StringBuilder sbdr = new StringBuilder("");

		int j = integer.length();

		if (j > bit.length)
			throw new Exception("\n只能处理亿万亿以内的数据(含亿万亿)!");

		char[] rmb = integer.toCharArray();
		for (int i = 0; i < rmb.length; i++) {
			int numLocate = Integer.parseInt("" + rmb[i]); // 大写数字位置
			int bitLocate = j - 1 - i; // 数字单位的位置

			/*
			 * 连续大写零只添加一个
			 */
			if (numLocate == 0) {
				if (!sbdr.toString().endsWith(num[0])) {
					sbdr.append(num[numLocate]);
				}
				continue;
			}

			/*
			 * 下面的if语句保证 10065004583.05-->壹佰亿陆仟伍佰万肆仟伍佰捌拾叁圆零伍分
			 */
			if (bit[bitLocate].equals("仟")) {
				String s = sbdr.toString();
				if (!s.endsWith(bit[bitLocate + 1]) && s.length() > 0) {
					if (s.endsWith(num[0])) {
						sbdr.deleteCharAt(sbdr.length() - 1);
					}
					sbdr.append(bit[bitLocate + 1]);
				}
			}

			sbdr.append(num[numLocate]);
			sbdr.append(bit[bitLocate]);

		}// end for

		/*
		 * 去掉结尾"零"后,补全
		 */
		if (sbdr.toString().endsWith(num[0])) {
			sbdr.deleteCharAt(sbdr.length() - 1);
			sbdr.append("圆整");
		} else {
			sbdr.append("整");
		}

		return sbdr.toString();
	}

	/**
	 * 处理带小数的金额,整数部分交由上一个方法处理,小数部分自己处理
	 *
	 * @param integer
	 * @param decimal
	 * @return String
	 * @throws Exception
	 */
	public static String praseUpcaseRMB(String integer, String decimal)
			throws Exception {

		String ret = ChangeRMB.praseUpcaseRMB(integer);
		ret = ret.split("整")[0]; // 处理整数部分
		StringBuilder sbdr = new StringBuilder("");
		sbdr.append(ret);

		char[] rmbjf = decimal.toCharArray();
		for (int i = 0; i < rmbjf.length; i++) {
			int locate = Integer.parseInt("" + rmbjf[i]);
			if (locate == 0) {
				if (!sbdr.toString().endsWith(num[0])) {
					sbdr.append(num[locate]);
				}
				continue;
			}
			sbdr.append(num[locate]);
			sbdr.append(jf[i]);
		}

		return sbdr.toString();
	}

	/**
	 * 将double形式的字符串(有两位小数或无小数)转换成人民币的大写格式
	 *
	 * @param doubleStr
	 * @return String
	 * @throws Exception
	 */
	public static String doChangeRMB(String doubleStr) throws Exception {
		String result = null;

		if (doubleStr.contains(".")) { // 金额带小数
			int dotloc = doubleStr.indexOf(".");
			int strlen = doubleStr.length();

			String integer = doubleStr.substring(0, dotloc);
			String decimal = doubleStr.substring(dotloc + 1, strlen);

			result = ChangeRMB.praseUpcaseRMB(integer, decimal);
		} else { // 金额是整数
			String integer = doubleStr;
			result = ChangeRMB.praseUpcaseRMB(integer);
		}

		return result;
	}

	/**
	 * 将double数值(有两位小数或无小数)转换成人民币的大写格式
	 *
	 * @param rmbDouble
	 * @return String
	 * @throws Exception
	 */
	public static String doChangeRMB(double rmbDouble) throws Exception {
		String result = null;
		double theInt = Math.rint(rmbDouble);
		if (theInt > rmbDouble) {
			theInt -= 1;
		}
		double theDecimal = rmbDouble - theInt;

		String integer = new Long((long) theInt).toString();
		String decimal = "" + Math.round(theDecimal * 100);
		if (decimal.equals("0")) {
			result = ChangeRMB.praseUpcaseRMB(integer);
		} else {
			result = ChangeRMB.praseUpcaseRMB(integer, decimal);
		}

		// 小数是零结尾的
		if (result.charAt(result.length() - 1) == '零') {
			result = result.substring(0, result.length() - 1);
		}
		return result;
	}
	/*
	 * test public static void main(String[] args) throws Exception{
	 * System.out.print("输入小写人民币金额:"); BufferedReader br = new
	 * BufferedReader(new InputStreamReader(System.in)); String in =
	 * br.readLine();
	 *
	 * String result=ChangeRMB.doChangeRMB(in);
	 *
	 * System.out.println("\n"+"------------转换结果------------");
	 * System.out.println(result);
	 *
	 * double d=54628569856.68; String ret=ChangeRMB.doChangeRMB(d);
	 * System.out.println("\n"+"------------转换结果------------");
	 * System.out.println(ret); }
	 */
}

ubunut linux SVN server install and configration

Posted by Jerry in Knowledge | Leave a comment

一、SVN安装
1.安装包

$ sudo apt-get install subversion

2.添加svn管理用户及subversion组

$ sudo adduser svnuser
$ sudo addgroup subversion
$ sudo addgroup svnuser subversion

3.创建项目目录

$ sudo mkdir /home/svn
$ cd /home/svn
$ sudo mkdir fitness
$ sudo chown -R root:subversion fitness
$ sudo chmod -R g+rws fitness

4.创建SVN文件仓库

$ sudo svnadmin create /home/svn/fitness

5.访问方式及项目导入:

$ svn co file:///home/svn/fitness
//或者
$ svn co file://localhost/home/svn/fitness

* 注意:
如果您并不确定主机的名称,您必须使用三个斜杠(///),而如果您指定了主机的名称,则您必须使用两个斜杠(//).
//–
下面的命令用于将项目导入到SVN 文件仓库:
$ svn import -m “New import” /home/svn/fitness file:///home/svnuser/src/fitness
一定要注明导入信息

//————————–//
6.访问权限设置
修改 /home/svn/fitness目录下:
svnserve.conf 、passwd 、authz三个文件,行最前端不允许有空格
//–
编辑svnserve.conf文件,把如下两行取消注释
password-db = password
authz-db = authz

//补充说明

# [general]
anon-access = read
auth-access = write
password-db = passwd
//其中 anon-access 和 auth-access 分别为匿名和有权限用户的权限,默认给匿名用户只读的权限,但如果想拒绝匿

名用户的访问,只需把 read 改成 none 就能达到目的。

//–
编辑/home/svnuser/etc/passwd 如下:
[users]
mirze = 123456
test1 = 123456
test2 = 123456
//–
编辑/home/svnuser/etc/authz如下
[groups]
admin = mirze,test1
test = test2
[/]
@admin=rw
*=r
这里设置了三个用户mirze,test1,test2密码都是123456
其中mirze和test1属于admin组,有读和写的权限,test2属于test组只有读的权限

7.启动SVN服务
svnserve -d -r /home/svn
描述说明:
-d 表示svnserver以“守护”进程模式运行
-r 指定文件系统的根位置(版本库的根目录),这样客户端不用输入全路径,就可以访问版本库
如: svn://192.168.12.118/fitness

这时SVN安装就完成了.
局域网访问方式:
例如:svn checkout svn://192.168.12.118/fitness –username mirze –password 123456 /var/www/fitness

———————————————————————–

二、HTTP:// [apache]
1.安装包 [已安装subversion]
$ sudo apt-get install libapache2-svn

创建版本仓库:
sudo svnadmin create /目录地址
目录地址必须存在,这个就是保存版本仓库的地方,不同的版本仓库创建不同的文件夹即可,比如:
sudo svnadmin create /home/svn/project
本来/home/svn/project这个目录下什么都没有,执行下面的命令之后再去看一下,多出一些文件和文件夹,我们需要操作的是conf这个文件夹,这个文件夹下有一个文件,叫做passwd,用来存放用户名和密码。
然后把这个版本仓库目录授权给apache读写:
sudo chown -R www-data:www-data /目录地址
然后来到打开apache配置文件:
sudo gedit /etc/apache2/mods-available/dav_svn.conf

加入如下内容:

DAV svn
SVNPath /home/svn/project
AuthType Basic
AuthName “myproject subversion repository”
AuthUserFile /home/svn/project/conf/passwd
# Require valid-user
#

location说的是访问地址,比如上述地址,访问的时候就是

http://127.0.0.1/project

其中有两行被注释掉了,以保证每次都需要用户名密码。
最后一步就是创建访问用户了,建议将用户名密码文件存放在当前版本仓库下conf文件夹下,这样版本仓库多的时候无至于太乱。
因为conf文件夹下已经存在passwd文件了,所以直接添加用户:
sudo htpasswd -c /home/svn/project/conf/passwd test
然后输入两遍密码,laoyang这个用户就创建好了。
打开/home/svn/project/conf/passwd这个文件,会开到形如如下形式的文本:
test:WEd.83H.gealA //后面是加密后的密码。
创建以后,再次需要往别的版本仓库添加这个用户,直接把这一行复制过去就可以了。
重启apache就可以了。
sudo /etc/init.d/apache2 restart

———————————————————————–

三、同步更新 [勾子]

同步程序思路:用户提交程序到SVN,SVN触发hooks,按不同的hooks进行处理,这里用到的是post-commit,利用post-commit到代码检出到SVN服务器的本地硬盘目录,再通过rsync同步到远程的WEB服务器上。

知识点:
1、SVN的hooks
# start-commit 提交前触发事务
# pre-commit 提交完成前触发事务
# post-commit 提交完成时触发事务
# pre-revprop-change 版本属性修改前触发事务
# post-revprop-change 版本属性修改后触发事务
通过上面这些名称编写的脚本就就可以实现多种功能了,相当强大。
2、同步命令rsync的具体参数使用
3、具有基个语言的编程能力bash python perl都可以实现

post-commit具体实现细节
post-commit脚本

编辑文件:sudo vim /home/svn/fitness/hooks/post-commit

注意:编辑完成post-commit后,执行:sudo chmod 755 post-commit

内容:

#!/bin/sh
export LANG=zh_CN.UTF-8
sudo /usr/bin/svn update /var/www/www –username mirze –password 123456


#Set variable
SVN=/usr/bin/svn
WEB=/home/test_nokia/
RSYNC=/usr/bin/rsync
LOG=/tmp/rsync_test_nokia.log
WEBIP=”192.168.0.23″
export LANG=en_US.UTF-8

#update the code from the SVN
$SVN update $WEB –username user –password password
#If the previous command completed successfully, to continue the following
if [ $? == 0 ]
then
echo “” >> $LOG
echo `date` >> $LOG
echo “##############################” >> $LOG
chown -R nobody:nobody /home/test_nokia/
#Synchronization code from the SVN server to the WEB server, notes:by the key
$RSYNC -vaztpH –timeout=90 –exclude-from=/home/svn/exclude.list $WEB root@$WEBIP:/www/ >> $LOG
fi

以上是具体的post-commit程序
注意事项:
1、一定要定义变量,主要是用过的命令的路径。因为SVN的考虑的安全问题,没有调用系统变量,如果手动执行是没有问题,但SVN自动执行就会无法执行了。
2、SVN update 之前一定要先手动checkout一份出来,还有这里一定要添加用户和密码 如果只是手动一样会更新,但自动一样的不行。
3、加上了对前一个命令的判断,如果update的时候出了问题,程序没有退出的话还会继续同步代码到WEB服务器上,这样会造成代码有问题
4、记得要设置所属用户,因为rsync可以同步文件属性,而且我们的WEB服务器一般都不是root用户,用户不正确会造成WEB程序无法正常工作。
5、建议最好记录日志,出错的时候可以很快的排错
6、最后最关键的数据同步,rsync的相关参数一定要清楚,这个就不说了。注意几个场景:
这里的环境是SVN服务器与WEB服务器是开的
把SVN服务器定义为源服务器 WEB服务器为目的服务器
场景一、如果目的WEB服务器为综合的混杂的,像只有一个WEB静态资源,用户提交的,自动生成的都在WEB的一个目录下,建议不要用–delete这个参数
上面这个程序就是这样,实现的是源服务器到目的服务器的更新和添加,而没有删除操作,WEB服务器的内容会多于源SVN的服务器的
场景二、实现镜像,即目的WEB服务器与源SVN服务器一样的数据,SVN上任何变化WEB上一样的变化,就需要–delete参数
场景三、不需要同步某些子目录,可能有些目录是缓存的临时垃圾目录,或者是专用的图片目录(而不是样式或者排版的)要用exclude这个参数
注意:这个参数的使用不用写绝对路径,只要目录名称就行 aa代表文件 aa/ 代表目录 ,缺点就是如果有多个子目录都是一样的名称 那么这些名称就都不会被同步
建议用–exclude-from=/home/svn/exclude.list 用文件的形式可以方便的添加和删除
exclude.list

.svn/
.DS_Store
images/

利用SVN的钩子还可以写出很多的程序来控制SVN 如代码提交前查看是否有写日志,是否有tab,有将换成空格,是否有不允许上传的文件,是否有超过限制大小的文件等等。

You need to analyze the members in the component and the dependencies among them.

Posted by Jerry in Knowledge | Tagged | 1 Comment

You create an application by using Microsoft Visual Studio .NET 2008 and the .NET Framework 3.5.You plan to add an existing .NET component into the current application. The .NET component hasinsufficient documentation.The structure of the classes in the component must be analyzed before they are incorporated in theapplication.You need to analyze the members in the component and the dependencies among them.What should you do?

A. Enable logging on the component.

B. Run a code profiler on the component.

C. Create a class diagram for the component.

D. Create a sequence diagram for the component.

Answer: C

One minute life

Posted by Jerry in Articale | Leave a comment


One minute life !

Apache2.2.x + php5.x + mysql Install and configuration on windows

Posted by Jerry in Articale, php | Leave a comment
  1. Go to apache website, http://www.apache.org download httpd .
  2. Go to php website, http://www.php.net download php5.x.x.zip
  3. Go to mysql website ,http://www.mysql.com download mysql installer exe
Install apache2.2.x.exe , when you finish the application is started. Then you can visit on you IE or Firefox browser. Type in http://localhost:port , the port is you config in apache when you install.
Now you can see it: “It’s work!” .
Then you unzip the php.5.x.zip to your directory, and change the name of the php.ini-development to php.ini and open as text edit of apache directory “C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\httpd.conf”, in my System is like this .
Go to the end of load models:

LoadModule php5_module "C:/php/php5apache2_2.dll"
PHPIniDir "C:/php"
AddType application/x-httpd-php .php

and go to here, you can press Ctrl + F to find the words “DirectoryIndex: sets the file that Apache will serve if a directory”
and add the index of directory like flow code :

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#

    DirectoryIndex index.html index.htm index.php

Then you restart apache service. The php script can be run.
Install mysql.exe and setup !Now go to configuration the php visit mysql service.

Then let us change the pram of php.ini like this :

;extension=php_bz2.dll
extension=php_curl.dll
;extension=php_fileinfo.dll
extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
extension=php_mbstring.dll
;extension=php_exif.dll      ; Must be after mbstring as it depends on it
extension=php_mysql.dll
;extension=php_mysqli.dll
;extension=php_oci8.dll      ; Use with Oracle 10gR2 Instant Client
;extension=php_oci8_11g.dll  ; Use with Oracle 11g Instant Client
;extension=php_openssl.dll
;extension=php_pdo_firebird.dll
;extension=php_pdo_mssql.dll
extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
;extension=php_pdo_sqlite.dll
;extension=php_pgsql.dll
;extension=php_phar.dll
;extension=php_pspell.dll
;extension=php_shmop.dll
;extension=php_snmp.dll
;extension=php_soap.dll
;extension=php_sockets.dll
;extension=php_sqlite.dll
;extension=php_sqlite3.dll
;extension=php_sybase_ct.dll
;extension=php_tidy.dll
;extension=php_xmlrpc.dll
;extension=php_xsl.dll
;extension=php_zip.dll

OK , you finish the configuration.

How to add a Open Cart themes

Posted by Jerry in Articale | Leave a comment

Today I’ve install a new theme of Open Cart, though that is not very good, but that is really coll when you can’t design this application page.
So I have download the Documentation how to develop theme of Open Cart ! Today I will tall you home install themes.

1st : you can download a free theme and upload to your website ,the directory is /catalog/view/theme/

When  you uploaded will like flow picture.

2sd : you will go to visit you admin of website System -> Settings -> Store like flow picture example.

Then you can select it ! Enjoy .

By Jerry.