Skip to content

Instantly share code, notes, and snippets.

Avatar

arganzheng arganzheng

View GitHub Profile
View 优雅的builder.md

优雅的Builder模式

package com.baidu.global.mobile.hao123.nantianmen.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
View setenv.sh
# determine base directory; preserve where you're running from
#echo "Path to $(basename $0) is $(readlink -f $0)"
realpath=$(readlink -f "$0")
filepath=$(dirname "$realpath")
basedir=${filepath%/*}
LOG_DIR=${basedir}/logs
mkdir -p ${LOG_DIR}
GC_LOG_DIR=${basedir}/logs/gc
mkdir -p ${GC_LOG_DIR}
View Import an existing repository to Bitbucket
如果你本地工程已经是一个Git Repository(已经执行过[Import an existing, unversioned code project to an empty repository]),那么可以这样把它加入你在Bitbucket创建的远程仓库中:
cd /path/to/my/repo
# Creates a remote named "origin" pointing at your GitHub/Bitbucket repository (设置远程仓库地址)
git remote add origin ssh://git@bitbucket.org/arganzheng/remote-terminator.git
# Sends your commits in the "master" branches to GitHub/Bitbucket
git push -u origin master
当然在你能push之前必须先设置你的账号信息,并且最好使用Password Caching或者SSH key避免每次提交代码都要提示输入密码。
View lottery_create.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>微生活抽奖模块管理后台</title>
<link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="/static/css/datetimepicker.css" rel="stylesheet" media="screen">
</head>
<body>
@arganzheng
arganzheng / ok.jsp
Created Jul 11, 2013
可以使用这个ok.jsp检查应用是否正常启动
View ok.jsp
<%@page import="org.springframework.web.context.WebApplicationContext"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="org.springframework.web.context.support.XmlWebApplicationContext"%>
<%
XmlWebApplicationContext context = (XmlWebApplicationContext)WebApplicationContextUtils.getWebApplicationContext(application);
try{
if(!context.isActive()){
context.refresh();
}
View MappingJsonpHttpMessageConverter.java
package me.arganzheng.study;
import java.io.IOException;
import java.io.PrintStream;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
import org.springframework.http.HttpOutputMessage;
import org.springframework.http.converter.HttpMessageNotWritableException;
import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter;
View redirect-with-js-after-some-time.md

JS实现一段时间后自动调转页面

setTimeout(function(){
	window.location.href="./modules.xhtml?source=${source}";
	}, 2000
);
View config-log4j-for-ibatis-to-print-sql.md

如何打印ibatis拼凑的动态SQL语句

log4j.logger.java.sql.PreparedStatement=debug
log4j.logger.java.sql.Connection=debug

将打印出Connection和Statement信息:

[DEBUG] 11:48:17 Connection - {conn-100000} Connection
[DEBUG] 11:48:17 Connection - {conn-100000} Preparing Statement:    select api.id   from t_api_metadata_api api,   t_api_metadata_module module   where api.module_id=module.id   and api.source = ?   and api.name = ?       and     api.module_id = ?        and     module.name = ?         
View XmlFileApiMetadataDao.java
package me.arganzheng.study.metadata.dao;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.List;
import javax.xml.bind.JAXBContext;
@arganzheng
arganzheng / ApiDao.java
Last active Dec 19, 2015
如何autowired sqlMapClient到Dao对象中,解决这个问题`java.lang.IllegalArgumentException: Property 'sqlMapClient' is required`。参考文章: 1. http://edwin.baculsoft.com/2010/08/yet-another-simple-swing-spring-and-ibatis-integration-example/ 2. http://stackoverflow.com/questions/3807707/injecting-derived-property-for-repository-bean-without-autowired-in-super-clas
View ApiDao.java
@Repository
public class ApiDao extends SqlMapClientDaoSupport {
// empty constructor
public ApiDao() {
}
// autowired constructor
// i dont know why, but i cant autowired sqlMapClient directly
// it will cause java.lang.IllegalArgumentException: Property 'sqlMapClient' is required