Skip to content

Instantly share code, notes, and snippets.

@aliencode
aliencode / Spring3-use-properties.xml
Last active December 18, 2015 10:48
Spring3 引入 properties 文件
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations" value="classpath:zookeeper.properties"/>
</bean>
@aliencode
aliencode / Get-Context-Param.md
Last active December 18, 2015 11:58
获取web.xml里的context-param配置

##web.xml:

    <context-param>
        <param-name>email</param-name>
        <param-value>[email protected]</param-value>
    <context-param>
@aliencode
aliencode / handlebar.md
Created June 28, 2013 02:24
handlebar 方法参考文档

handlebar 方法参考文档

介绍

Handlebars是JavaScript一个语义模板库,通过对view和data的分离来快速构建Web模板。它采用"Logic-less template"(无逻辑模版)的思路,在加载时被预编译,而不是到了客户端执行到代码时再去编译, 这样可以保证模板加载和运行的速度。Handlebars兼容Mustache,你可以在Handlebars中导入Mustache模板。

使用与安装

Handlebars的安装非常简单,你只需要从Github下载最新版本,你也可访问下面网址获取最新信息:http://handlebarsjs.com。 目前handlebars.js已经被许多项目广泛使用了,handlebars是一个纯JS库,因此你可以像使用其他JS脚本一样用script标签来包含handlebars.js

@aliencode
aliencode / build_check.libversions.groovy
Created July 4, 2013 04:20
Gradle检测所有依赖版本是否有更新
task '_check.libversions'(description: 'check all dependencys version!') << {
def checked = [:]
allprojects {
configurations.each { configuration ->
configuration.allDependencies.each { dependency ->
def version2 = dependency.version
if(version2!=null && !version2.contains('SNAPSHOT') && !checked[dependency]) {
def group = dependency.group
def name = dependency.name
def url = "http://search.maven.org/solrsearch/select?q=g:%22${group}%22%20a:%22${name}%22&wt=mxl"
@aliencode
aliencode / build.gradle
Created July 5, 2013 07:12
Gradle判断操作系统
import org.apache.tools.ant.taskdefs.condition.Os
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
} else {
}
@aliencode
aliencode / build.gradle
Created July 5, 2013 07:39
Gradle - 解析Exec的输出结果 Exec DSL调用方法
task svninfo << {
new ByteArrayOutputStream().withStream { os ->
def result = exec {
executable = 'svn'
args = ['info']
standardOutput = os
}
def outputAsString = os.toString()
def matchLastChangedRev = outputAsString =~ /Last Changed Rev: (\d+)/
println "Latest Changed Revision #: ${matchLastChangedRev[0][1]}"
@aliencode
aliencode / find-nearby.js
Created July 7, 2013 03:17
jQuery查找附近某个元素
$('.postTitle').each(function(p){
//向后*nextAll*或向前*prevAll*
$(this).attr('data-date', $(this).nextAll('.postDesc').eq(0).text() )
})
@aliencode
aliencode / app.xml
Last active December 20, 2015 02:49
读取Properties配置文件值
<!-- 引用 -->
<context:property-placeholder ignore-resource-not-found="true"
location="classpath*:/application.properties,classpath*:/application.development.properties"/>
@aliencode
aliencode / Controller.java
Created July 23, 2013 08:24
##Spring3.2 Controller RequestMapping use properties file. 可配置的RequestMapping地址.
//${key:defaultValue}
@RequestMapping("${sys.user:/adm/user}" )
@aliencode
aliencode / mvc.xml
Created July 30, 2013 04:51
Spring redirect 不带参数
<mvc:annotation-driven ignoreDefaultModelOnRedirect="true" />