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
payload.collate(2).collectEntries { [it[0], it[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
invoke('https://gist.github.com/EwanDawson/67902abfb90239b502a255fcff0f69ca/raw/21037fea2ac819d92663dd2b8f6b80ac21512f32/multiply.groovy', [payload[0], 2]) |
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
payload[0] * payload[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
{ | |
"nonce": "0x0000000000000042", | |
"difficulty": "0x40000", | |
"alloc": { | |
"bbbbbaaaaa82db86a35502193b4c6ee9a76ebe8f": { | |
"balance": "10015200000000000000000" | |
} | |
}, |
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
diy <- function(year) { | |
require(zoo) | |
as.numeric(as.Date(as.yearmon(year) + 1) - as.Date(as.yearmon(year))) | |
} |
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='grails-core', root='http://repo.grails.org/grails/core') | |
@Grab(group='org.grails', module='grails-datastore-gorm-mongo', version='1.0.0.BUILD-SNAPSHOT') | |
@Grab(group='org.slf4j', module='slf4j-simple', version='1.6.1') | |
import grails.persistence.* | |
import org.grails.datastore.gorm.mongo.config.* | |
MongoDatastoreConfigurer.configure("myDatabase", Book) | |
Book.withSession { |
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 org.joda.time.DateTime | |
def oldAsType = String.metaClass.getMetaMethod("asType", [Class] as Class[]) | |
String.metaClass.asType = { Class type -> | |
type.isAssignableFrom(DateTime) ? | |
new DateTime(delegate) : | |
oldAsType.invoke(delegate, [type] as Class[]) | |
} | |
assert "2012-01-01T10:10:10" as DateTime == new DateTime("2012-01-01T10:10:10") | |
assert "1234" as Integer == 1234 |
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 |
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
# 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 "[\/\@]$") |