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
def referenceClosure = { | |
html { | |
body { | |
h1 "hello" | |
} | |
} | |
} | |
def markupBuilder(closure) { |
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
@Grab('org.codehaus.groovy.modules:groovyws:0.5.2') | |
def 'groovyws'(){} | |
class SyncService { | |
def getFoo() { | |
"bar. i mean, foo" | |
} | |
} | |
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 Magic { | |
def methodMissing(String methodName, Object arguments) { | |
method(methodName, *arguments) | |
} | |
private method(String methodName, Object... arguments) { | |
if (!(arguments[-1] instanceof Closure)) | |
throw new MissingMethodException(methodName, this.class, arguments) |
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
def cli = new CliBuilder().with { | |
usage = 'program [options] <arguments>' | |
header = 'Options:' | |
footer = '-' * width | |
s 'simplest boolean option' | |
b longOpt: 'both', 'boolean option with both longop and shortop' | |
_ longOpt: 'no-shortop-1', 'boolean option without short version 1' |
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
javax.net.ssl.SSLContext.getInstance('SSL').with { | |
init null, [[checkServerTrusted:{chain,authType->}]] as javax.net.ssl.X509TrustManager[], null | |
javax.net.ssl.HttpsURLConnection.defaultSSLSocketFactory = socketFactory | |
} |
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
java.awt.Toolkit.defaultToolkit.systemClipboard.getData java.awt.datatransfer.DataFlavor.stringFlavor |
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 static org.hamcrest.CoreMatchers.is | |
import static org.junit.Assert.assertArrayEquals | |
import static org.junit.Assert.assertEquals | |
import static org.junit.Assert.assertSame | |
import static org.junit.Assert.assertNot | |
import static org.junit.Assert.assertNull | |
import static org.junit.Assert.assertNotNull | |
import static org.junit.Assume.assumeNoException |
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='itextpdf', root='http://maven.itextpdf.com/') | |
@Grab('com.itextpdf:itextpdf:5.0.5') | |
import static com.itextpdf.text.PageSize.A4 | |
import com.itextpdf.text.Document | |
import com.itextpdf.text.pdf.PdfReader | |
import com.itextpdf.text.pdf.PdfWriter | |
def cli = new CliBuilder().with { | |
usage = 'preparePdf [options] <source file path>' |
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
@Grab('org.mortbay.jetty:jetty-embedded:6.1.26') | |
import static org.mortbay.jetty.Handler.DEFAULT | |
import org.mortbay.jetty.Server | |
import org.mortbay.jetty.servlet.Context | |
import org.mortbay.jetty.servlet.DefaultServlet | |
import org.mortbay.servlet.MultiPartFilter | |
import groovy.servlet.GroovyServlet | |
import groovy.servlet.TemplateServlet |
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
// PostgreSQL | |
@GrabConfig(systemClassLoader=true) | |
@Grab('postgresql:postgresql:9.0-801.jdbc4') | |
def sql = groovy.sql.Sql.newInstance( | |
"jdbc:postgresql://host.example.org/database", | |
"username", "password", "org.postgresql.Driver") | |
// MySQL | |
@GrabConfig(systemClassLoader=true) |
OlderNewer