Skip to content

Instantly share code, notes, and snippets.

View ataylor284's full-sized avatar

Andrew Taylor ataylor284

View GitHub Profile
@ataylor284
ataylor284 / build.gradle
Created December 21, 2015 17:41
Snippet for pmd code checks.
apply plugin: 'pmd'
pmd {
consoleOutput = true
ruleSets = ['java-basic', 'java-braces', 'java-imports', 'java-design', 'java-typeresolution', 'java-unnecessary']
}
@ataylor284
ataylor284 / build.gradle
Created November 19, 2015 20:18
Snippet for showing path names of jar dependencies.
task showJars << {
configurations.compile.each { println it }
}
@ataylor284
ataylor284 / ServletTestCase.groovy
Created February 27, 2015 22:39
A quick and dirty trait for testing legacy Java servlets.
import javax.servlet.ServletOutputStream
import javax.servlet.http.*
trait ServletTestCase {
def parameters = [:]
def requestAttributes = [:]
def sessionAttributes = [:]
def responseContentType
def responseHeaders = [:]
@ataylor284
ataylor284 / keybase.md
Created October 1, 2014 03:14
keybase

Keybase proof

I hereby claim:

  • I am ataylor284 on github.
  • I am ataylor284 (https://keybase.io/ataylor284) on keybase.
  • I have a public key whose fingerprint is 981F 1299 904E BC0C EA45 CE4B BC0C 1BE0 5C34 6162

To claim this, I am signing this object:

@ataylor284
ataylor284 / build.gradle
Created June 13, 2014 16:52
Simple gradle build file for Java application with jar dependencies.
apply plugin: 'java'
apply plugin: 'application'
mainClassName = "package.MainClass"
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
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' ))
@ataylor284
ataylor284 / LookaheadIterator.java
Last active December 16, 2015 06:09
LookaheadIterator
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;
@ataylor284
ataylor284 / webapp.groovy
Created November 16, 2010 19:31
inspired by gist: 675667 -- expose any groovy object over the web
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]
}