Skip to content

Instantly share code, notes, and snippets.

@yongboy
yongboy / ICommentService.java
Created January 5, 2011 10:02
just for demo...
public interface ICommentService {
void pagingComments(Paging<Comment> pager, YpwapTypes objType,
Object objUuid);
Comment get(Integer id);
void update(Comment comment);
void save(Comment comment);
String.prototype.template=function(){
var args=arguments;
return this.replace(/\{(\d+)\}/g, function(m, i){
return args[i];
});
}
var html = '<div class="logDiv">'
+ '<div class="contentDiv">{0}</div>'
+ '<div class="tipDiv">last date : {1}</div>'
+ '<div class="clear">&nbsp;</div>'
@yongboy
yongboy / BigPipeDemoServlet.java
Created February 22, 2011 06:53
模拟Facebook BigPipe异步展现页面
/**
* 模拟Facebook BigPipe异步展现页面
* @author yongboy
* @date 2011-2-21
* @version 1.0
*/
@WebServlet(urlPatterns = "/bigPipeDemoServlet", asyncSupported = true)
public class BigPipeDemoServlet extends HttpServlet {
private static final long serialVersionUID = 14526556595656565L;
private static final Log log = LogFactory.getLog(BigPipeDemoServlet.class);
@yongboy
yongboy / subCnString.java
Created March 14, 2011 07:07
字符串截取(设定中文长度为2)
/**
* 定义中文字符Unicode编码范围
*/
private static final String CN_PATTERN = "[\\u4e00-\\u9fbb]+";
public static final String subCnString(String str, int targetLen) {
if (str == null || str.equals(""))
return str;
if (targetLen < 1)
@yongboy
yongboy / date.jsp
Created May 21, 2011 10:09
jstl format test
<%@ page language="java" contentType="text/html; charset=GBK"
pageEncoding="GBK"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
String date = "2011-05-21 18:20:32.0";
request.setAttribute("dateStr", date);
request.setAttribute("nowDate", new java.util.Date());
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
@yongboy
yongboy / DownPage.java
Created June 27, 2011 23:46
DownPage.java
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashSet;
import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ExecutorService;
@yongboy
yongboy / gist:1581399
Created January 9, 2012 06:03
BeanCopyTest.java
import java.lang.reflect.InvocationTargetException;
import java.util.Date;
import net.sf.cglib.beans.BeanCopier;
import org.apache.commons.beanutils.BeanUtils;
/**
* 测试属性拷贝
* @author nieyong
@yongboy
yongboy / DemoAsync3Action.java
Created January 17, 2012 09:37
DemoAsync3Action.java
package com.servlet3.demo;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
@yongboy
yongboy / DownloadFileAction.java
Created January 18, 2012 08:00
DownloadFileAction.java
package com.servlet3.demo;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.Writer;
import javax.servlet.ServletException;
@yongboy
yongboy / DownloadFileZeroCopyAction.java
Created January 18, 2012 08:11
DownloadFileZeroCopyAction.java
package com.servlet3.demo;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;