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
#!/usr/bin/env groovy | |
import java.util.regex.Pattern | |
# Older versions of sabnzb created a folder structure like this | |
# /complete/4323322/<item>.mp3 | |
# /complete/4564334/<item>.mkv | |
# | |
# This script will traverse these directories, move the contents | |
# into the specified folder and remove empty directories: | |
# /complete/music/<item>.mp3 |
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
def login() { | |
def http = new HTTPBuilder( 'https://www.google.com' ) | |
http.request( POST, TEXT ) { req -> | |
uri.path = '/accounts/ClientLogin' | |
send URLENC, [ | |
service: 'reader', | |
Email: username, | |
Passwd: password, | |
source: 'Testing couchdb', | |
continue:'http://www.google.com/' |
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
def showMeTheJavascriptProperties() { | |
def http = new HTTPBuilder( 'https://www.google.com' ) | |
http.request( GET, HTML ) { req -> | |
uri.path = "/" | |
response.success = { resp, page -> | |
def properties = new Properties() | |
properties.load( | |
new ByteArrayInputStream( | |
page.HEAD.SCRIPT.text().replace(',','').replace('"','').getBytes() | |
) |
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
Edit your $GROOVY_HOME/conf/groovy-start.conf and add the following line: | |
load !{user.home}/.groovy/grapes/**.jar | |
After that your @Grab will work as advertised: | |
#!/usr/bin/env groovy | |
@Grab(group='mysql', module='mysql-connector-java', version='5.1.12') | |
import groovy.sql.Sql |
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
#!/usr/bin/env groovy | |
import groovy.sql.Sql | |
import com.mysql.jdbc.* | |
/** | |
* A small example script on how to connect to a mysql database in a groovy script. | |
* | |
* @author: Marcel Maatkamp (m.maatkamp avec gmail dot com) | |
*/ |
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.security.MessageDigest | |
import java.io.* | |
/** | |
* Determine the MD5 or SHA1Sum of a file: | |
* | |
* println Checksum.getMD5Sum(new File("file.bin")) | |
* println Checksum.getSHA1Sum(new File("file.bin")) | |
* | |
* @author: Marcel Maatkamp (m.maatkamp avec gmail dot com) |
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.nio.* | |
/** | |
* Fast copy with java.nio.channels | |
* | |
* Usage: | |
* | |
* FileUtils.fastCopy(new File("from.bin"), new File("to.bin")) | |
* | |
* @author Marcel Maatkamp (m.maatkamp avec gmail dot com) |
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
#!/usr/bin/env groovy | |
import org.apache.camel.* | |
@Grapes([ | |
@Grab('org.springframework:spring:2.5.6'), | |
@Grab('org.apache.camel:camel-core:2.2.0'), | |
@GrabConfig(systemClassLoader = true) | |
]) | |
// define route |
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
#!/usr/bin/env groovy | |
import org.apache.camel.* | |
@Grapes([ | |
@Grab('org.springframework:spring:2.5.6'), | |
@Grab('org.apache.camel:camel-core:2.2.0'), | |
@GrabConfig(systemClassLoader = true) | |
]) | |
class QuoteServiceBean { |
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
#!/usr/bin/env groovy | |
import groovyx.net.http.* | |
import static groovyx.net.http.Method.GET | |
import static groovyx.net.http.ContentType.HTML | |
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.5.0-SNAPSHOT' ) | |
def http = new HTTPBuilder( 'https://www.google.com' ) | |
http.request( GET, HTML ) { req -> | |
uri.path = "/" | |
response.success = { resp, page -> |
OlderNewer