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
<?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> |
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
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" } | |
} |
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
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 } |
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
# 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()"' |
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 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) | |
} |
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
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 { |
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
<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" /> |
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
# Actually, lists the installed files in the order they were updated, most recent first. | |
# All the unmodified files will have the same last modified date, so it should be pretty | |
# easy to spot where the updated files begin. | |
PACKAGE=jetty # Replace with your package | |
ls -lt $(ls -Fd1 $(dpkg -L $PACKAGE) | grep -v "[\/\@]$") |
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
// Using Matcher object returned by =~ operator | |
matcher = "Hello world v1.01" =~ /.* v(\S*)/ | |
if (matcher.matches()) version = matcher[0][1] | |
assert version == "1.01" | |
// We can make this a little tidier using the 'with' method | |
version = ("Hello world v1.01" =~ /.* v(\S*)/).with { matches() ? it[0][1] : null } | |
assert version == "1.01" |
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
@GrabResolver(name='javahg', root='https://oss.sonatype.org/content/repositories/snapshots/') | |
@Grab(group='com.aragost.javahg', module='javahg', version='0.3-SNAPSHOT') | |
import com.aragost.javahg.* | |
import com.aragost.javahg.commands.* | |
config = new RepositoryConfiguration() | |
config.hgrcPath = null // forces Mercurial to look in the usual places for .hgrc | |
rep = Repository.open(config, new File('.')) // assume the current directory is a repo | |
// Print the status of the repo |
OlderNewer