Skip to content

Instantly share code, notes, and snippets.

View kellyrob99's full-sized avatar

Kelly Robinson kellyrob99

View GitHub Profile
import groovy.xml.StreamingMarkupBuilder
def inputs = ['FirstName', 'LastName', 'Street', 'City', 'Country']
def controller = 'formController'
def bean = 'formBean'
def builder = new StreamingMarkupBuilder()
builder.encoding = "UTF-8"
def doc = builder.bind {
mkp.xmlDeclaration()
#!/usr/bin/env groovy
import ca.odell.glazedlists.*
import ca.odell.glazedlists.gui.*
import ca.odell.glazedlists.swing.*
import groovy.swing.*
import javax.swing.*
@Grab (group = 'net.java.dev.glazedlists', module = 'glazedlists_java15', version = '1.8.0')
public class SVNGlazedListExample
{
import org.jdesktop.swingx.JXTable
import javax.swing.*
@Grab(group='org.swinglabs', module='swingx', version='0.9.3')
@Grab(group='org.ccil.cowan.tagsoup', module='tagsoup', version='0.9.7')
def getHtml(url) {
def parser = new XmlParser(new org.ccil.cowan.tagsoup.Parser())
parser.parse(url)
}
def data = [ ]
@kellyrob99
kellyrob99 / Twitter Timeline Script Example
Created March 28, 2010 18:28
Groovy script for grabbing last 20 Tweets in your home timeline.
@Grab(group='net.homeip.yusuke', module='twitter4j', version='2.0.10')
import twitter4j.Twitter
def getHomeTimeline() {
Console cons = System.console()
def getUsername = { cons.readLine( 'Enter a username: ' ).trim() }
def getPassword = { cons.readPassword( "Enter a password: ").toString()}
def twitter = new Twitter(getUsername(),getPassword())
def response = twitter.getHomeTimeline()
response.each {status ->println "${status.text} FROM ${status.user.name} and SOURCE ${status.source}"; println ""}
println new XmlSlurper().parse('http://feeds.dzone.com/dzone/frontpage'.toURL().content)
.depthFirst()
.findAll {(it.name()=='title'&&it.parent().name()=='item')}[0..5]
@kellyrob99
kellyrob99 / Minimal Gradle+Geb build script
Created March 4, 2011 04:51
Gives a Gradle build with IDE and maven support, ready to go for Geb and Spock and the Firefox web driver.
apply plugin: 'groovy'
apply plugin: 'idea'
apply plugin: 'maven'
apply plugin: 'eclipse'
apply plugin: 'project-report'
version = '1.0-SNAPSHOT'
group = ''
versions = [
@kellyrob99
kellyrob99 / GMaven script properties
Created March 6, 2011 19:31
A pom snippet to show what's available to Groovy scripts run using the GMaven plugin as part of your maven build
<build>
<plugins>
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>execute</goal>
def company = new Expando()
[500000, 399999, 1000000].each{ hops ->
company.hops = hops
switch(company.hops)
{
case 0..99999 :
company.rating = 1
break
case 100000..399999 :
@kellyrob99
kellyrob99 / parallelSearchJdk7ApiDocsForSince17.groovy
Created April 2, 2011 19:59
Add some library support to speed up looking for Java 1.7 changes in javadoc and simultaneously shorten the script a bit. Inspired by http://marxsoftware.blogspot.com/2011/03/jdk-7-new-interfaces-classes-enums-and.html
#!/usr/bin/env groovy
// searchJdk7ApiDocsForSince17.groovy
@Grab(group='org.ccil.cowan.tagsoup', module='tagsoup', version='0.9.7')
@Grab(group='org.codehaus.gpars', module='gpars', version='0.11')
import groovyx.gpars.GParsPool
import java.util.concurrent.atomic.AtomicInteger
def xml = new XmlParser(new org.ccil.cowan.tagsoup.Parser()).parse("http://download.oracle.com/javase/7/docs/api/allclasses-frame.html")
def urls = xml.'**'.a.@href
@kellyrob99
kellyrob99 / gist:1026097
Created June 14, 2011 22:31
Gradle rule to execute arbitrary groups of tests in isolation
/**
* Add a rule that supports executing tests based on a series of comma delimited patterns(ant glob patterns).
*/
tasks.addRule("Pattern: testMulti<Name>,<Name2> will test **/<Name>.class,**/<Name2>.class") {String taskName ->
if (taskName.startsWith("testMulti"))
{
tasks.add(taskName).dependsOn(test)
test.includes = taskName.substring(9).split(',').collect {"**/${it}.class"}
}
}