Skip to content

Instantly share code, notes, and snippets.

assertThat(
listOf(1, 2, 3, 4, 5).filter { it < 3 }
).isEqualTo(
listOf(1, 2)
)
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.8.0</version>
</dependency>
@bugs84
bugs84 / ChangeFromRuntimeToCompile.gradle
Created February 26, 2016 16:07
maven-publish plugin. Hook, change in published pom.xml 'runtime' dependency to compile dependency.
publishing.publications.all {
pom.withXml {
asNode().dependencies.'*'.findAll() {
it.scope.text() == 'runtime' && project.configurations.compile.allDependencies.find { dep ->
dep.name == it.artifactId.text()
}
}.each { it.scope*.value = 'compile'}
}
}
@bugs84
bugs84 / build.gradle
Created October 19, 2015 11:16
Gradle - Get Hg Mercurial revision
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.aragost.javahg:javahg:0.4'
}
}
@bugs84
bugs84 / build.gradle
Created October 9, 2015 13:36
Gradle get hg mercurial changeset revision
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.aragost.javahg:javahg:0.4'
}
}
task revision << {
@bugs84
bugs84 / gist:514cd38ccd480305de1a
Created September 3, 2014 14:54
OQL how to write bytes in heapdump into file in VisualVM
//To get Id of object
//In VisualVM right click on instance of byte[] and select 'Copy ID'
var bytes = heap.findObject(0xe21b95d8);
var filePath = "c:/tmp/result.txt"
var fos = new java.io.FileOutputStream(filePath);
var len = bytes.length
for (var i=0; i<len; i++) {
fos.write(bytes[i]);
}
@bugs84
bugs84 / MavenCompileGroovyAndJava_pom.xml
Last active December 20, 2015 18:08
Maven compile Groovy by groovy-eclipse-compiler
<project ... >
...
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.1.8</version>
</dependency>
</dependencies>
@bugs84
bugs84 / pom.xml
Created July 18, 2013 14:38
Groovy - kompilace Mavenem pomoci groovy-eclipse-compiler pluginu
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerId>groovy-eclipse-compiler</compilerId>
<verbose>true</verbose>
<extensions>true</extensions>
Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
marshaller.marshal(new JAXBElement<MyClass>(new QName("NameSpaceUri","ElementName"), MyClass.class, myClassInstance), System.out);
@bugs84
bugs84 / gist:4945280
Created February 13, 2013 15:15
InputStreamDataSourceWithHackForSchemaValidation
import javax.activation.DataSource;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* Vzniklo to, protoze servisa, ktera ma zapnute @SchemaValidation
* Udela to, ze pri validaci zavola getInputStream a cely ho precte
* Potom se pri vyplnovani responsu znova zavola getInputStream a chce ho napsat do response, jenomze