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
/** | |
* Groovy ASCII Art. Converts an image into ASCII. | |
* This doesn't work under the web console due to missing AWT classes. | |
* | |
* Author : Cedric Champeau (http://twitter.com/CedricChampeau) | |
* Updated : Steven Olsen (http://crazy4groovy.blogspot.com) | |
*/ | |
import java.awt.color.ColorSpace as CS | |
import java.awt.geom.AffineTransform | |
import javax.imageio.ImageIO |
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.codehaus.groovyfx:groovyfx:0.1') | |
import groovyx.javafx.GroovyFX | |
import groovyx.javafx.SceneGraphBuilder | |
GroovyFX.start { | |
def sg = new SceneGraphBuilder() | |
sg.stage(title: "GroovyFX Hello World", visible: true) { | |
scene(fill: black, width: 530, height: 300) { |
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
apply plugin:'groovy' | |
javafxHome = System.env['JAVAFX_HOME'] | |
repositories { mavenCentral() } | |
dependencies { | |
groovy 'org.codehaus.groovy:groovy-all:1.8.2' | |
compile 'org.codehaus.groovyfx:groovyfx:0.1' | |
compile files("${javafxHome}/rt/lib/jfxrt.jar") |
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.codehaus.groovyfx:groovyfx:0.1') | |
import groovyx.javafx.GroovyFX | |
import groovyx.javafx.SceneGraphBuilder | |
//source: http://pleasingsoftware.blogspot.ca/2012/03/groovyfx-first-official-release.html | |
//run: groovy -classpath $JAVAFX_HOME/rt/lib/jfxrt.jar helloGroovyFX.groovy | |
GroovyFX.start { | |
def sg = new SceneGraphBuilder() |
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
/** | |
* Copyright (C) 2011 Yusuke Yamamoto | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* | |
**/ | |
@Grab(group='quartz', module='quartz', version='1.5.2') | |
@Grab(group='org.twitter4j', module='twitter4j-core', version='2.2.5') |
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
// No commas | |
def a = 'tim' | |
def nocom = match( a ) { | |
when 'dave' 'Hi Dave' | |
when 'tim' 'Hi Tim' | |
otherwise 'none of the above' | |
} | |
assert nocom == 'Hi Tim' | |
// Commas |
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
apply plugin:'groovy' | |
apply plugin:'idea' | |
repositories { mavenCentral() } | |
dependencies { | |
groovy 'org.codehaus.groovy:groovy-all:1.8.4' | |
} | |
task makeDirs(description:'make all dirs for project setup') << { |
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
debounce = function debounce(func, wait, immediate) { | |
var timeout; | |
return function() { | |
var context = this, args = arguments; | |
var later = function() { | |
timeout = null; | |
if (!immediate) func.apply(context, args); | |
}; | |
var callNow = immediate && !timeout; | |
clearTimeout(timeout); |
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
Closure bind | |
List.metaClass.rightShiftUnsigned = { return bind(delegate, it) } | |
List.metaClass.call = { return [delegate, ''] } | |
Closure squrt = { Double x -> | |
if (x < 0.0d) return [] | |
if (x == 0.0d) return [0.0] | |
return [Math.pow(x, 0.5), -Math.pow(x, 0.5)] | |
} |
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 groovy.json.* | |
import groovy.transform.Immutable | |
enum Fruit { | |
Orange, | |
Apple | |
} | |
enum Car { | |
Ford('slow'), |
OlderNewer