2009年11月5日

免費的VPN

免費的VPN


alonweb
alonweb
需要申請帳號(免費)
速度還不錯,雖然偶爾會有廣告,兩台伺服器(荷蘭,巴拿馬)可供選擇
HTTP上限2M
所以開開網頁~MSN都還滿好用的~當然不能下載超過2M的檔案就是
但是會有ROUTE問題

UltraVPN
需要申請帳號(免費)
法國的免費VPN~沒有流量限制~跟REQUST限制~但是連線慢~速度也慢
但是會有ROUTE問題


loki
美國新的VPN
在公司測試MSN很正常~但是網頁真的很慢
下載約34Kbs其實很慢
但是設定容易安裝容易也不需要設定路由設定



thefreevpn/
美國加拿大的VPN,需安裝軟體(核心是用OPENVPN架構),或許要設定路由
在公司尚未測試

2009年10月15日

好用 快速的 OPENVPN - Ace VPN

Ace VPN
acevpn.com/
如果在公司或是外面不安全的網路環境
想要上網又怕資料外洩或是網站被封閉
這個時候就只能使用VPN
其中OPENVPN是一個最好的選擇
這其中
Ace VPN
提供了便宜或是免費的VPN服務
安裝使用相當便利
一個月只要 5 塊錢美金~雖然目前只有美國歐洲適用
但相信不久以後台灣這邊應該可以享受的到服務了
使用Ace VPN
好處好多
可以隱藏自己的IP
突破防火牆
瀏覽被限制的網站
使用MSN等IM軟體

2009年10月14日

OPENVPN 設定與route

免費 openvpn
http://alonweb.com/

安裝VPN之後
執行
netsh -c interface dump
取得網路卡所有設定
此時應該有兩張網卡設定
interface 1 --> 內網
interface 2 --> VPN網

interface 2 之 DNS 設定
改成
interface 1 之DNS

---------------------
# "{???}" 的介面 IP 設定

set address name="{???}" source=dhcp
set dns name="{???}" source=dhcp register=PRIMARY
set wins name="{???}" source=dhcp
---------------------
修改成

??? -> VPN網卡設定
將設定資料存檔
利用
netsh -f XX.txt
匯入設定

設定 router設定
route add destination mask netmask gateway
例如
route -p add 10.0.0.0 mask 255.0.0.0 172.2.5.253
將目的地 10.0.0.0 (netmask 為 255.0.0.0) 之網域指定給 172.2.5.253
-p 為永久寫入
如不指定 則為暫時寫入 重開機之後會消失

如此
連上網路時
DNS使用內網專屬DNS
而內網與外網則可不同路線

2009年8月12日

facebook 的 世界海盗王

記得幫點阿
facebook 的 世界海盗王

http://apps.facebook.com/pirates_world/new.php?invite=swpoker

2009年6月29日

wii

http://www.wiiholic.com

http://www.wii.club.tw


用硬碟玩Wii遊戲的時代來臨(安裝步驟圖文詳解)新增遊戲安裝列表
http://kissjojo99.pixnet.net/blog/post/23134530

Wii中文說明書
http://game.ps2ps3.com/wii/


http://www.corumcollege.com/forum/forumdisplay.php?f=53

2009年6月24日

ORACLE 有關時間的格式表

















































































MMNumeric month (e.g., 07)
MONAbbreviated month name (e.g., JUL)
MONTHFull month name (e.g., JULY)
DDDay of month (e.g., 24)
DYAbbreviated name of day (e.g., FRI)
YYYY4-digit year (e.g., 1998)
YYLast 2 digits of the year (e.g., 98)
RRLike YY, but the two digits are ``rounded'' to a year in
the range 1950 to 2049.
Thus, 06 is considered 2006 instead
of 1906
AM (or PM)Meridian indicator
HHHour of day (1-12)
HH24Hour of day (0-23)
MIMinute (0-59)
SSSecond (0-59)

2009年6月23日

ant for spring

ant for spring
參考網路文件設定而成
主要是在ant 可執行 spring 中 bean 的task
ant-xml:







































destdir="${classes}"
encoding="utf-8"
>





























update="true"
>











id="test.1"
beanName="test"
method="execute"
classpathref="all.path"
beanlocation="test.xml"
beanlocationref="beanconfig.path"
>


refid="test.1"
method="execute1"
>


refid="test.1"
method="execute2"
>














testinputA1
testinputA2


















src:
SpringMethodCallValue.java

package spring_ant;

