Skip to content

Instantly share code, notes, and snippets.

@chiquitinxx
chiquitinxx / gist:9632100
Created March 18, 2014 23:22
Groovy bean builder for Spring Boot
package hello
import conversion.GrooscriptConverter
import org.springframework.beans.factory.groovy.GroovyBeanDefinitionReader
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.boot.SpringApplication
import org.springframework.context.ApplicationContextInitializer
import org.springframework.context.ConfigurableApplicationContext
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration
@chiquitinxx
chiquitinxx / run.groovy
Last active August 29, 2015 14:01
Run express server
import org.grooscript.asts.GsNative
//ExpressServer class
class ExpressServer {
//Initial functions, so this groovy script will run
def expressApp = [get: { path, closure -> "Get in '${path}'."},
listen: { port -> println 'Listening in port ' + port}]
ExpressServer() {
@chiquitinxx
chiquitinxx / convert.groovy
Last active August 29, 2015 14:01
Convert groovy file to javascript
@GrabConfig(systemClassLoader=true)
@Grab('org.grooscript:grooscript:0.5.1')
import org.grooscript.GrooScript
GrooScript.setConversionProperty(GrooScript.INITIAL_TEXT_OPTION, "var gs = require('grooscript');")
GrooScript.convert('run.groovy', '.')
@chiquitinxx
chiquitinxx / gist:5192ff81d3b3351e3f1d
Created November 26, 2014 21:49
Using Firebase from your pages in a Groovy way with grooscript
def firebase = new GrooscriptFirebase()
firebase.message = [list: [1, 2, 3], number: 5, name: 'grooscript']
//Show on console:
// Message received: [list: [1, 2, 3] ,name: grooscript ,number: 5 ,]
class GrooscriptFirebase extends BaseFirebase {
GrooscriptFirebase() {
super('https://XXXX.firebaseio.com/')
}
@chiquitinxx
chiquitinxx / gist:ce31042741e8726ba6c1
Last active August 29, 2015 14:11
GsNative example
import org.grooscript.asts.GsNative
class A {
def b = 6
static c = 7
@GsNative
def a() {/*
//This js code is inserted in the javascript conversion
//You can use gSobject better than this
@chiquitinxx
chiquitinxx / gist:94bbc82cb6652a4b19a2
Created January 6, 2015 22:28
Show 10 latest gradle plugins published in repository
@GrabConfig(systemClassLoader=true)
@Grab('org.grooscript:grooscript:1.0.0-rc-1')
import org.grooscript.asts.PhantomJsTest
//Where you have phantom js, in my case 'which phantomjs' is '/usr/local/bin/phantomjs'
System.setProperty('PHANTOMJS_HOME', '/usr/local')
@PhantomJsTest(url = 'http://plugins.gradle.org')
void getLatestPlugins() {
@chiquitinxx
chiquitinxx / gist:6ef000456732aa9bd7fb
Last active August 29, 2015 14:13
Using some grooscript tools, groovy templates and traits
trait Colorable {
static COLOR_CLASSES = [
'navy','blue','aqua','teal','olive','green','lime','yellow', 'orange',
'red','fuchsia','purple','gray','maroon'
]
}
import org.grooscript.builder.HtmlBuilder
import org.grooscript.jquery.GQuery
import org.grooscript.jquery.GQueryImpl
Three.scene {
tetrahedron 200 moveTo -360, 300, 300
icosahedron 200 moveTo 360, 200, 300
sphere 100, 50, 50 moveTo -300, -200, 100
torus 200, 50, 50, 50 moveTo -300, -200, 100
ring 20, 200, 50 moveTo 450, -200, 100
setMaterial(grooscriptMaterial)
box 200, 200, 200
}.animate { items ->
items.findAll { it.name != 'Box' }.each {
@chiquitinxx
chiquitinxx / gist:a38ba0b54a405c11ece4
Created March 1, 2015 17:04
First approach angular controller
//Todo app controller written in groovy, from https://angularjs.org/
def todoAngular = { $scope ->
$scope.todos = [
[text:'learn angular', done: true],
[text:'build an angular app', done: false]
]
$scope.addTodo = {
$scope.todos << [text:$scope.todoText, done:false]
$scope.todoText = ''
@chiquitinxx
chiquitinxx / gist:e0c561547e0e1b690767
Created March 2, 2015 17:38
My trait approach to an angular.js controller
//Grooscript Angular.js TODO example from https://angularjs.org/
//You need next release of grooscript to run it (1.0.1)
class TodoController implements AngularController {
def todos = [
[text:'learn angular', done: true],
[text:'build an angular app', done: false]
]
def addTodo() {
scope.todos << [text: scope.todoText, done: false]
scope.todoText = ''