This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'java' | |
apply plugin: 'application' | |
mainClassName = "package.MainClass" | |
dependencies { | |
compile fileTree(dir: 'libs', include: '*.jar') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.servlet.ServletOutputStream | |
import javax.servlet.http.* | |
trait ServletTestCase { | |
def parameters = [:] | |
def requestAttributes = [:] | |
def sessionAttributes = [:] | |
def responseContentType | |
def responseHeaders = [:] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.sun.net.httpserver.* | |
Object.metaClass.webapp = { | |
{ path -> | |
try { | |
def attrs = path.split('/')[1..-1] | |
[200, owner.delegate.invokeMethod(attrs.head(), attrs.tail() as Object[]) as String] | |
} catch (Exception e) { | |
[500, e as String] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task showJars << { | |
configurations.compile.each { println it } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Iterator; | |
public class LookaheadIterator implements Iterator { | |
private Iterator iter; | |
private boolean hasLookahead; | |
private Object lookahead; | |
public LookaheadIterator(Iterator iter) { | |
this.iter = iter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def makeContent(file) { | |
if (file.directory) { | |
[ file: file.name, type: 'dir', contents: file.listFiles().collect { makeContent(it) } ] | |
} else { | |
[ file: file.name, type: 'file' ] | |
} | |
} | |
def map = makeContent(new File( 'conf' )) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'pmd' | |
pmd { | |
consoleOutput = true | |
ruleSets = ['java-basic', 'java-braces', 'java-imports', 'java-design', 'java-typeresolution', 'java-unnecessary'] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First verify the version of Java being used is not SunJSK. | |
java -version | |
# Get the latest Sun Java SDK from Oracle http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u1-download-513651.html | |
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u74-b02/jdk-8u74-linux-x64.rpm | |
# Rename the file downloaded, just to be nice | |
# mv jdk-7u1-linux-i586.rpm\?e\=1320265424\&h\=916f87354faed15fe652d9f76d64c844 jdk-7u1-linux-i586.rpm | |
# Install Java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// calculate odds to draw at least one card in target set from a deck | |
// with n draws | |
// total size | |
def deckSize = 52 | |
// cards already consumed | |
def burned = 0 | |
// number of copies of card we're looking for in the deck | |
def targets = 4 | |
// number of draws we have |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grapes([ | |
@Grab(group='org.eclipse.jetty', module='jetty-server', version='8.1.18.v20150929'), | |
@Grab(group='org.eclipse.jetty', module='jetty-servlet', version='8.1.18.v20150929'), | |
@Grab(group='org.eclipse.jetty', module='jetty-servlets', version='8.1.18.v20150929') | |
]) | |
import org.eclipse.jetty.server.Server | |
import org.eclipse.jetty.servlet.ServletHandler | |
import org.eclipse.jetty.servlets.ProxyServlet |
OlderNewer