Web
记录一些关于Web开发和应用方面的一些信息。
2010系统架构师大会
Sep 1st
2010年8月27、28日,由IT168、ChinaUnix、ITPUB、IXPUB共同主办的SACC2010系统架构师大会在北京永泰福朋·喜来登大酒店成功举行。两天的盛会以七个技术专场为平台,内容涵盖从系统架构、网络、安全、存储、数据库、移动互联、云计算等与架构师相关的方方面面。
相关地址:
http://sacc.it168.com/
部分PPT下载地址:
1、架构师大会-架构设计专场
http://linux.chinaunix.net/SACC2010/topic1.zip
2、架构师大会-架构设计与存储管理专场
http://linux.chinaunix.net/SACC2010/topic2.zip
3、架构师大会-应用系统优化与流量管理
http://linux.chinaunix.net/SACC2010/topic3.zip
4、架构师大会-可扩展数据库架构
http://linux.chinaunix.net/SACC2010/topic4.zip
5、架构师大会-移动互联网产品架构设计
http://linux.chinaunix.net/SACC2010/topic5.zip
6、架构师大会-系统安全与服务监控
http://linux.chinaunix.net/SACC2010/topic6.zip
7、架构师大会-云计算分布式应用实践
http://linux.chinaunix.net/SACC2010/topic7.zip
微博客输入框jQuery插件
Aug 29th
自己开发的一个类似微博客输入框的一个jQuery插件,也可以让大家学习下怎么开发一个简单的jQuery插件。
(function($){
$.fn.extend({
speaker:function(countId){
var intervalId = jQuery.data(this, 'intervalId');
this.focus(function(){
if(intervalId==null||intervalId!=0){
intervalId = setInterval("jQuery.speaker.check('"+this.id+"','"+countId+"')",50);
jQuery.data(this, 'intervalId', intervalId);
}
});
this.blur(function(){
var intervalId = jQuery.data(this, 'intervalId');
jQuery.data(this, 'intervalId', 0);
clearInterval(intervalId);
});
}
});
jQuery.extend({
speaker: {
check:function(id,countId){
var str = $("#"+id).val();
var count = 140-str.length;
$("#"+countId).html(count);
if(count>10){
$("#"+countId).attr("style","color:#000000;");
}else if(count>=0){
$("#"+countId).attr("style","color:#085879;");
}else{
$("#"+countId).attr("style","color:#BA2636;");
}
}
}
});
})(jQuery);
ANT自动化压缩合并JS/CSS和更改版本号
Jul 20th
最近做到了前端优化的一些工作,涉及到了自动化部署的问题。前端优化无非是雅虎的优化法则,不过如果想把优化法则加到自动化部署中去的话,下面的几种方法可以帮助你。
1、JS/CSS压缩脚本
<!-- 压缩JS,CSS -->
<target name="compress">
<apply executable="java" parallel="false" failonerror="true">
<fileset dir="${html-js}" includes="**/*.js" />
<arg line="-jar" />
<arg path="${yui-compressor}" />
<arg line="--charset utf-8" />
<srcfile />
<arg line="-o" />
<mapper type="glob" from="*.js" to="${webhtml-js}/*-min.js" />
<targetfile />
</apply>
<apply executable="java" parallel="false" failonerror="true">
<fileset dir="${html-css}" includes="**/*.css" />
<arg line="-jar" />
<arg path="${yui-compressor}" />
<arg line="--charset utf-8" />
<srcfile />
<arg line="-o" />
<mapper type="glob" from="*.css" to="${webhtml-css}/*-min.css" />
<targetfile />
</apply>
</target>
2、更新JSS/CSS版本号
<!-- 更新静态文件的版本号 -->
<target name="version">
<tstamp>
<format property="TIMESTAMP" pattern="yyyyMMddHHmmss" locale="en" />
</tstamp>
<loadfile property="svn.version" srcFile="./.svn/entries">
<filterchain>
<headfilter lines="1" skip="3" />
<deletecharacters chars="\n" />
</filterchain>
</loadfile>
<delete file="${webinf-ftl}/config.ftl"/>
<copy file="${ftl-app}/config.ftl" tofile="${webinf-ftl}/config.ftl" />
<replace file="${webinf-ftl}/config.ftl" token="$version$" value="${svn.version}" />
</target>
接下来就是合并JS/CSS文件
<!-- 合并静态文件 -->
<target name="js-concat">
<concat destfile="${webhtml-js}/jquery.js" encoding="utf-8" append="false">
<path path="${webhtml-js}/jquery.core-min.js" />
<path path="${webhtml-js}/jquery.cookie-min.js" />
<path path="${webhtml-js}/jquery.timeago-min.js" />
<path path="${webhtml-js}/jquery.utils-min.js" />
<path path="${webhtml-js}/jquery.watermarkinput-min.js" />
</concat>
</target>
HTTP 错误
May 28th
HTTP 400 – 请求无效
HTTP 401 – 未授权
HTTP 403 – 禁止访问
HTTP 404 – 无法找到文件
HTTP 405 – 资源被禁止
HTTP 406 – 无法接受
HTTP 407 – 要求代理身份验证
HTTP 410 – 永远不可用
HTTP 412 – 先决条件失败
HTTP 414 – 请求 – URI 太长
HTTP 500 – 内部服务器错误
HTTP 501 – 未实现
HTTP 502 – 网关错误
当负载过高时重启Apache
Nov 23rd
最近半年碰到了几次,由于“蜘蛛”导致机器挂掉了,所以想出了这个方法,等系统负载过高的情况下,直接重启Apache。这就是Twitter提倡的那样,等进程杀死你之前,你先杀死他(原话不记得了)。其实这种方法早就在业界使用了。
来吧,看看我写的脚本。
checkload.sh
#!/bin/sh
TOP_SYS_LOAD_NUM=5
SYS_LOAD_NUM=`uptime | awk '{print $(NF-2)}' | sed 's/,//'`
echo $(date +"%y-%m-%d") `uptime`
if [ `echo "$TOP_SYS_LOAD_NUM < $SYS_LOAD_NUM"|bc` -eq 1 ]
then
echo "##" $(date +"%y-%m-%d %H:%M:%S") "pkill httpd" `ps -ef | grep httpd | wc -l`
pkill httpd
sleep 10
for i in 1 2 3
do
if [ `pgrep httpd | wc -l` -le 0 ]
then
/home/app/httpd/bin/apachectl start
sleep 30
echo "##" $(date +"%y-%m-%d %H:%M:%S") "start httpd" `ps -ef | grep httpd | wc -l`
fi
done
else
if [ `pgrep httpd | wc -l` -le 0 ]
then
/home/app/httpd/bin/apachectl start
sleep 30
echo "##" $(date +"%y-%m-%d %H:%M:%S") "start httpd" `ps -ef | grep httpd | wc -l`
fi
fi
然后在crontab里增加定时执行的命令
*/2 * * * * (/root/checkload.sh >>/root/checkload.log)
每两分钟检查一次系统负载。
使用Google的Ajax库API
Aug 12th
使用这个的一个好处是使用了Google的CDN,这对于贫穷的站长来说,实在是太好了。
<script src="http://www.google.com/jsapi"></script>
<script>
google.load("jquery", "1.3.1");
google.load("jqueryui", "1.5.3");
</script>
同时在介绍一下Google的代码园地很不错的一个东西,有很多的Google开发的API可以使用。
让你的用户感受特别
Aug 10th
原文:Web Directions UX: Making Your Users Feel Special
http://www.sitepoint.com/blogs/2008/05/16/web-directions-ux-making-your-users-feel-special/
1. First impressions count
2. Attention to detail gets noticed
3. Personalisation and customisation matters
4. Dripfeed your information
5. Take care of the mundane
6. Make it fun
7. Feedback is important
8. Recommendations are powerful
9. Users love competitions
马斯洛的需求层次”web”体系
马斯洛的需求层次体系当每一层次需求得到满足时,人们便会移至上一层次
1. functional 功能
2. reliable 可靠
3. usable 可用
4. convenient 便捷
5. pleasurable 愉悦
6. meaningful 意义
参考文献:
http://blog.youmila.com/?p=349【Web方向用户体验之”让你的用户感受特别”】
Eclipse中高亮
Aug 7th
不知道为什么,Eclipse的编辑器的高亮不见了,很不方便啊。最后搜索找到一篇文章,介绍了怎么重新启动高亮。
其恢复方式如下:
选择:windows-> preferences->java->Editor->Mark Occurences
我是碰到过两次了,这次写个日志记录下吧。
参考文章:
http://blog.csdn.net/ccsuliuxing/archive/2007/04/16/1566583.aspx
Windows环境下的项目环境搭建(Tomcat+Apache+Memcached+ActiveMQ+MySQL)
Jul 26th
首先到 http://labs.xiaonei.com/apache-mirror/ 下载相关的软件。
http://labs.xiaonei.com/apache-mirror/activemq/apache-activemq/5.2.0/apache-activemq-5.2.0-bin.zip 这个软件现在不用,不过以
后会用的。
http://labs.xiaonei.com/apache-mirror/httpd/binaries/win32/apache_2.2.11-win32-x86-no_ssl.msi
http://labs.xiaonei.com/apache-mirror/tomcat/tomcat-6/v6.0.20/bin/apache-tomcat-6.0.20.exe
http://labs.xiaonei.com/apache-mirror/tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.28/mod_jk-1.2.28-httpd-2.2.3.so
http://www.splinedancer.com/memcached-win32/memcached-1.2.4-Win32-Preview-20080309_bin.zip 这个软件以后也会用
现在这几个软件被安装在以下目录
D:\Program Files\Apache Software Foundation\Tomcat 6.0
D:\Program Files\Apache Software Foundation\Apache2.2
D:\Program Files\Apache Software Foundation\apache-activemq-5.2.0
首先把mod_jk-1.2.28-httpd-2.2.3.so文件复制到
D:\Program Files\Apache Software Foundation\Apache2.2\modules
改名为mod_jk.so
再在
D:\Program Files\Apache Software Foundation\Apache2.2\conf
创建文件
workers.properties
内容为
workers.tomcat_home=D:\Program Files\Apache Software Foundation\Tomcat 6.0
workers.java_home=D:\Program Files\Java\jdk
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.type=ajp13
worker.ajp13.lbfactor=1
然后在文件D:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf 找到
LoadModule rewrite_module modules/mod_rewrite.so
去掉前面的#号
再添加
LoadModule jk_module modules/mod_jk.so
在文件的最后添加
JkWorkersFile “D:\Program Files\Apache Software Foundation\Apache2.2\conf\workers.properties”
JkLogFile “D:\Program Files\Apache Software Foundation\Apache2.2\logs\mod_jk2.log”
JkLogLevel inf
<VirtualHost *:80> DocumentRoot "D:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\iguoer" ServerName www.iguoer.com DirectoryIndex index.html index.htm index.jsp ErrorLog logs/shsc-error_log.txt CustomLog logs/shsc-access_log.txt common JkMount /dwr/* ajp13 JkMount /*.jsp ajp13 JkMount /*.do ajp13 </VirtualHost>
现在去配置Tomcat
找到文件
D:\Program Files\Apache Software Foundation\Tomcat 6.0\conf\server.xml
如果你安装的Tomcat和我的版本是一样的话,在文件的最后面应该可以找到
<Engine name="Catalina" defaultHost="localhost"> <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> </Host> </Engine>
我修改为
<Engine name="Catalina" defaultHost="www.iguoer.com"> <Host name="www.iguoer.com" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Context path="" docBase="iguoer" reloadable="true" /> </Host> </Engine>
修改这段后,此时Tomcat的根目录为
D:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\iguoer
这样用Eclipse的插件,就能启动项目为根目录启动了。
当然还可以配置不同域名访问不同目录
<Engine name="Catalina" defaultHost="www.iguoer.com"> <Host name="www.iguoer.com" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Context path="" docBase="iguoer" reloadable="true" /> </Host> <Host name="img.iguoer.com" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Context path="" docBase="D:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\iguoer" reloadable="true" /> </Host> </Engine>
当然不要忘记修改你的C:\Windows\System32\drivers\etc\hosts
127.0.0.1 www.iguoer.com
127.0.0.1 img.iguoer.com
127.0.0.1 memcached.iguoer.com
127.0.0.1 mysql.iguoer.com
127.0.0.1 mq.igueor.com
抛弃在Hibernate的二级缓存使用Memcached
Jul 19th
Memcached就像一个调皮的精灵,在你困难的时候,他会跳出来帮你一把,那绝对是雪中送。
不过,也如精灵的天性一样,喜欢冲破任何约束,感觉都不太可靠。
在Hibernate的二级缓存加上Memcached,似乎是把这个精灵捆住了,也正因为如此,Memcached不再是Memcached了。
扔掉这种想法吧,如果你使用了Memcached,就要做好他上窜下窜的准备,这就是他的魅力。