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
| 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 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
| @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 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
| diy <- function(year) { | |
| require(zoo) | |
| as.numeric(as.Date(as.yearmon(year) + 1) - as.Date(as.yearmon(year))) | |
| } |
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
| { | |
| "nonce": "0x0000000000000042", | |
| "difficulty": "0x40000", | |
| "alloc": { | |
| "bbbbbaaaaa82db86a35502193b4c6ee9a76ebe8f": { | |
| "balance": "10015200000000000000000" | |
| } | |
| }, |
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
| payload[0] * payload[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
| invoke('https://gist.github.com/EwanDawson/67902abfb90239b502a255fcff0f69ca/raw/21037fea2ac819d92663dd2b8f6b80ac21512f32/multiply.groovy', [payload[0], 2]) |
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
| payload.collate(2).collectEntries { [it[0], it[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
| @Grapes(@Grab(group='org.atteo', module='evo-inflector', version='1.2.2')) | |
| import org.atteo.evo.inflector.English | |
| English.plural(payload[0], payload[1] ?: 2) |
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
| @Grapes(@Grab("com.jcabi:jcabi-http:1.17.1")) | |
| import com.jcabi.http.request.JdkRequest | |
| import static java.net.URLEncoder.encode | |
| def (title, message) = payload.collect { encode(it).replaceAll("\\+", "%20") } | |
| new JdkRequest("https://api.simplepush.io/send/jzAa6m/${title.toUpperCase()}/$message").fetch() |
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
| import java.time.LocalDateTime | |
| import static java.time.temporal.ChronoField.* | |
| def now = LocalDateTime.now() | |
| def everySecond = { it() } | |
| def everyMinute = { if (now.get(SECOND_OF_MINUTE) == 0) it() } | |
| def everyHour = { if (now.get(SECOND_OF_MINUTE) == 0 && now.get(MINUTE_OF_HOUR) == 0) it() } | |
| def alert = { title, message -> invoke('https://gist.githubusercontent.com/EwanDawson/a65e720ed8ce0c9bc26d816de71ee776/raw/af0fa90ea080c758fec4077cd927dd1bd3d3da92/alert-me.groovy', [title, message]) } | |
| everyMinute { alert("The time is now", now.toString()) } |