import org.apache.tools.ant.Task;

public class SpringMethodCallValue extends Task{

String value;
public void addText(String text) {
value = text;
}

}


MethodExecute.java

package spring_ant;

import java.util.*;
import java.lang.reflect.*;
public class MethodExecute {
String name;

List params=new ArrayList();;

public MethodExecute(String name,Object [] params){
this(name,Arrays.asList(params));
}

public MethodExecute(String name,List params){
this(name);
addParams(params);
}
public MethodExecute(String name ){
this.name=name;
}

public void addParam(Object value){
addParams(Arrays.asList(new Object[]{value}));
}
public void addParams(Collection values){

this.params.addAll(values);
}


Method findMethod(Class c) throws Exception{
Class [] mc = new Class[this.params.size()];
for(int i=0;i < this.params.size();i++){
mc[i]=this.params.get(i).getClass();
}

Method [] ms = c.getMethods();
Method m;
Class [] _mc;
boolean _ck=true;
for(int i = 0;i < ms.length;i++){
m = ms[i];
if(!m.getName().equals(name)){
continue;
}
_ck=true;
_mc=m.getParameterTypes();
if(mc.length == _mc.length){
for(int j=0;j < mc.length;j++){
if(!_mc[j].isAssignableFrom(mc[j])){
_ck=false;
break;
}
}
if(_ck){
return m;
}
}
}

throw new NoSuchMethodException(c.getName()+"."+name+"("+Arrays.asList(mc)+") not found");
//return c.getMethod(name, mc);
}


public Object execute(Object obj) throws Exception{
Class c = obj.getClass();
Method m = findMethod(c);
return m.invoke(obj, params.toArray());
}


public String toString(){
return "name="+name+" ,values="+params;
}

}


Spring.java

package spring_ant;


import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.util.ReflectionUtils;

import java.util.*;
import java.io.*;
import java.lang.reflect.*;

import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.Path;

import org.apache.tools.ant.types.Reference;
import org.apache.tools.ant.AntClassLoader;

