This file contains hidden or 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
| @Grab(group='org.springframework.security', module='spring-security-core', version='3.2.5.RELEASE') | |
| @Grab(group='org.springframework.security', module='spring-security-ldap', version='3.2.5.RELEASE') | |
| import groovy.transform.* | |
| import javax.naming.NamingException | |
| import javax.naming.directory.Attribute | |
| import javax.naming.directory.Attributes | |
| import org.springframework.ldap.core.* | |
| import org.springframework.security.ldap.* |
This file contains hidden or 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
| <html> | |
| <body> | |
| <a href="ms-word:ofe|u|http://localhost:8080/doc.docx">Click me</a> | |
| </body> | |
| </html> |
This file contains hidden or 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
| // http://www.infoq.com/presentations/groovy-test-java-spock @ 17:00 | |
| import spock.lang.Specification | |
| class Publisher { | |
| def subscribers = [] | |
| def send(event) { | |
| subscribers.each { | |
| try { | |
| it.receive(event) |
This file contains hidden or 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
| @Grab(group='org.apache.tika', module='tika-core', version='1.7') | |
| @Grab(group='org.apache.tika', module='tika-parsers', version='1.7') | |
| import org.apache.tika.metadata.* | |
| import org.apache.tika.parser.* | |
| import org.apache.tika.parsers.* | |
| import org.apache.tika.sax.* | |
| import javax.xml.transform.* | |
| import javax.xml.transform.sax.* | |
| import javax.xml.transform.stream.* | |
| import org.xml.sax.* |
This file contains hidden or 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 _ = [do: { body -> | |
| [while: { condition -> | |
| body() | |
| if (condition()) call(condition) | |
| }] | |
| }] | |
| int i = 0; _. |
This file contains hidden or 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
| /* | |
| * Follows http://www.righto.com/2009/03/y-combinator-in-arc-and-java.html blog | |
| */ | |
| // standard factorial closure | |
| def fact = { n -> n == 0 ? 1 : n * call(n - 1) } | |
| // factorial closure generator, which requires the factorial closure as an arg (mind blown already) | |
| def factGen = { factFn -> | |
| { n -> n == 0 ? 1 : n * factFn(n - 1) } |
This file contains hidden or 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
| package prpsutil; | |
| import java.io.*; | |
| import java.util.*; | |
| import org.apache.pdfbox.pdmodel.*; | |
| import org.apache.pdfbox.pdmodel.font.*; | |
| public class PDFScanner { | |
| private static final byte[] expectedMagicNumber = "%PDF".getBytes(); |
This file contains hidden or 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
| @Grab(group='org.ccil.cowan.tagsoup', module='tagsoup', version='1.2') | |
| import java.text.* | |
| class SOTagCounter { | |
| def parser = new XmlSlurper(new org.ccil.cowan.tagsoup.Parser()) | |
| int count(String tag) { | |
| new URL("http://stackoverflow.com/questions/tagged/${new URI(tag).path}").withReader { page -> | |
| def html = parser.parse(page) | |
| def c = html.body.div.find { it.@class == 'container' }.div.find { it.@id == 'content' }.div.find { it.@id == 'sidebar' }.div.find { it.@class == 'module' }.div[0].text() |
This file contains hidden or 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
| @Unroll | |
| def "the string '#string' is #description"() { | |
| expect: | |
| string.isInteger() == expected | |
| where: | |
| string | expected | |
| "ABC" | false | |
| "123" | true | |
| "1.2" | false |