Skip to content

Instantly share code, notes, and snippets.

View EwanDawson's full-sized avatar

Ewan Dawson EwanDawson

View GitHub Profile
@EwanDawson
EwanDawson / logback.xml
Created June 5, 2011 17:41
Logback configuration for versions < 0.9.19
<configuration debug="true" scan="true" scanPeriod="30 seconds">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout>
<pattern>%d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n</pattern>
</layout>
</appender>
<root level="warn">
<appender-ref ref="STDOUT" />
@EwanDawson
EwanDawson / BuildConfig.groovy
Created June 5, 2011 16:16
Grails BuildConfig for using logback instead of log4j
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
//grails.project.war.file = "target/${appName}-${appVersion}.war"
grails.project.dependency.resolution = {
inherits("global") {
excludes "slf4j-log4j12"
}
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
repositories {
@EwanDawson
EwanDawson / gist:1001984
Created June 1, 2011 08:30
Groovy closure delegation test
import spock.lang.Specification
class ClassInstanceAccessFromWithinClosureSpec extends Specification {
def component = new ClassUnderTest()
def "class instance variable is accessible when called from within closure delegated to Object" (){
setup: def delegate = new Object()
expect: component.execute(delegate)
}
# add alias to get latest version of mongo cheatsheet
alias mongocheat='curl -s http://cheat.errtheblog.com/s/mongo | groovy -e "@Grab(group=/net.sourceforge.nekohtml/, module=/nekohtml/, version=/1.9.14/)import org.cyberneko.html.parsers.SAXParser;println new XmlSlurper(new SAXParser()).parseText(System.in.text).depthFirst().find{ it.@class == /sheet/}.text()"'
class Appointment implements Comparable {
LocalDateTime time
String description
String place
// Define a natural ordering of Appointments
// base on their times.
int compareTo(that) { this.date <=> that.date }
void mapsAreEqual(Map a, Map b) {
if ( a == null || b == null ) { assert a == b; return }
assert a.keySet().sort()*.toString() == b.keySet().sort()*.toString()
a.each{ key, value -> assert "${b[key]}" == "$value" }
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.your-company</groupId>
<artifactId>your-project</artifactId>
<version>0.1-SNAPSHOT</version>
<name>your-project</name>