2008年12月28日星期日

run groovy the first time

java.lang.SecurityException: Prohibited package name: java.lang


remove ***\rt.jar from "classpath" and then groovy(.bat) runs well.

2008年12月19日星期五

evil 163.com

it hides the auditing note of user's comments.

Bitch and cheater.

2008年12月18日星期四

The column name xxx was not found in this ResultSet.

org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [select * from t_service_transaction where id = ?]; nested exception is org.postgresql.util.PSQLException: The column name sp_id was not found in this ResultSet.
    org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translate(SQLStateSQLExceptionTranslator.java:107)
    org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:276)
    org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:554)
    org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:588)
    org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:617)
    org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:625)
    org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:657)


sp_id is absolutely not a field of table `t_service_transaction`,
and this exception occurred many times with different table names but same field name.

restart postgres sql server, and evrything goes fine.

@see:
http://archives.postgresql.org/pgsql-jdbc/2005-06/msg00086.php

2008年12月16日星期二

output 0 to 1000 without loop and if, at least two methods.

1. Java version, recursive.

package shawn.test;
public class Thousand {
    public static void main(String[] args) {
        descrease2(1000);
    }
    public static Integer descrease2(Integer i) {
        try{
            Integer tmp = 1 / (i+1);
        }catch(Exception e){
            System.exit(1);
        }
        System.out.println(i--);
        descrease2(i);
        return i;
    }
}


2. Javascript Version, implementing Javascript Closure
<script type="text/javascript">
function test($num) {
  document.write($num+"<br />");
  $num--;
  return $num>0?test($num):document.write("0<br />");
}
var testMe = test(1000);
testMe();
</script>

3. Perl version, using language buildin looping feature.

#!/usr/local/bin/perl -w
@array = (0 .. 1000);
map {print $_, "\t"} @array;

> or

#!/usr/local/bin/perl -w
@array = (0 .. 1000);
grep {print $_, "\t"} @array;

> Extreme version, only 19 charactrors, no white space,
> no quotes, no brackets, no semicolon:

map{print$_}0..1000

2008年12月9日星期二

2008年12月8日星期一

solve winlogon.exe memory leak

keywords: windows xp, winlogon.exe memory leak

delete this reg key, and the problem is solved:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Notify\psfus

you could compare your setting with other normal systems, and delete those unique keys.

2008年10月20日星期一

get Last-Modified in jQuery ajax.

This issue bugged me for days. After a deep inspect of jQuery source code, I worked out this code:

$url="../status.php";
$.ajax({
"url":$url,
"type":"GET",
"complete":function(xhr, s){
handleResponse(xhr, s);
}
});