public class Spring extends Task {
String defaultSpringConfig = "spring-config.xml";
String defaultCall = "execute";

String id;
//Path beanlocation ;
List beanlocation = new ArrayList(Arrays.asList(new String[]{defaultSpringConfig})) ;
Path classpath ;
String bean;
//String method=null;
MethodExecute _method=null;
BeanFactory beanFactory;
Object tobj;

// init
public void init(){
super.init();
classpath =new Path(this.getProject());
}

public void setBeanlocation(String path){
beanlocation.addAll(Arrays.asList(path.split("[,;\n]")));
}

public void setBeanlocationref(String id){
Path _path = new Path(this.getProject());
_path.setRefid(new Reference(this.getProject(),id));
beanlocation.addAll(Arrays.asList(_path.list()));
}

public void setClasspathref(String id){
classpath.setRefid(new Reference(this.getProject(),id));
}

public void setBeanName(String bean){
this.bean=bean;
}
public void setMethod(String methodCall){
this._method=new MethodExecute(methodCall);
}
public void addConfiguredMethod(SpringMethodCall mc){
//mc.maybeConfigure();
//this.log("mc=" + mc);
//this.log("mc.name=" + mc.name);
this._method=new MethodExecute(mc.name,mc.values);
}


public void setId(String id){
this.id = id;
this.getProject().addIdReference(id, this);
}

public void setRefid(String refid){
Spring rf = (Spring)this.getProject().getReference(refid);
if(rf == null){
throw new RuntimeException(" refid["+refid+"] not found");
}
beanlocation = rf.beanlocation ;
classpath =rf.classpath ;
bean=rf.bean;
_method=rf._method;
beanFactory=rf.beanFactory;
tobj=rf.tobj;
}






public void execute(){
//checkBeanloactions
getCheckBeanloactions();
//check attributes
assertCheck();
//load classpath if need
loadClasspath();
//find object and invoke method
invoke();
}

void assertCheck(){
//check bean
//this.log("bean=" + bean);
if(bean == null || "".equals(bean.trim())){
throw new IllegalArgumentException("bean is null or empty");
}

//this.log("method=" + _method);
//this.log("classpath=" + classpath);
//this.log("beanloactions=" + beanlocation);
String [] ckbs = getCheckBeanloactions();
//this.log("ckbs=" + Arrays.asList(ckbs));
if(ckbs.length == 0){
throw new IllegalArgumentException("all beanloactions path not exit :["+beanlocation+"]");
}

}


String [] getCheckBeanloactions(){
List _beanlocation = new ArrayList();
File path;
for( Iterator ite = beanlocation.iterator() ;ite.hasNext(); ){
path =new File((String)ite.next()) ;
if(path.exists()){
_beanlocation.add(path.getAbsolutePath());
}/*else{
this.log("beanloaction["+path+"] is not exist");
}*/
}
String [] rs = new String [_beanlocation.size()];
_beanlocation.toArray(rs);
return rs;
}
void loadClasspath(){
AntClassLoader acl = new AntClassLoader(this.getClass().getClassLoader(), this.getProject(), this.classpath);
acl.setThreadContextLoader();
}
BeanFactory getBeanFactory(){
if(beanFactory == null){
beanFactory = new FileSystemXmlApplicationContext( getCheckBeanloactions());
}
return beanFactory;
}

Object getTargetObj(){
if(tobj == null){
BeanFactory bf = getBeanFactory();
tobj = bf.getBean(this.bean);
}
return tobj;
}

void invoke() {
Object obj = getTargetObj();
if(obj == null){
throw new NullPointerException("bean["+bean+"] not found");
}
// invoke if call not null
if(this._method != null){

//inject BeanFactory
try{
new MethodExecute("setBeanFactory",new Object[]{getBeanFactory()}).execute(obj);
}catch(Exception e){
//donothing
}
//invoke method
try {
this._method.execute(obj);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}






}



SpringClient.java

package spring_ant;

import org.springframework.beans.factory.BeanFactory;

public class SpringClient {
BeanFactory beanFactory;

public BeanFactory getBeanFactory() {
return beanFactory;
}

public void setBeanFactory(BeanFactory beanFactory) {
this.beanFactory = beanFactory;
}

}


SpringMethodCall.java

package spring_ant;
import java.util.*;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
public class SpringMethodCall extends Task{
String name;
List values=new ArrayList();

public SpringMethodCall(){
//this.log("SpringMethodCall ");
}

public void setName(String _name){
//this.log("SpringMethodCall setName="+_name);
this.name=_name;
}

public void setValue(String value){
//this.log("SpringMethodCall setValue="+value);
appendStrValue(value);
}

public void addConfiguredValue(SpringMethodCallValue value){
appendStrValue(value.value);
}

void appendStrValue(String v){
String [] vs = v.split("[,;]");
if(vs.length == 1){
values.add(vs[0]);
}else{
values.add(vs);
}
}

public void execute() throws BuildException {
////this.log("SpringMethodCall.execute");
}



}

在 eclipse 中使用 tomcat 設定 jndi

在eclipse 中
設定servier / tomcat 下 的
1.server.xml
2.web.xml

1.server.xml
找到



AAA : 專案名稱
BBB : context root
在此新增JNDI 如下




2.web.xml
在底下新增以下程式碼,
res-ref-name : JNDI 的名稱
res-type : JNDI 的 TYPE




3.JNDI
tomcat : java:comp/env/jdbc/db

2009年3月5日

浮動定位

浮動元素

可外掛於jqeury
$.markPostion(targetObj,'top'/'bottom',0,'left'/'right',50);



// jquery 1.2.6

function _Position(obj,xtype,x,ytype,y){
this._computes = {
'top':{'postion':function(pos){
t = $(pos.scrollObj).scrollTop();
nt = parseInt($(pos.obj).css('top').replace('px',''));
$(pos.obj).css('top',( t - pos.lasty + nt ) +'px' );
pos.lasty = t;}
},'bottom':{'postion':function(pos){
t = $(pos.scrollObj).scrollTop();
$(pos.obj).css('bottom',( pos.lasty - t + pos.y ) +'px' );
pos.lasty = t;}
},'left':{'postion':function(pos){
t = $(pos.scrollObj).scrollLeft();
nt = parseInt($(pos.obj).css('left').replace('px',''));
$(pos.obj).css('left',( t - pos.lastx + nt ) +'px' );
pos.lastx = t;}
},'right':{'postion':function(pos){
t = $(pos.scrollObj).scrollLeft();
$(pos.obj).css('right',( pos.lastx - t + pos.x ) +'px' );
pos.lastx = t;}
}};
this.obj = obj;
this.xtype = (xtype ? xtype : 'left');
this.x = (x ? x : 0) ;
this.lastx = 0;
this.ytype = (ytype ? ytype : 'top');
this.y = (y ? y : 0) ;
this.lasty = 0;
this.scrollObj = $(window)?$(window):$(document);
this.xcompute = this._computes[this.xtype];
this.ycompute = this._computes[this.ytype];
_Position.prototype.init = function(){
$(this.obj).css('position','absolute').css(this.xtype,this.x+'px').css(this.ytype,this.y + 'px');
this.xcompute.postion(this);
this.ycompute.postion(this);
};
_Position.prototype.postion = function(){
this.xcompute.postion(this);
this.ycompute.postion(this);
};
}

function markPostion(obj,ytype,y,xtype,x ){
var top = new _Position(obj,xtype,x,ytype,y );
top.init();
$(top.scrollObj).scroll(function(){
top.postion();
}).resize(function(){
top.postion();
});
}

$.extend({
'markPostion':markPostion
});



測試:

t1 = $('');
$(t1).append('textA111!!!');
$(t1).css('background-color','#00ff00');
$(document.body).append($(t1));

markPostion(t1);


$.markPostion($('#testC1'),'top',0,'right',50);

2009年3月3日

視窗的SIZE還有SCROLL的位置

Getting window size and scroll bars position in JavaScript/DHTML:
http://www.softcomplex.com/docs/get_window_size_and_scrollbar_position.html
這篇文章分析了視窗的SIZE還有SCROLL的位置(節錄部份)





ParameterwindowdocumentElementbody
Window Widthwindow.innerWidthdocument.documentElement.clientWidthdocument.body.clientWidth
Window Heightwindow.innerHeightdocument.documentElement.clientHeightdocument.body.clientHeight
Horizontal Scrollwindow.pageXOffsetdocument.documentElement.scrollLeftdocument.body.scrollLeft
Vertical Scrollwindow.pageYOffsetdocument.documentElement.scrollTopdocument.body.scrollTop

2009年1月19日

貨幣千位符號


function addsign(value,interval,sign){
var v = $.trim(value);
if(v.length == 0 ){
return '';
}
var rs = '';
for(i = v.length -1,j=1 ;i >= 0 ; i--,j=++j%interval){
rs = ( i!=0 && j==0 ? sign : "" )+ v.charAt(i) + rs ;
}
return rs;
}

function currencyStr(value,round){
if(isNaN(value)){
return '';
}
if(!round){
round = 0;
}
v = $.trim(""+Math.abs(value)).split('.');
return (value < 0 ?"-":"")+ addsign(v[0],3,',')+(v.length > 1 && round > 0 ?"."+ v[1].substr(0,round): "" );
}

2009年1月14日

檔案下載

如果有要使用檔案下載方式
只要宣告幾個部份就可以了


public void download(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/aaa");
res.setHeader("Content-Disposition",new String("attachment;filename=中文.csv".getBytes(),"ISO8859_1"));

OutputStreamWriter out=new OutputStreamWriter(res.getOutputStream());
out.write("aaaa");
out.close();

res.setStatus(res.SC_OK );
res.flushBuffer();
}




這個部份主要改掉預設值 text/html ,只要改成不是'text/html',就可以出現檔案下載的畫面:

res.setContentType("text/aaa");




這個部份主要是提供下載檔名,將檔案名稱使用ISO8859_1編碼即可:

res.setHeader("Content-Disposition",new String("attachment;filename=中文.csv".getBytes(),"ISO8859_1"));







ContentType 參考列表
application/andrew-inset ez
application/mac-binhex40 hqx
application/mac-compactpro cpt
application/mathml+xml mathml
application/msword doc
application/octet-stream bin dms lha lzh exe class so dll
application/oda oda
application/ogg ogg
application/pdf pdf
application/postscript ai eps ps
application/rdf+xml rdf
application/smil smi smil
application/srgs gram
application/srgs+xml grxml
application/vnd.mif mif
application/vnd.mozilla.xul+xml xul
application/vnd.ms-excel xls
application/vnd.ms-powerpoint ppt
application/vnd.wap.wbxml wbxml
application/vnd.wap.wmlc .wmlc wmlc
application/vnd.wap.wmlscriptc .wmlsc wmlsc
application/voicexml+xml vxml
application/x-bcpio bcpio
application/x-cdlink vcd
application/x-chess-pgn pgn
application/x-cpio cpio
application/x-csh csh
application/x-director dcr dir dxr
application/x-dvi dvi
application/x-futuresplash spl
application/x-gtar gtar
application/x-hdf hdf
application/x-httpd-php .php .php4 .php3 .phtml
application/x-httpd-php-source .phps
application/x-javascript js
application/x-koan skp skd skt skm
application/x-latex latex
application/x-netcdf nc cdf
application/x-pkcs7-crl .crl
application/x-sh sh
application/x-shar shar
application/x-shockwave-flash swf
application/x-stuffit sit
application/x-sv4cpio sv4cpio
application/x-sv4crc sv4crc
application/x-tar .tgz tar
application/x-tcl tcl
application/x-tex tex
application/x-texinfo texinfo texi
application/x-troff t tr roff
application/x-troff-man man
application/x-troff-me me
application/x-troff-ms ms
application/x-ustar ustar
application/x-wais-source src
application/x-x509-ca-cert .crt
application/xhtml+xml xhtml xht
application/xml xml xsl
application/xml-dtd dtd
application/xslt+xml xslt
application/zip zip
audio/basic au snd
audio/midi mid midi kar
audio/mpeg mpga mp2 mp3
audio/x-aiff aif aiff aifc
audio/x-mpegurl m3u
audio/x-pn-realaudio ram rm
audio/x-pn-realaudio-plugin rpm
audio/x-realaudio ra
audio/x-wav wav
chemical/x-pdb pdb
chemical/x-xyz xyz
image/bmp bmp
image/cgm cgm
image/gif gif
image/ief ief
image/jpeg jpeg jpg jpe
image/png png
image/svg+xml svg
image/tiff tiff tif
image/vnd.djvu djvu djv
image/vnd.wap.wbmp .wbmp wbmp
image/x-cmu-raster ras
image/x-icon ico
image/x-portable-anymap pnm
image/x-portable-bitmap pbm
image/x-portable-graymap pgm
image/x-portable-pixmap ppm
image/x-rgb rgb
image/x-xbitmap xbm
image/x-xpixmap xpm
image/x-xwindowdump xwd
model/iges igs iges
model/mesh msh mesh silo
model/vrml wrl vrml
text/calendar ics ifb
text/css css
text/html .shtml html htm
text/plain asc txt
text/richtext rtx
text/rtf rtf
text/sgml sgml sgm
text/tab-separated-values tsv
text/vnd.wap.wml .wml wml
text/vnd.wap.wmlscript .wmls wmls
text/x-setext etx
video/mpeg mpeg mpg mpe
video/quicktime qt mov
video/vnd.mpegurl mxu
video/x-msvideo avi
video/x-sgi-movie movie
x-conference/x-cooltalk ice

2009年1月11日

StrUtil



2009年1月10日

WordTemplate

類似word 匯入功能
因為看不到MSDN有關於WORD的API
所以就自己弄了個可以當作樣板的word以供大量產生相同格式的word


Logger

自己弄得logger
為在執行目錄下建立log目錄並且有檔案數目限制


時間格式轉換



測試案例基本JAVA

以下用在測試案例的類別


2009年1月9日

語法高亮-syntaxhighlighter

http://alexgorbatchev.com/
為支援語法高亮的java script
可參考
http://alexgorbatchev.com/SyntaxHighlighter/manual/installation.html


使用方式為:
使用script 比較好~不會有特別字造成的問題




支援語言為:

參考

http://alexgorbatchev.com/SyntaxHighlighter/manual/brushes/

 

Language

Aliases

C++

cpp, c, c++

C#

c#, c-sharp, csharp

CSS

css

Delphi

delphi, pascal

Java

java

Java Script

js, jscript, javascript

PHP

php

Python

py, python

Ruby

rb, ruby, rails, ror

Sql

sql

VB

vb, vb.net

XML/HTML

xml, html, xhtml, xslt

ObjectUtil



語法高亮Syntax Highlighting

Online syntax highlighting
http://tohtml.com
有時候要將 HTML、CSS、Java script 等語法貼到網頁上時,往往無法以顏色標示其重點位置。現在透過Online syntax highlighting工具,可以直接將語法貼上後,線上產生色彩原始碼,只要將這段原始碼貼入自己的網站內,使用者就能夠透過高亮的方式來閱讀這段語法。

Online syntax highlighting目前支援相當多種格式,包括常見的 Java, HTML, CSS, C, C++, PHP, Perl, Python, Ruby 等等語法都可以正確支援和識別顏色。使用方法相當簡單,只要將語法貼入 Source code 的框框內,從右方 Style 挑選欲產生的色彩,Type 部份選擇正確的格式,按下 Highlight 就可完成。同時也會在網頁上產生一個預覽,相當實用。