Skip to content

Instantly share code, notes, and snippets.

View christoph-frick's full-sized avatar

Christoph Frick christoph-frick

View GitHub Profile
class Widget {
void doStuff() { println 'doing stuff' }
String sayStuff(String name) { return "Hello $name" }
void fail() { throw new RuntimeException("Boom") }
}
class WidgetService {
// our service now has all the methods, Widget has
@Delegate Widget widget = new Widget()
// adding other stuff is fine too
@christoph-frick
christoph-frick / gist:118857c176c3f06efa16
Last active August 29, 2015 14:06
Disassembly of groovy's generated code for @singleton
/* groovy */
import groovy.transform.CompileStatic
@CompileStatic
@Singleton
class RegularSingleton {
void foo() { println 'foo' }
}
@christoph-frick
christoph-frick / MultiLineField.groovy
Created June 27, 2014 07:41
Vaadin Multiline Field (List<String> in TextArea)
import com.vaadin.ui.Component
import com.vaadin.ui.CustomField
import com.vaadin.ui.TextArea
class MultiLineField extends CustomField<List<String>> {
private TextArea textArea = new TextArea()
MultiLineField() {
super()
curl -s -XDELETE localhost:9200/so_delete_parent >/dev/null
curl -s -XPUT localhost:9200/so_delete_parent/ -d '{ "settings": { "index": { "number_of_shards" : 2 } } }' >/dev/null
curl -s -XPUT localhosT:9200/so_delete_parent/childs/_mapping -d '{ "_parent": { "type": "parents" } }' >/dev/null
curl -s -XPUT localhost:9200/so_delete_parent/childs/A\?parent=1 -d '{ "doc": "parent 1" }'
curl -s -XPUT localhost:9200/so_delete_parent/childs/A\?parent=2 -d '{ "doc": "parent 2" }'
curl -s localhost:9200/so_delete_parent/childs/A\?parent=1 | json_pp
curl -s localhost:9200/so_delete_parent/childs/A\?parent=2 | json_pp
curl -s localhost:9200/so_delete_parent/childs/A\?parent=666 | json_pp
curl -s localhost:9200/so_delete_parent/childs/A | json_pp # fails with ES 1.0
@christoph-frick
christoph-frick / _Events.groovy
Last active August 29, 2015 13:56
Build Vaadin Themes (scripts/_Events.groovy)
import com.vaadin.sass.internal.ScssStylesheet
eventCreateWarStart = { name, stagingDir ->
new File("${stagingDir}/VAADIN/themes/").eachDir {
def scssName = "${it}/styles.scss"
if (new File(scssName).exists()) {
ScssStylesheet scss = ScssStylesheet.get(scssName)
scss.compile()
def outFile = new File("$it/styles.css")
outFile.write(scss.toString())
@christoph-frick
christoph-frick / VaadinCompile.groovy
Created February 4, 2014 20:00
Compile Vaadin WidgetSet
includeTargets << grailsScript("_GrailsInit")
includeTargets << grailsScript("_GrailsClasspath")
includeTargets << grailsScript("_GrailsRun")
target(widgetset_init: "init") {
vaadinConfig = new ConfigSlurper(grails.util.Environment.current.name).parse(new File("${basedir}/grails-app/conf/VaadinConfig.groovy").text)
ant.property(name: "widgetset", value: vaadinConfig.vaadin.widgetset)
ant.property(name: "workers", value: "4")
ant.property(name: "widgetset-path", value: "")
ant.property(name: "client-side-destination", value: "web-app/VAADIN/widgetsets")