Skip to content

Instantly share code, notes, and snippets.

View ilopmar's full-sized avatar

Iván López ilopmar

  • VMware
  • Madrid, Spain (Remote)
  • X @ilopmar
View GitHub Profile
@ilopmar
ilopmar / LogTime.groovy
Last active December 3, 2022 19:41
Sample Groovy AST Transformation developed during the 4th Kaleidos Piweek for log the execution time of a method
package net.kaleidos.piweek
import org.codehaus.groovy.transform.GroovyASTTransformationClass
import java.lang.annotation.ElementType
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
import java.lang.annotation.Target
@Retention(RetentionPolicy.SOURCE)
@GrabResolver(name='grails-core', root='http://repo.grails.org/grails/core')
@Grab(group='org.grails', module='grails-datastore-gorm-mongo', version='1.0.0.BUILD-SNAPSHOT')
@Grab(group='org.slf4j', module='slf4j-simple', version='1.6.1')
import grails.persistence.*
import org.grails.datastore.gorm.mongo.config.*
MongoDatastoreConfigurer.configure("myDatabase", Book)
Book.withSession {
@ilopmar
ilopmar / gist:3e954dd030e88817786e
Created January 17, 2015 17:29
Error starting Grails 3.0 application
$ grails --version
| Grails Version: 3.0.0.BUILD-SNAPSHOT
| Groovy Version: 2.4.0-rc-2
| JVM Version: 1.8.0_25
$ gradle bootRun
:compileJava UP-TO-DATE
:compileGroovy
:processResources
:classes
| Plugin packaged grails-url-shortener-0.2.1.zip
| Plugin packaged grails-url-shortener-0.2.1.zip
| POM generated: /home/ivan/workspaces/misc/grails-url-shortener/target/pom.xml
WARN: No SCM provider installed.
Publishing to Grails Central
Publishing to http://grails.org/api/v1.0/publish/url-shortener/0.2.1
| Error Failed to publish plugin: <!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en-US"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en-US"> <![endif]-->
@ilopmar
ilopmar / SpeakerPageGenerator.groovy
Last active August 29, 2015 14:16
speakers_data.csv
package com.greachconf
import groovy.text.SimpleTemplateEngine
@Grab('com.xlson.groovycsv:groovycsv:1.0')
import com.xlson.groovycsv.CsvParser
@Grab('com.github.slugify:slugify:2.1.3')
import com.github.slugify.Slugify
package com.example
import ratpack.guice.Guice
import ratpack.server.RatpackServer
public class MyApp {
public static void main(String[] args) throws Exception {
RatpackServer.start { spec ->
spec.registry {
@ilopmar
ilopmar / jooq.gradle
Created December 17, 2015 14:24 — forked from schoenobates/jooq.gradle
JOOQ Generator Gradle
import org.jooq.util.jaxb.*
import org.jooq.util.*
ext.db = [
url: 'jdbc:postgresql://host/db',
user: 'user',
password: 'user',
schema: 'schema'
]

External configuration in Grails 3


Working on Grails 3 I realized that I no longer can specify external configuration using the standard grails.config.locations property in Config.groovy file.

Reason is obvious! There is no Config.groovy now in Grails 3. Instead we now use application.yml to configure the properties. However, you can't specify the external configuration using this file too!

What the hack?

Now Grails 3 uses Spring's property source concept. To enable external config file to work we need to do something extra now.

04fc849bffb84762d5f716ca2f662c36c051a6ec908c46cd3f3cc4cac23d50e19c56b76dc2011b61b28a535b44b7e0bdd896531fe624d399cc7fe94af68084187e
@ilopmar
ilopmar / reduce-pdf.size.sh
Last active July 1, 2018 11:48
Reduce pdf size
#!/bin/bash
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf