Skip to content

Instantly share code, notes, and snippets.

@aliencode
aliencode / ServiceLoader.md
Last active December 23, 2015 18:59
通过接口加载其实现子类

##java

package com.demo;
public abstract class Service1 {
    private static Service1 getInstance() {
    	return ServiceLoader.load(Service1.class).iterator().next();
    }
}
@aliencode
aliencode / default.xml
Created September 15, 2013 03:29
使用SPRING MVC时让WEB容器处理静态资源
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/static/*</url-pattern>
</servlet-mapping>
@aliencode
aliencode / seconds.md
Created September 11, 2013 07:39
秒单位换算
0,000 000 000 000 000 000 000 001	yoctosecond [ ys ]
0,000 000 000 000 000 000 001	        zeptosecond [ zs ]
0,000 000 000 000 000 001	        attosecond [ as ]
0,000 000 000 000 001	                femtosecond [ fs ]
0,000 000 000 001                       [ trillionth ]	picosecond [ ps ]
0,000 000 001                           [ billionth ]	nanosecond [ ns ]
0,000 001                               [ millionth ]	microsecond [ µs ]
0,001                                   [ thousandth ]	millisecond [ ms ]
0.01 [ hundredth ]	centisecond [ cs ]
@aliencode
aliencode / servlet.md
Created September 9, 2013 09:24
SERVLET3.0 注解

##注册一个servlet

@WebServlet(name = "captcha-servlet", value = "/getcaptcha")
public class CaptchaServlet extends HttpServlet {

}

GenericServlet要使用HttpServlet

@aliencode
aliencode / property-placeholder.md
Last active December 22, 2015 08:39
Spring context:property-placeholder 加载顺序和覆盖

##设定加载顺序,数字大的优先加载

<context:property-placeholder location="classpath*:/context2.properties" order="0"/>
<context:property-placeholder location="classpath*:/context.properties" order="100"/>

context2.properties将覆盖context.properties中的值。

##覆盖其它properties

@aliencode
aliencode / factorybean.java
Created September 2, 2013 03:48
Spring获取factory bean本身
//加前缀&
getBean("&factorybeanid")
@aliencode
aliencode / random.java
Created September 2, 2013 02:34
JAVA随机数
//1000 - 9999
Random generator = new Random();
int id = generator.nextInt(9999) + 1000;
@aliencode
aliencode / textarea.css
Created August 17, 2013 11:34
Textarea 禁用缩放功能
textarea {
resize: none;
}
/*Or, if need only vertical resize:*/
textarea {
resize: vertical;
}
@aliencode
aliencode / 1.css
Created August 17, 2013 06:47
CSS移除输入框焦点高亮边框
textarea:focus, input:focus{
outline: 0;
}
@aliencode
aliencode / 1.md
Created August 17, 2013 04:58
github markdown table
  dog | bird | cat
  ----|------|----
  foo | foo  | foo
  bar | bar  | bar
  baz | baz  | baz

dog | bird | cat