RSS| 首页| 山顶道| 布珞阁¹| GoodUI| 土产| 关于

海外虚拟服务器心得
2009.08.23 16:05 bruce:

折腾了2天海外虚拟主机,有些心得写下来。

因为墙(GWF)的问题很严重,不但国内访问不到国外站点,国外客户访问国内站点都够呛。

因此要做国际化服务服务器必须架设在海外,美国信息化发达,比较开放,带宽也不错,互联网销售的服务商也很多。

普通应用只需要虚拟主机,

查看全部

分类  日经| 3个评论


七月半中元化袱
2009.08.16 20:29 bruce:

没想到北方就没这习俗,故贴图分享

12点前将土纸钱,用棒槌打专门的钱凿子凿出基数行。就是给祖人捎去的钱币了,一扎也是基数张

用白纸包成包袱,四方装

跟墓碑一样写上祖人收,

男的就是:故先考×公××老大人,女的就是:故先妣×母×老孺人,如果是外祖,就是尊外祖考、尊外祖妣,

左边是落款,孙子××× 曾孙×××

右边是钱数,中元化袱××包

背面用封字覆盖上粘贴的纸张,好比邮票

还要写几百给力夫大人,应该就是邮差吧

要在午12点钱写完,都应由男丁写,要谦卑

 

写完后,与农历七月十四晚,在阴暗角落的地上烧掉,可以拿些供果

 

分类  日经| 2个评论


水溶C100真的有柠檬
2009.08.16 20:19 bruce:

分类  日经| 暂无评论


java1.5以后的java.util.UUID 与 hibernate标识符生成器中uuid的不同
2009.08.9 0:32 bruce:

java.util.UUID.randomUUID().toString();