function handleResponse(xhr, status){
$("#result").append("
Headers:
"+xhr.getAllResponseHeaders());
var $dateStr = xhr.getResponseHeader("Date");
alert(xhr.responseText);
alert($dateStr);
var $date = new Date($dateStr);
alert($date);
}

<div id="result"></div>

===================
If you think this is useful, please leave a word, many thanks.

Why unbind of jQuery does not work

I need a javascript function to unbind "onclick" operation for some div elements like this:


Click me


and then click and unbind:
Unbind Click



This code cannot unbind the onclick event, it seems that the unbind could only unbind the events binded by jQuery, not events coded directly in HTML.

I hope you can understand this.



2008年10月18日星期六

double click column to resize table width in word 2007

double click column to resize table width in word 2007

it is easy to resize table width if it is beyound the visition.

Another usage of 7-zip

7-zip can open chm file, and unpack files in it.
That is wonderful, because some old chm file does not work fine in modern system,
7-zip could get what we want instead of bad chm files.

2008年10月9日星期四

I'm tired of splash screens

I am tired of splash screen, they really make me uneasy.

I hope I can find ways to remove them.

Known:
>1. pgAdmin III(static)
>2. Eclipses(Dynamic infomation)
>3. ....

2008年10月8日星期三

How to make sure eclipse code formater does not wrap multi line comment .

Add HTML marks to avoid code formater wrap long comments to ugly
one.
For example:<div>&<br />
/**
* <div> Date format reference:<br />
* Letter Date or Time Component Presentation Examples <br />
* G Era designator Text AD <br />
* y Year Year 1996; 96 <br />
* M Month in year Month July; Jul; 07 <br />
* w Week in year Number 27 <br />
* W Week in month Number 2 <br />
* D Day in year Number 189 <br />
* d Day in month Number 10 <br />
* F Day of week in month Number 2 <br />
* E Day in week Text Tuesday; Tue <br />
* a Am/pm marker Text PM <br />
* H Hour in day (0-23) Number 0 <br />
* k Hour in day (1-24) Number 24 <br />
* K Hour in am/pm (0-11) Number 0 <br />
* h Hour in am/pm (1-12) Number 12 <br />
* m Minute in hour Number 30 <br />
* s Second in minute Number 55 <br />
* S Millisecond Number 978 <br />
* z Time zone General time zone Pacific Standard Time; PST; GMT-08:00
* <br />
* Z Time zone RFC 822 time zone -0800 </div>
*/

2008年10月7日星期二

"You are welcomed" or "you are welcome"?

From:
http://answers.yahoo.com/question/index?qid=20060628170518AAJhSop

Is it correct to say "you are welcomed" or "you are welcome"?
I have said "you are welcomed" my whole life, and decided to switch to "you are welcome" a week ago. But something is bothering me, so I come to you for advice.

Serious answers only.
Answer only if you are at least 90% certain.
==============================================
The two phrases have different meanings.

The proper phrase, "You are welcome" says that the person is welcome to whatever you have given them.

The other phrase, "You are welcomed", which is not generally used, implies that the person is being welcomed to wherever they are, as in "we are welcoming you into this place". Notice that the sentence does not say who is doing the welcoming, only who is receiving the welcome. It's an awkward phrase and should not be used, even when you are truly welcoming someone to a particular place.

So, when someone thanks you, just say "you're welcome" and if you want to welcome them to some place, then say "welcome to my ..."

Fix one RealVNC viewer problem.

I cannot connect to RealVNC server yesterday, the same today.
I did it on another PC. So the problem is in viewer, not in server.

Open regedit, find this:

HKEY_CURRENT_USER\Software\RealVNC\VNCViewer4\KnownHosts

and delete the server and reconnect, the viewer will generate a new secure key,
and then all is OK.

2008年9月19日星期五

Backup J2ee project with batch, 7z

This batch script can backup full project files, adding date time to archive name, jar files are excluded.

My date Format is:

>E:\wwwroot>echo exit|cmd /q /k prompt $D $T
>2008-09-19 星期五 16:37:41.18

Please modify codes to meet your need.


echo off
@For /F "tokens=1,2,3 delims= " %%A in ('echo exit^|cmd /q /k prompt $D $T') do @(
Set DateStr=%%A
Set WeekStr=%%B
Set TimeStr=%%C
)

@For /F "tokens=1,2,3 delims=-" %%A in ('echo %DateStr%') do @(
Set Year=%%A
Set Month=%%B
Set Day=%%C
)

@For /F "tokens=1,2,3 delims=:" %%A in ('echo %timeStr%') do @(
Set Hour=%%A
Set Minute=%%B
Set Second1=%%C
)

@echo Second1 = %Second1%
@For /F "tokens=1 delims=." %%A in ('echo %Second1%') do @(
Set Second=%%A
)

@rem @echo DateStr = %DateStr%
@rem @echo TimeStr = %TimeStr%

@rem @echo Second1 = %Second1%

@rem @echo Year = %Year%
@rem @echo Month = %Month%
@rem @echo DAY = %Day%

@rem @echo Hour = %Hour%
@rem @echo Minute = %Minute%
@rem @echo Second = %Second%

@rem @echo ProjectFolder%Year%%Month%%Day%_%Hour%%Minute%%Second%.7z
@rem @Set FilePath=ProjectFolder%%Year%%%%Month%%%%Day%%_%%Hour%%%%Minute%.7z
@rem @"E:\Program Files\7-Zip\7z.exe" a -t7z ProjectFolder%Year%%Month%%Day%_%Hour%%Minute%%Second%.7z "E:\wwwroot\projectfolder\" -xr!*.jar
@echo on

@Set FilePath=ProjectFolder%Year%%Month%%Day%_%Hour%%Minute%%Second%.7z
@"E:\Program Files\7-Zip\7z.exe" a -t7z %FilePath% "E:\wwwroot\projectfolder\" -xr!*.jar

2008年9月17日星期三

三聚氰胺 melamine

三聚氰胺
melamine

>From Powerdict

melamine
[5melEmi(:)n]
n.
[化]三聚氰胺

melamine
mel.a.mine
AHD:[mµl“…-m¶n”]
D.J.[6mel*7mi8n]
K.K.[6mWl*7min]
n.(名词)
A white crystalline compound, C3H 6N 6, used in making melamine resins and for tanning leather.
蜜胺,三聚氰胺:白色结晶状化合物,C3H 6N 6,用来制造三聚氰胺树脂及用于鞣革
A plastic made from such resin.
三聚氰氨树脂:三聚氰胺树脂制得的塑料

Melam [distillate of ammonium thiocyanate]
Melam [硫氰酸铵馏出液]
amine
amine

melamine
[5melEmi:n]
n.
密胺树脂,密胺树脂塑料

melamine
[5melEmi(:)n]
n.
【化】三聚氰(酰)胺, 蜜胺

melamine
[5melEmi(:)n]
adj.
蜜胺的, 三聚氰胺的

methylol melamine
羟甲基蜜胺
triethylene melamine
三乙撑三聚氰酰胺, 三乙撑蜜胺

2008年9月11日星期四

RandomAccessFile notes

/**
* Write contents to txt file using "RandomAccessFile "
*
*/

String filepath = "E:\\wwwroot\\tmp\\testRandomAccreeFile.txt";
RandomAccessFile f = new RandomAccessFile(filepath,"rw");
f.seek(7 * 7 - 2);
String toWrite = "Helloo";

// not work, it will output one white space after one char.
//f.writeChars( toWrite );

// not work, it will output one white space and a new line
// before toWrite after writing
// f.writeUTF( toWrite );

// This is the right solution
f.write(toWrite.getBytes());

f.close();

2008年9月9日星期二

jadclipse sometimes does not work.

jadclipse works for a time, and sometimes fails to work, and can not decompile java class.
In fact we can make it work again. I restart eclipse, and it's OK.

2008年9月4日星期四

import java.util.Date & java.sql.Date


Import wrong class,


java.util.Date should be imported, but java.sql.Date was imported in entity class,
so java.lang.IllegalArgumentException is thrown,
btw, the debug point is in:

com.mycom.db.dao.CommDbOperTool$CustomRowMap.mapRow(CommDbOperTool.java:71)


HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: java.lang.IllegalArgumentException: java.lang.IllegalArgumentException
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:118)
com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:52)
com.mycom.webapp.filter.GZIPFilter.doFilterInternal(GZIPFilter.java:42)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
com.mycom.webapp.filter.LocaleFilter.doFilterInternal(LocaleFilter.java:63)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)


