Skip to content

Instantly share code, notes, and snippets.

View marcelmaatkamp's full-sized avatar
🚢
Available

Marcel Maatkamp marcelmaatkamp

🚢
Available
View GitHub Profile
#!/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
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/'
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()
)
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
#!/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)
*/
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)
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)
#!/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
#!/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 {
#!/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 ->