Skip to content

Instantly share code, notes, and snippets.

@jagedn
jagedn / application.properties
Created February 12, 2016 10:32
shutdown gracefully a grails 3.0 application
endpoints.shutdown.enabled=true
// call a shutdown with post
// curl -X POST http://localhost:8080/shutdown
@jagedn
jagedn / gist:304f7dca3eb11f8c59b9976576a0773e
Created May 19, 2016 07:22
remove whitespace in g:each
default index.gsp:
<ul>
<g:each var="c" in="${grailsApplication.controllerClasses.sort { it.fullName } }">
<li class="controller"><g:link controller="${c.logicalPropertyName}">${c.fullName}</g:link></li>
</g:each>
</ul>
result:
<ul>
@jagedn
jagedn / DistributeForecast.groovy
Created July 15, 2016 11:40
Use Gpars + Sshoogr to distribute a jar and execute it
@Grab('com.aestasit.infrastructure.sshoogr:sshoogr:0.9.25')
@Grab('org.codehaus.gpars:gpars:1.2.1')
@GrabConfig(systemClassLoader = true)
import static com.aestasit.infrastructure.ssh.DefaultSsh.*
import groovyx.gpars.GParsPool
options.trustUnknownHosts = true
stores = [ '10.0.1.1', '10.0.2.1', '10.0.3.1' ]
GParsPool.withPool(10) {
@jagedn
jagedn / ApplicationController.groovy
Last active September 27, 2016 16:00
Using Spring Cloud Config Server with Grails 3.1
class ApplicationController implements PluginManagerAware {
GrailsApplication grailsApplication
GrailsPluginManager pluginManager
@Autowired
BeansConfiguration beansConfiguration
def index() {
[grailsApplication: grailsApplication, pluginManager: pluginManager,hello:beansConfiguration.hello]
@jagedn
jagedn / CloudConfiguration.groovy
Last active September 28, 2016 07:35
Listener from cloud configuration changes and do something
@Component
@ConfigurationProperties(prefix="authorization")
class CloudConfiguration {
String secretKey
boolean dirty = true
@Autowired
SignedJwtTokenGenerator tokenGenerator
@jagedn
jagedn / build.gradle
Created September 30, 2016 17:18
Generate HTML + Pdf with Asciidoctor Gradle plugin in the same build
buildscript {
dependencies {
classpath 'org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.11'
}
}
plugins {
id 'org.asciidoctor.convert' version '1.5.3'
}
@jagedn
jagedn / .git hooks pre-push
Created November 20, 2016 16:42
con esta tontería de hook evito subir nada a master que no se haya probado
#!/bin/sh
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
if [ $current_branch != "master" ]; then
exit 0
fi
echo "Antes de subir nada a master, vamos a chequearlo"
$(pwd)/gradlew check
@jagedn
jagedn / example.groovy
Created November 29, 2016 08:34
consumir un soap con Grails Framework
def client = new SOAPClient('http://www.holidaywebservice.com/Holidays/US/Dates/USHolidayDates.asmx')
def response = client.send(SOAPAction:'http://www.27seconds.com/Holidays/US/Dates/GetMothersDay') {
body {
GetMothersDay('xmlns':'http://www.27seconds.com/Holidays/US/Dates/') {
year(2011)
}
}
}
response.GetMothersDayResponse.GetMothersDayResult.text()
def p = ["docker","images"].execute() | ["sort","-buk1,3"].execute()
p.waitFor()
def text =p.text
def prev
text.split('\n').each{ line ->
def fields = line.split(' ').findAll{ it.size() }
if(!prev || prev[0] != fields[0])
println fields[0]
if(prev && prev[2] != fields[2])
println "\t${fields[1]}\t${fields[2]}"
@jagedn
jagedn / hello.groovy
Created April 2, 2017 10:09
groovyfx as script
import groovy.grape.Grape
new javafx.embed.swing.JFXPanel();
Grape.grab(group:'org.groovyfx',module:'groovyfx',version:'8.0.0',transitive:false)
Class.forName('groovyx.javafx.GroovyFX').start {
stage(title: 'GroovyFX Hello World', visible: true) {
scene(fill: BLACK, width: 500, height: 250) {
hbox() {
text(text: 'Groovy', font: '80pt sanserif') {
fill linearGradient(endX: 0, stops: [PALEGREEN, SEAGREEN])