Skip to content

Instantly share code, notes, and snippets.

@aliencode
aliencode / properties.java
Created August 11, 2013 03:37
Java properties 文件读取
Properties prop = new Properties();
try {
prop.load(this.getClass().getClassLoader().getResourceAsStream("properties/application.routing.properties"));
} catch (IOException e) {
e.printStackTrace();
}
prop.getProperty(strVal, strVal);
@aliencode
aliencode / build.gradle
Created August 7, 2013 06:40
Gradle TestNg 指定 suite 文件
test {
useTestNG(){
suites(file('src/test/resources/testng.xml'))
}
}
@aliencode
aliencode / Environment .java
Created August 7, 2013 05:05
Spring获取当前运行环境
@Autowired
Environment env;
@aliencode
aliencode / mvc.xml
Created July 30, 2013 04:51
Spring redirect 不带参数
<mvc:annotation-driven ignoreDefaultModelOnRedirect="true" />
@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 / 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 / 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 / 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 / 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_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"