相当于其他语言(c++、c#)中的GUID概念,由机器算出不重复的128位值的hex代码组成,中间用-号隔开

<time_low> “-” <time_mid> “-” <time_high_and_version> “-” <variant_and_sequence> “-” <node>

字母基本没有规律


abf4f706-d585-102c-8c4a-bda3fb01135a


而hibernate中提供的集中标识符生成器中,也有个uuid,3.2以前版本分uuid.hex和uuid.string,后来去掉了uuid.string,建议用uuid

uuid标识符生成器  uuid标识符生成器使用一个128位的全局唯一标识符(Universally Unique Identifier,UUID)算法生成字符串类型的标识符。UUID包含本机的IP地址、本机JVM的信息,相对于同一时空中的所有机器都是唯一的。uuid标识符生成器由Hibernate维护并生成uuid值,不依赖于底层数据库的实现细节,因而可以适用于所有数据库。
使用uuid标识符生成器需要注意以下的问题:由于UUID的值是完全随机的,因此在数据库中,不能确定记录的顺序。另外,uuid标识符生成器使用32位16进制字符串,需要占用更多的空间,索引的效率也比较低。

通过测试,算出来值有2点

1. 只是32位hex代码,没有用-分隔

2. 基本上前面都是相同的,一眼就可以看出来

9481818622fad32b0122fad5961f0005
9481818622fad32b0122fad429bb0002
9481818622fad32b0122fad3ce320001

倒是可以拿来做组件,但是和C++写的程序共用数据库时,不一致的情况很麻烦,要处理-号分隔的问题

C++常用

{ABF4F706-D585-102C-8C4A-BDA3FB01135A}

 

还好,hibernate中还是提供了guid标识符生成器,需要底层数据库支持。mysql支持。

guid标识符生成器
  guid包含当前日期、时间、时钟序列和全局唯一的IEEE机器识别号等,在全局是唯一的。
  使用guid标识符生成器保存数据时,标识符生成器从数据库中获取guid作为对象标识符的值和记录的主键。使用guid需要底层数据库的支持。

20a1ba87-d586-102c-8c4a-bda3fb01135a
abf4f706-d585-102c-8c4a-bda3fb01135a
 

分类  日经| 暂无评论


polo衫颜色表
2009.08.8 8:36 bruce:

来自vancl

分类  日经| 暂无评论


关于MyEclipse 7.x 删除 工程的.svn下的entries 和all-wcprops 文件的问题
2009.08.8 2:15 bruce:

觉得很离谱

没事就去删那2个文件,搞得svn目录混乱。问了不少人,也搜了很久,都没碰到。

在官方论坛找到了同命相连的人。

这是bug

http://www.myeclipseide.com/PNphpBB2-viewtopic-t-23494-postdays-0-postorder-asc-start-0.html

7.1以后就开始有了,官方说7.5修复了。

结果没有,按客服的方法:问题出在org.eclipse.wst.jsdt.core.javascriptValidator 或者org.eclipse.wst.jsdt.core.jsNature nature 上

删除.project中这2项的配置,问题解决了

pickaxe,
Can you please check if you are able to do the following steps:-
1. Create the project (it will erase all the svn elements)
2. Close the project in MyEclipse
3. Replace the SVN elements on-disk — eg. re-checkout the projects from the repository using some external SVN client.
4. Navigate directly into the project directory and edit the .project file using a text editor and remove the org.eclipse.wst.jsdt.core.javascriptValidator builder, and the org.eclipse.wst.jsdt.core.jsNature nature — then save and close the .project file.
5. Now re-open the project in MyEclipse and refresh it — are the SVN elements left in-tact?

 

翻译下

1.重新下载好的工程。或者按他说的先建个空项目,再checkout你的项目下来覆盖

2. 用编辑器修改.project文件

删除org.eclipse.wst.jsdt.core.javascriptValidator 和 org.eclipse.wst.jsdt.core.jsNature nature 相关的2项

再开myeclipse,应该解决了。

我先自己试试……………………

分类  日经| 1个评论


stucts 里面用 jcaptcha 做登录验证码
2009.08.7 21:54 bruce:

jcaptcha是专业的解决方案,做到了极致,没必要自己去写了

下载之:http://sourceforge.net/projects/jcaptcha/files/

根据他官方的例子,在struts中集成方法如下

环境:struts 1.3.x  jcaptcha 1.0

1. 加载lib

把jcaptcha-1.0-all.jar 和 jcaptcha-integration-struts-1.0.jar 放到工程的lib里面,并设置包含之

2. 配置struts-config.xml

加plug-in描述

<plug-in className=“com.octo.captcha.module.struts.CaptchaServicePlugin”/>

加引用的 action

<action-mappings>这个里面加以下代码
<!– add the render action–>
<action
path=“/jcaptcha”
type=“com.octo.captcha.module.struts.image.RenderImageCaptchaAction”
>
</action>

即:可用 http://server/proj/jcaptcha.do 调用(如果你设置的是 *.do)   http://server/proj/do/jcapcha(如果你设置的是 /do/*的话) 显示生成的图片

运行起来后,在浏览器中应该可以看到图片了

3. jsp中集成

如 login.jsp中

最前面加入taglib定义
<%– Add the jcaptcha taglib–%>
<%@ taglib uri=“http://jcaptcha.sourceforge.net” prefix=“jcaptcha”%>

增加显示和校验代码
<%– Add the jcaptcha form part–%>
<input type=“text” name=“jcaptcha_response” />

<!– 加入错误提示,改成用errors了–>
<font class=“required_error_font”> <html:errors property=“jcaptcha_error_msg” /></font><br/>
<font size=“-1″ color=“#6f6f6f”><jcaptcha:question/></font><br/>
<%– Add the image–%>
<img name=“jcaptcha” id=“jcaptcha” onclick=“refresh_jcaptcha(this)” src=<%=request.getContextPath()%>/do/jcaptchaalt=“click to refresh” style=“cursor:pointer;”/>

增加了个点击刷新的功能,脚本如下

<script language=“Javascript”>
function refresh_jcaptcha(obj){
//alert(obj);
obj.src=”<%=request.getContextPath()%>/do/jcaptcha?” + Math.random();
}

</script>

 

4. 在提交页面对应的Action.excute()中增加校验代码处理 request

我把他封装成了函数

public boolean isJcaptchaOK(HttpServletRequest request)
{
log.debug(“enter captcha challenge verification”);
CaptchaService service = CaptchaServicePlugin.getInstance()
.getService();
String responseKey = CaptchaServicePlugin.getInstance()
.getResponseKey();
String captchaID = CaptchaModuleConfigHelper.getId(request);
String challengeResponse = request.getParameter(responseKey);
if (log.isDebugEnabled())
log.debug(“response for id “ + captchaID + ” : “ + challengeResponse);
request.removeAttribute(responseKey);
boolean isResponseCorrect = false;
if (challengeResponse != null)
try {
isResponseCorrect = service.validateResponseForID(captchaID,
challengeResponse).booleanValue();
} catch (CaptchaServiceException e) {
log.debug(“Error during challenge verification”, e);
request.setAttribute(CaptchaServicePlugin
.getInstance().getMessageKey(),
CaptchaModuleConfigHelper
.getMessage(request));
log.debug(“forward to error with message : “ + CaptchaModuleConfigHelper.getMessage(request));
throw(e);//抛出程序应用异常
}
if (isResponseCorrect) {
log.debug(“correct : forward to success”);
return true;//正确
}
if (log.isDebugEnabled()) {
log.debug(“false : forward to failure with message : “
+ CaptchaModuleConfigHelper.getMessage(request));
log.debug(“in request attribute key : “
+ CaptchaServicePlugin.getInstance().getMessageKey());
}
ActionErrors errors = new ActionErrors();//用ActionError替换了他自己的Message
errors.add(“jcaptcha_error_msg”, new ActionMessage(
“error.jcaptcha.error.inputInvalid”));
this.addErrors(request, errors);
return false;
}

—–

excute(…)中:

if(!isJcaptchaOK(request))
    return mapping.findForward(“return_form”); //返回页面
return mapping.findForward(“global_success”);
 
——
大功告成

分类  日经| 暂无评论


平静下来
2009.08.3 0:11 bruce:

http://bruce.in/dbz.mp3

音频片段:需要 Adobe Flash Player(9 或以上版本)播放音频片段。 点击这里下载最新版本。您需要开启浏览器的 JavaScript 支持。

分类  日经| 暂无评论


分类 搜索

   
月档 日历
2009年八月
« 七   十二 »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

最新 RSS

评论 RSS

链接