root cause

java.lang.IllegalArgumentException: java.lang.IllegalArgumentException
com.mycom.db.helper.annota.AnnotaEntityOper.doSet(AnnotaEntityOper.java:325)
com.mycom.db.helper.annota.AnnotaEntityOper.createObjByRs(AnnotaEntityOper.java:124)
com.mycom.db.dao.CommDbOperTool$CustomRowMap.mapRow(CommDbOperTool.java:71)
org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:92)
org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:600)
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:538)
org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:588)
org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:617)
org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:625)
org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:657)
com.myapp.db.dao.AccountCashingDao.getAccountCashingBySiteUserID(AccountCashingDao.java:49)
com.mycom.myapp.user.manager.AccountManager.getAccountCashingBySiteUserID(AccountManager.java:158)
com.mycom.myapp.user.manager.AccountManager$$FastClassByCGLIB$$ab87176b.invoke()
net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:694)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:629)
com.mycom.myapp.user.manager.AccountManager$$EnhancerByCGLIB$$cdf0dc72.getAccountCashingBySiteUserID()
com.mycom.myapp.webapp.action.AccountCashingAction.listCashing(AccountCashingAction.java:85)
com.mycom.myapp.webapp.action.AccountCashingAction.execute(AccountCashingAction.java:54)
org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:118)
com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:52)
com.mycom.webapp.filter.GZIPFilter.doFilterInternal(GZIPFilter.java:42)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
com.mycom.webapp.filter.LocaleFilter.doFilterInternal(LocaleFilter.java:63)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)


