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(group='com.jcraft', module='jsch', version='0.1.46') | |
import com.jcraft.jsch.* | |
java.util.Properties config = new java.util.Properties() | |
config.StrictHostKeyChecking = "no" | |
JSch ssh = new JSch() | |
Session session = ssh.getSession(user, host, port) | |
session.config = config |
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
// match html class | |
class=\"(footer|.+ footer)( |\") |
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.atomic.AtomicInteger | |
/** | |
* A cyclic counter that is backed by an {@code AtomicInteger}. | |
* | |
* This counter will return integers starting at {@code start} up to {@code max}, then starting over (cycling). | |
*/ | |
class AtomicCyclicCounter { | |
int max | |
int start = 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
// grails -debug -DFOO=bar -Djava.awt.headless=true -Dapp.context=/ run-app | |
run { | |
if (project.hasProperty('debug') && project.property('debug') == 'true') { | |
def debugPort = project.hasProperty('debug.port') ? project.property('debug.port') : 5005 | |
def suspend = project.hasProperty('debug.suspend') ? project.property('debug.suspend') : 'y' | |
jvmArgs '-Xdebug', "-Xrunjdwp:transport=dt_socket,server=y,suspend=${suspend},address=${debugPort}" | |
} | |
} |
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.codehaus.groovy.runtime.StringGroovyMethods | |
use(EnumUtils1) { | |
println Foo.ONE.toString() | |
println "THREE" as Foo | |
println "123" as int | |
println "Three" as Foo | |
println "T" as 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
package foo | |
@Grab('org.spockframework:spock-core:1.0-groovy-2.3') | |
import org.junit.runner.* | |
import spock.lang.Specification | |
import spock.util.EmbeddedSpecRunner | |
/* |
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.apache.kafka:kafka_2.10:0.8.1") | |
@GrabExclude("com.sun.jmx:jmxri") | |
@GrabExclude("javax.jms:jms") | |
@GrabExclude("com.sun.jdmk:jmxtools") | |
@GrabExclude("junit:junit") | |
import kafka.consumer.ConsumerConfig; | |
import kafka.consumer.ConsumerIterator; | |
import kafka.consumer.KafkaStream; | |
import kafka.javaapi.consumer.ConsumerConnector; |
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
task runVertx(type: Exec, dependsOn: ['compileGroovy']) { | |
if (System.getProperty('debug')) { | |
environment 'VERTX_OPTS', '-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005' | |
} | |
ext.vertxClasspath = (sourceSets.main.runtimeClasspath.filter { !it.path.contains('groovy') }).asPath | |
def configFile = 'etc/conf.json' | |
commandLine 'vertx', 'run', 'src/MyVertxModule.groovy', '-conf', configFile, '-cp', "src/:$vertxClasspath" | |
} |
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
function rm () { | |
local path | |
for path in "$@"; do | |
# ignore any arguments | |
if [[ "$path" = -* ]]; then : | |
else | |
local dst=${path##*/} | |
# append the time if necessary | |
while [ -e ~/.Trash/"$dst" ]; do | |
dst="$dst "$(date +%H-%M-%S) |
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.springframework.core.io.ByteArrayResource | |
def s = new File('/Users/ben/Documents/foo/index.gsp').withReader { reader -> | |
return reader.text | |
} | |
def resource = new ByteArrayResource(s.bytes) | |
def renderer = ctx.groovyPagesTemplateEngine | |
def template = renderer.createTemplate(resource, false) |