Skip to content

Instantly share code, notes, and snippets.

@saltnlight5
saltnlight5 / web-3.xml
Created November 29, 2012 05:37
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<description>Groovy Web Application</description>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
@saltnlight5
saltnlight5 / java.sh
Created November 16, 2012 12:02
java.sh
#!/usr/bin/env bash
# Author: Zemian Deng, Date: 2012-11-16_06:30:00
# java.sh - A Java wrapper that auto setup classpath to run in Cygwin, Unix or Linux shell.
# We assume this script is located in a subdiretory inside the application home directory.
# Example:
# app/bin/java.sh
# app/config/log4j.properties
# app/lib/log4j.jar
# Usage:
# bash> java.sh app.Hello
@saltnlight5
saltnlight5 / compile.sh
Created November 15, 2012 01:19
kotlinc_bin tools
#!/usr/bin/env bash
# Author: Zemian Deng, Date: 2012-11-13_22:53:54
#
# Compile Kotlin source files and write into 'out' directory.
#
KOTLIN_DIR=$(cd $(dirname $0)/.. && pwd)
SRC='$KOTLIN_DIR/src'
if [[ $# -ge 1 ]]; then SRC=$1; shift; fi
CP=${CP:=}
@saltnlight5
saltnlight5 / Default.sublime-keymap
Created November 1, 2012 13:53
ZemianNameAndDate.py
// SublimeText user keymap
// Author: Zemian Deng, Date: 2012-11-01_09:55:03
[
{ "keys": ["ctrl+alt+f6"], "command": "reindent"},
{ "keys": ["ctrl+alt+f5"], "command": "zemian_name_and_date"},
{ "keys": ["ctrl+alt+n"], "command": "new_note_file"}
]
@saltnlight5
saltnlight5 / parsepom.xml
Created October 31, 2012 20:50
parsepom.xml
// Parse pom.xml and print all dependency elements in single line for gradle use instead.
// Zemian Deng 11/1/2012
depMap = [:].withDefault{ [] }
project = new XmlParser().parse("pom.xml")
project.dependencies[0].each{ dependency ->
line = "'" + dependency.groupId.text() + ":" +
dependency.artifactId.text() + ":" +
dependency.version.text() + "'"
scope = dependency.scope.text() ?: 'compile'
depMap[scope] << line
@saltnlight5
saltnlight5 / mkgradleproject.sh
Created October 31, 2012 17:15
mkgradleproject.sh
PROJ=java-demo
if [[ $# -ge 1 ]]; then PROJ=$1; fi
echo "Creating $PROJ project."
if [[ -e $PROJ ]]; then
echo "ERROR: $PROJ already exists."
exit 1
fi
# Create a java project with Gradle build script.
@saltnlight5
saltnlight5 / printclasspath-build.gradle
Created October 31, 2012 15:50
printclasspath-build.gradle
// Problem with http://issues.gradle.org/browse/GRADLE-2381
apply plugin: 'java'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
testCompile(
'org.neo4j:neo4j-kernel:1.8.M05:tests'
@saltnlight5
saltnlight5 / hibernate-build.gradle
Created October 31, 2012 14:24
hibernate-build.gradle
// A Gradle build script for a typical Hiberante+Spring data project.
//
// Author: Zemian Deng <saltnlight5@gmail.com> 10/31/2012
apply plugin: 'java'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
@saltnlight5
saltnlight5 / build.gradle
Created October 31, 2012 14:01
build.gradle
// Gragle build script for a Java application
apply plugin: 'java'
repositories { mavenCentral() }
dependencies {
testCompile(
//compile(fileTree(dir: gradle.gradleHomeDir, include: 'lib/**/*.jar')),
'org.hamcrest:hamcrest-library:1.3',
'junit:junit:4.11-beta-1'
)
compile(
@saltnlight5
saltnlight5 / killjava.sh
Created October 29, 2012 15:35
killjava.sh
# Terminate all java processes forcefully!
# This script is for Cygwin only.
# WARN: Be very sure what's what you want. You usually want this if they are stuck and
# not responsive.
LIST=$(jps -l | grep -v 'sun.tools.jps.Jps')
echo $LIST
for PID in $(echo $LIST | ruby -a -ne 'puts $F[0]'); do
echo "Killing Java PID $PID"
/usr/bin/kill -f $PID
done