root cause

java.lang.IllegalArgumentException
sun.reflect.UnsafeObjectFieldAccessorImpl.set(Unknown Source)
java.lang.reflect.Field.set(Unknown Source)
com.mycom.db.helper.annota.AnnotaEntityOper.doSet(AnnotaEntityOper.java:322)
com.mycom.db.helper.annota.AnnotaEntityOper.createObjByRs(AnnotaEntityOper.java:124)
com.mycom.db.dao.CommDbOperTool$CustomRowMap.mapRow(CommDbOperTool.java:71)
org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:92)
org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:600)
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:538)
org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:588)
org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:617)
org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:625)
org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:657)
com.myapp.db.dao.AccountCashingDao.getAccountCashingBySiteUserID(AccountCashingDao.java:49)
com.mycom.myapp.user.manager.AccountManager.getAccountCashingBySiteUserID(AccountManager.java:158)
com.mycom.myapp.user.manager.AccountManager$$FastClassByCGLIB$$ab87176b.invoke()
net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:694)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:629)
com.mycom.myapp.user.manager.AccountManager$$EnhancerByCGLIB$$cdf0dc72.getAccountCashingBySiteUserID()
com.mycom.myapp.webapp.action.AccountCashingAction.listCashing(AccountCashingAction.java:85)
com.mycom.myapp.webapp.action.AccountCashingAction.execute(AccountCashingAction.java:54)
org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:118)
com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:52)
com.mycom.webapp.filter.GZIPFilter.doFilterInternal(GZIPFilter.java:42)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
com.mycom.webapp.filter.LocaleFilter.doFilterInternal(LocaleFilter.java:63)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.13 logs.


--------------------------------------------------------------------------------

Apache Tomcat/6.0.13

2008年8月26日星期二

STX Transform Notes

I tries to transform xml with Joost(STX), but I found that sometimes the child nodes cannot be matched and transformed.
Finally I found the problem was tied with the XML namespace, and made the transform working in this way, please notice the prefix "myns" both in root node and child nodes:

Source XML:

<RootNode xmlns="http://.... " >
<ChildNode>
....

STX:
<stx:transform version="1.0"
xmlns:stx="http://stx.sourceforge.net/2002/ns"
xmlns:myns="http://www.../" >

<stx:template match="myns:RootNode">
...
<stx:template>

<stx:template match="myns:ChildNode">
...
<stx:template>

How to output new line in result xml in STX transform

I'm new to professional xml develop and boring the transformed result xml is always one large line those days.
Now I found the way out,

"<stx:text>&# xA;</stx:text>" is the solution!
(please remove the white space, google can not post xml code?)

2008年8月11日星期一

发现 Foxmail 的一个逻辑 BUG

今天网络情况不咋样, 开个网页经常打不开.
用 Foxmail 一直收不到信.
没有设置让foxmail记住密码.
一旦网络坏掉而没有成功收信, 下次收信时, foxmail会再次询问密码.

我认为这是一个很严重的逻辑问题, 应该在密码错误的情况下才应该询问密码, 而不是在网络出错的情况下.

I'm back

习惯了用雅虎邮箱来做一切事, 现在又回归到这个google帐号.