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
System.properties['javax.net.ssl.trustStore'] = '/some/trust.store' | |
System.properties['javax.net.ssl.trustStorePassword'] = 'pass' | |
System.properties.each { k, v -> | |
println "$k = $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
groovy -e "new File('data.in').eachLine { println it[0..12] }" > data.out |
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.nio.charset.Charset.availableCharsets().each { name, charset -> println 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
var WindowStyle_Hidden = 0 | |
var objShell = WScript.CreateObject("WScript.Shell") | |
var result = objShell.Run("cmd.exe /c {BATCHFILENAME}.bat", WindowStyle_Hidden) |
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 java.util.zip.* | |
/** | |
* Makes it easier to unzip files by adding extraction methods to the entries themselves and providing Closure-based methods for finding specific entries. | |
* | |
* For example, to extract all XML files to a certain directory: | |
* <code> | |
* new Unzipper(zip).findAllEntries { it.name.endsWith(".xml") }.each { it.extractTo(someDir) } | |
* </code> | |
*/ |
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
// a regex literal is just a String literal with '/' deliminters and backslash-friendliness | |
def rx1 = /^foo$/ | |
assert rx1.class == String.class | |
assert 'foo' ==~ rx1 | |
assert 'FOO' !=~ rx1 | |
assert 'Foo' !=~ rx1 | |
// so you can use String methods and operators on them | |
def rx2 = /(?i)/ + rx1 | |
assert 'foo' ==~ rx2 |
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 java.io.File; | |
import java.io.FileInputStream; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.OutputStream; | |
import java.util.Arrays; | |
import java.util.List; | |
import java.util.Random; | |
import java.util.concurrent.Callable; |
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
/* | |
* Script for calculating how much space a file will consume when Base64 encoded. | |
*/ | |
def showUsage = { -> | |
println ''' | |
Usages: calcBase64.groovy [options] file | |
calcBase64.groovy [options] number | |
Options: provide as single string, e.g. 'gp' or 'pq' (with optional prefix '-') |
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
// Clean up double slashes | |
// uses negative lookbehind pattern (?<!text) | |
def input = 'http://host//path/with//some/segments//double//slashed' | |
assert input.replaceAll("(?<!\\:)//", "/") == 'http://host/path/with/some/segments/double/slashed' |
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 java.util.concurrent.* | |
class Factory { | |
def rand = new Random() | |
def instance | |
def getInstance() { | |
if (instance == null) { | |
synchronized(this) { | |
if (instance == null) { | |
instance = createInstance() |
OlderNewer