Skip to content

Instantly share code, notes, and snippets.

View ysb33r's full-sized avatar

Schalk W. Cronjé ysb33r

  • Andorra
View GitHub Profile
@ysb33r
ysb33r / bintray-examples.groovy
Created March 8, 2014 10:24
Maipulating Bintray API with Groovy
@Grab( 'org.codehaus.groovy.modules.http-builder:http-builder:0.5.2' )
import groovyx.net.http.RESTClient
import groovyx.net.http.HttpResponseException
def repoOwner = 'ysb33r'
def repoName = 'grysb33r'
def packageName = 'bintray-gradle-plugin'
def bintrayUsername = '__YOUR_USERNAME__'
def bintrayApiKey = '__YOUR_APIKEY__'
def packageVersion = '0.1'
@ysb33r
ysb33r / vfs-plugins.groovy
Created April 1, 2014 15:50
How the plugin extension DSL will look like for Groovy VFS. No need to struggle with Apachae VFS vfs-provider.xml files
import org.ysb33r.groovy.dsl.vfs.VFS
def vfs = new VFS()
// ---------------------------------
// Adding new providers with schemes
// ---------------------------------
vfs {
extend {
// Adding provider with no external dependencies
@ysb33r
ysb33r / gradle-vfs-plugin2.groovy
Created April 9, 2014 16:03
VFS Gradle Plugin: SBE Copy Task
import org.ysb33r.gradle.vfs.*
// Assuming we have properties in gradle.properties
// userNameFrom
// passwordFrom
// userNameTo
// passwordTo
task simpleCopyTask ( type : VfsCopy ) {
from 'ftp://${userNameFrom}:${passwordFrom}@from.here/a.txt'
@ysb33r
ysb33r / jruby-support.gradle
Created June 20, 2014 10:58
Gradle concept - Supporting JRuby + Gems
// This is just a concept - this code does not exist !!
// I have placed it here in order to facilitate discussion
// let's assume that we have specified the lcoation of the jruby
// plugin in buildscript {} block
apply plugin : 'jruby'
repositories {
jcenter()
}
@ysb33r
ysb33r / gist:0c534d165863628a07cc
Last active August 29, 2015 14:04
HOWTO add deck.js to an Asciidoctor project without resorting to git submodules
// You will need the VFS plugin
buildscript {
repositories {
jcenter()
}
dependencies {
// Set your
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:0.7.0'
classpath 'org.ysb33r.gradle:vfs-gradle-plugin:0.5'
@ysb33r
ysb33r / gist:3fd93c4253e8775d5571
Last active August 29, 2015 14:05
Is it possible to convert asciidoctorj from maven to gradle?
// This is a first stab at trying to convert the asciidoctorj pom.xml to build.gradle
// Note the WORKAROUND. These are to work around problems with erubis. Gradle is much stricter
// about broken POMs that Maven.
//
// This had been done using some code which is is based on the current version of jruby-gradle-plugin,
// but with updates to fix shortcomings in the release 2.2.0
//
// This requires Gradle 2.0 or better.
//
buildscript {
@ysb33r
ysb33r / asciidoctor-pdf-with-gradle.gradle
Created August 30, 2014 12:52
A brute-force way to run asciidoctor-pdf under Gradle
buildscript {
repositories {
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.github.jruby-gradle:jruby-gradle-plugin:0.1.2-SNAPSHOT'
classpath 'org.ysb33r.gradle:vfs-gradle-plugin:0.5'
@ysb33r
ysb33r / build.gradle
Created December 9, 2014 17:00
Asciidoctor-packt with Gradle
// A minimum Gradle file to get you started with asciidoctor-packt
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.ysb33r.gradle:vfs-gradle-plugin:1.0-beta1'
classpath 'commons-httpclient:commons-httpclient:3.1'
@ysb33r
ysb33r / xinlude-xmlsluper.groovy
Created October 13, 2015 14:06
Processing XInclude with XmlSlurper
// Not quite sure if this will work as expected, but probably
// worth a trying if you want xi:include documents to be inlucdd.
def spf = javax.xml.parsers.SAXParserFactory.newInstance()
spf.namespaceAware = true
spf.setXIncludeAware ( true )
def parser = new XmlSlurper(spf.newSAXParser())
@ysb33r
ysb33r / SumSquaresNumbersDiv7SmallerThan100.groovy
Created April 15, 2013 13:35
Russel Winder did a lightning talk at ACCU 2013 titled "Who needs C++ when you have D and Go": http://www.slideshare.net/Russel_Winder/who-needscwhenyouhaved-andgo I decided to address the same problem using a one-liner in Groovy
println ((0..<100).step(7).collect{it*it}.sum())