<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"><channel><title>El blog de Deigote</title><link>https://blog.deigote.com/</link><description>Entradas y conversaciones del blog de Deigote</description><item><title>Luz: precios del PVPC de un vistazo</title><link>https://blog.deigote.com/2026/11/30/luz-precios-pvpc-de-un-vistazo/</link><guid>https://blog.deigote.com/2026/11/30/luz-precios-pvpc-de-un-vistazo/</guid><pubDate>Mon, 30 Nov 2026 12:00:00 +0000</pubDate><description>Uso la tarifa PVPC y cada vez que quería mirar el precio de la luz acababa en una web o app llena de publicidad, haciendo scroll para ver la información del día. Como no me convencía ninguna de las opciones que había probado, me hice Luz: una página sencilla con los precios oficiales del PVPC por horas. Tiene fondo blanco, una cuadrícula de colores que cabe en la pantalla del iPhone sin hacer scroll y unas monedas que marcan las tres horas más baratas. También permite consultar los precios de mañana cuando se publican los datos, y se puede añadir a la pantalla de inicio para usarla como una app. Sin anuncios, cuentas ni seguimiento. Está alojada en GitHub Pages, se actualiza automáticamente y el código es público.</description></item><item><title>Café de Datos: mi cuaderno cafetero</title><link>https://blog.deigote.com/2026/11/23/cafe-de-datos-mi-cuaderno-cafetero/</link><guid>https://blog.deigote.com/2026/11/23/cafe-de-datos-mi-cuaderno-cafetero/</guid><pubDate>Mon, 23 Nov 2026 12:00:00 +0000</pubDate><description>Café de Datos es un pequeño cuaderno de los cafés que voy probando: cuánto me costaron, qué prometían sus notas de cata y qué me parecieron realmente. Tiene una web sencilla para consultar, filtrar y ordenar la colección, pero por debajo solo hay un CSV y un poco de HTML y JavaScript. Guardar también la descripción del tostador permite conservar esa información cuando un café desaparece de la tienda y comparar sus notas con mi experiencia. La gracia está en usar ese historial para elegir el siguiente pedido con ayuda de un agente de código. El agente lee mis preferencias y valoraciones, explora los cafés disponibles y propone una combinación de favoritos, opciones económicas y alguna novedad que pueda encajar conmigo. No hay un panel de administración: le cuento qué he probado y él actualiza los datos. El proyecto está en GitHub, preparado para que cualquiera pueda copiarlo, apuntar su agente al repositorio y empezar su propio cuaderno cafetero.</description></item><item><title>Deploying new features at AutoScout24</title><link>https://blog.deigote.com/2023/06/15/deploying-new-features-at-autoscout24/</link><guid>https://blog.deigote.com/2023/06/15/deploying-new-features-at-autoscout24/</guid><pubDate>Thu, 15 Jun 2023 12:00:00 +0000</pubDate><description>I wrote this article while working at AutoScout24. It was originally published on the AutoScout24 Tech Blog on August 26, 2019. I’m keeping a copy here for posterity, in case the original page ever disappears. The text below is reproduced as it was published in 2019. Original article · August 26, 2019Diego Toharia · AutoScout24 Tech Blog Deploying new features at AutoScout24 One of the things that some newcomers are surprised about when joining AutoScout24 is the way we deploy new features. In this article I will try to give an overview of how we do it and some of the reasons behind it. No staging environments When we started to migrate our monolith to AWS based micro-services, we decided that we no longer wanted to have staging or pre-production environments. Instead, we would only maintain production, and our engineers would deploy directly to it. Having several environments increases deployment complexity since one needs a mechanism to understand what code is deployed in which environment. Maintenance costs are also higher, but more importantly, it also increases the time it takes for a release to make it to production. Continuous delivery Releasing our code directly to production in an automated way (that is, without any manual triggers) is the way we make sure we do continuous delivery. We think there’s no better way for it than continuous deployment — that is, to have every commit to master being released to production, without any intermediate stop other than running the tests. One important aspect around this is that we want our product engineers to feel as comfortable as possible when releasing new code to our customers and consumers, and we think the best way to feel comfortable about something is to do it as many times as possible. At AutoScout24 our engineers release new code dozens of times a day, without thinking about it, just by using trunk based development and doing small commits. Engineers release code to production dozens of times a day. Another important aspect is that we optimise for MTTR over MTBF. That is, we prefer to be able to recover from a failure very quickly than to try and make sure that failures never happen. To enable ourselves to do that, we invest in excellent monitoring and alerting, even favouring it over testing if necessary (though we try to excel at both things!). Test in production One consequence of not having any environment other than production is that manual testing, as in UX checks or QA tests, is done directly in production. Rather than a problem, we see this as a great advantage — what better way to know if your service works in production than, well, testing it there? The best way to know if code works in production is to test it there. Some automated tests run also in production in the form of semantic monitoring, though the big bulk of them run as part of the continuous integration pipeline. Many of these tests are written in the form of functional tests, especially when talking about APIs, and for many of them the service integrates directly with their production counterparts instead of mocking the dependencies. For write APIs, it is important to support test data across the different funnels, thus allowing to test without interfering with our users. Also, our micro-frontends engine can be run locally in a way in which one or many of the micro-frontends are resolved against locally running services, while keeping everything else pointing to production. This enables us to locally test UI changes in an environment that is as close to production as possible. Feature toggles Another important thing to deal with is that while we are manually testing our changes in production, we do not want our users to get exposed to the new code. To achieve that we use the well-known technique of feature toggles. Our tool of choice for this is Toguru. It allows to override individual toggles via browser query parameters or cookies, so engineers can easily run their manual and automated tests before turning a certain toggle on for the general public. Shadow traffic Last but not least, we also send shadow traffic to new services or features when possible. This allows us to gain confidence about its performance and behaviour under real traffic, both in volume and shape. This means that a service needs to be accessible as early as possible, though probably hidden to users. Once that’s the case, traffic can be sent to the service, getting early insights around performance, monitoring, etc. With this article I tried to give you a good understanding of how we release new features at AutoScout24, but more importantly, why we do it like we do. Like many others, I also found it surprising when I joined the company but now I couldn’t think of doing it any differently! If you want to experience techniques like this in an encouraging environment and surrounded with great people, get in touch.</description></item><item><title>Human readable to camel case in Scala</title><link>https://blog.deigote.com/2020/08/13/human-readable-string-to-camel-case-in-scala/</link><guid>https://blog.deigote.com/2020/08/13/human-readable-string-to-camel-case-in-scala/</guid><pubDate>Thu, 13 Aug 2020 08:18:00 +0000</pubDate><description>After searching for a simple way to convert a string like I am a nice string (human friendly) into something like IAmANiceString (camel-case) and finding formulas only for the opposite, I decided to write the solution myself. I’m sure it’s not the fastest and it doesn’t use regular expressions, but it’s simple to read (for me at least) and should allow me to build such string transformations myself in the future. Anyways, here the function: string-human-to-camel.scaladef humanToCamel(original: String): String = original .foldLeft(("", true)) { case ((acc, upper), e) =&gt; (if (e == ' ') acc else if (upper) acc + e.toUpper else acc + e, e == ' ') } ._1 Hope it’s useful for you, and if you have any feedback, feel free to leave it on the comments.</description></item><item><title>Feed My Files - build a feed from your filesystem</title><link>https://blog.deigote.com/2015/10/26/feed-my-files-build-a-feed-from-your-filesystem/</link><guid>https://blog.deigote.com/2015/10/26/feed-my-files-build-a-feed-from-your-filesystem/</guid><pubDate>Mon, 26 Oct 2015 10:22:58 +0000</pubDate><description>If for whatever reason you need to keep track of the new files being created on a remote filesystem, Feed My Files is your tool. It allows you to create a feed from a given path of the filesystem, and to customize the resulting URLs to match the server where the feed is published. It supports Atom, RSS2, and plain HTML for building the feed (or feeds, if multiple formats are seleted), and is built using Groovy and Gradle over the JVM. And thanks to the Gradle Wrapper it can be launched inside a docker container very easily. If you are interested, please read the REAME on the project's GitHub.</description></item><item><title>Gmail Sender - send emails from the command line</title><link>https://blog.deigote.com/2015/08/22/gmail-sender-send-emails-from-the-command-line/</link><guid>https://blog.deigote.com/2015/08/22/gmail-sender-send-emails-from-the-command-line/</guid><pubDate>Sat, 22 Aug 2015 13:57:31 +0000</pubDate><description>I had an itch that needed to be scratched already - in a couple of servers I maintain I had to send a few emails from some scripts, and having to install an SMTP server seemed like an overkill - one more service to maintain, having to add the server's IP address to the SPF DNS field, making the life easier for possible spam trojans to be silently installed... I thougth there had to be an easier way, but never put a couple of hourse into it. While migrating one server to docker I finally did it, and the result is Gmail Sender, a small CLI program that is written in Groovy and uses Gradle for managing the dependencies and allowing it to be launched from the command line. At the beggining I though of a simple Groovy script with Grapes, but then I switched to Gradle for 2 reasons: Easier to package as a library - so that it can be used not only from the command line, but from other services, such as Gmail Sender AAS. Easier to launch from the command line - gradle provides the fantastic gradle wrapper, so using it only requires to have a JVM installed. Gmail Sender supports HTML bodies, application-specific passwords, multiple addressees and can be launched using docker or can be added to another project as a maven dependency. For more details see the REAME page.</description></item><item><title>Dropbox in docker</title><link>https://blog.deigote.com/2015/06/28/dropbox-in-docker/</link><guid>https://blog.deigote.com/2015/06/28/dropbox-in-docker/</guid><pubDate>Sun, 28 Jun 2015 16:38:57 +0000</pubDate><description>I was thinking of an easy way to backup the wp-content directory of my two blogs (the other one being Una Cerveza Al Día :-D ) and Dropbox came to my mind: my space requirements are very modest, even for the beer blog with its one-picture-per-entry basis (after 4 years is using around 500MB). Since I very recently moved everything from puppet to docker, I thought Dropbox should be no less that the rest of the services (these being right now mysql, apache2, nginx and varnish :-) ). There were some Dockerfiles available for doing this, but it was quite simple so I gave it a go myself. You can find the repository in my Github account, under the name docker-dropbox. The README describes how to run the container, and is pretty straightforward. The only gotcha is that Dropbox requires you to authorize new devices, and dropboxd (the daemon included in the Dropbox Headless packages) does this step by printing a link in the standard output the first time it's launched. Once the link is opened in a browser and the docker container is added to the allowed devices, this is stored in the config directory. This has 2 consequences for the container: The first time the container is deployed you need to run docker logs deigote.com-dropbox to be able to grab the authorization link. The config file where the authorization is stored needs to be kept. For my, the easiest way to do this is to mount the whole config from the host filesystem, thus keeping the whole configuration persistent regardless of docker. Other than that, it worsk great: my pictures, plugins and themes are always backed up, making it very easy to switch to a new host - as I did very recently :-) .</description></item><item><title>Grails - Hibernate-safe domain class property editor</title><link>https://blog.deigote.com/2014/07/22/grails-hibernate-safe-domain-class-property-editor/</link><guid>https://blog.deigote.com/2014/07/22/grails-hibernate-safe-domain-class-property-editor/</guid><pubDate>Tue, 22 Jul 2014 08:00:53 +0000</pubDate><description>Grails automatic databinding is super powerful, but, at least in versions 2.2.x and below, is rather obscure and not very-well documented. Sometimes is not clear how a form input should be named depending on what you want to bind. An example, for a given domain class User and a property roles (that is an association with another to another domain class, Role), where sometimes you need to put roles as the input name (usually when the property is a collection), some other times roles.id (usually when the property is univaluated), or even roles[0].id (usually when the property is a sorted collection). Note the use of "usually" here, as sometimes more than one way (sort of) work. I've found that sometimes, for the first case (the input name not having id at the end), you might run into problems when the binding itself is done: since the input name is roles, Grails/Spring identifies the property type as an instance of the domain class Role, but the supplied value is a Long (or its string representation) - concretely, the id of the domain class that we want to associate to the property roles Grails complains about it by saying: Failed to convert property value of type java.lang.String to required type java.util.Set for property roles; nested exception is java.lang.IllegalStateException: Cannot convert value of type java.lang.String to required type Role for property roles[0]: no matching editors or conversion strategy found One solution for this is to provide a custom property editor, a feature that, as many others, is not documented by Grails itself, since is directly inherited by Spring (section "Registering additional custom PropertyEditors"). My first approach for this was to create a generic property editor that could work with any domain class and any property to identify it. The result was the following: GrailsHibernateSimpleDomainClassPropertyEditor.groovypublic class DomainClassLookupPropertyEditor extends PropertyEditorSupport { Class domainClass String property Boolean doAssert = true String getAsText() { value."$property" } void setAsText(String text) { value = searchValueInNewSession(text) assert doAssert &amp;&amp; value, "no $domainClass found for $property '$text'" } private searchValueInNewSession(String text) { domainClass.withNewSession { domainClass."findBy${property.capitalize()}"(text) } } static DomainClassLookupPropertyEditor newInstance(Class domainClass, String propToLookup) { new DomainClassLookupPropertyEditor(domainClass: domainClass, property: propToLookup) } } public class MyPropertyEditorRegistrar implements PropertyEditorRegistrar { static Map&lt;Class, String&gt; domainClassByPropertyCustomBinders = [ (User): 'id', (Role): 'authority' ] public void registerCustomEditors(PropertyEditorRegistry propertyEditorRegistry) { domainClassByPropertyCustomBinders.each { domainClass, prop -&gt; registerDomainClassLookupPropEditor(propertyEditorRegistry, domainClass, prop) } } private registerDomainClassLookupPropEditor( PropertyEditorRegistry propertyEditorRegistry, Class domainClass, String propToLookup ) { propertyEditorRegistry.registerCustomEditor( domainClass, DomainClassLookupPropertyEditor.newInstance(domainClass, propToLookup) ) } } With that approach, you have a class DomainClassLookupPropertyEditor that extends PropertyEditorSupport and that, when given a text to convert it into a domain class instance, searches the existing instance in the database using the declared property. The search is done in a new session to prevent automatic flushing in the middle of the databinding (by default, Grails configures Hibernate in a way that a flush will be done when performing a query). The second class needs to be registered as a bean (by adding myEditorRegistrar(MyPropertyEditorRegistrar) in resources.groovy ), and on startup it will register a property editor for each domain class declared in the domainClassByPropertyCustomBinders map (where the key of each entry would be the domain class, and the value the property used as a value in the form input). This approach worked for me for a while, until I ran into a problem I never had before: sometimes, when modifying an existing property by removing some of the previous values (but not all), Grails would throw the following exception: org.springframework.dao.DuplicateKeyException: a different object with the same identifier value was already associated with the session; nested exception is org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session It was more or less clear what was going on: the object retrieved by the searchValueInNewSession method was already in the current Hibernate session, so when trying to put one coming from a different session, Hibernate complained about it already been there. I tried different approaches, such as trying to merge the object coming from the new session, or trying to read the object in the existing with the method load (that theoretically would prevent the flush), but I always ended up with an exception similar to: org.hibernate.AssertionFailure: collection was not processed by flush() I think that is the only Hibernate related exception I've run into when using Grails that I can't still properly explain :oops: . I mean, I understand what Hibernate is trying to say, but I don't know why is triggered). Still, my thoughts were that somehow the object that I retrieved from the existing session had already been part of a flushed session, and that affected only its collections. In any case, after playing with it a bit I managed to make it work by using the following strategy: Search the existing object in the current session If the object is found, use its id to get a new instance (so is not tainted by previous sessions) of it that is lazingly loaded using load (so it doesn't trigger a flush in the current session) If is not found, retrieve the instance in a new session (as before) The full code would then look as the following: GrailsHibernateSafeDomainClassPropertyEditor.groovyimport static org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsHibernateUtil.unwrapIfProxy public class DomainClassLookupPropertyEditor extends PropertyEditorSupport { Class domainClass String property Boolean doAssert = true String getAsText() { value."$property" } void setAsText(String text) { def alreadyInSessionValue = searchValueInCurrentSession(text) value = alreadyInSessionValue != null ? domainClass.load(alreadyInSessionValue.id) : searchValueInNewSession(text) assert doAssert &amp;&amp; value, "no $domainClass found for $property '$text'" } private searchValueInNewSession(String text) { domainClass.withNewSession { domainClass."findBy${property.capitalize()}"(text) } } private searchValueInCurrentSession(String text) { domainClass.withSession { session -&gt; session.persistenceContext.entityEntries.find { instance, persistenceEntry -&gt; unwrapIfProxy(instance).getClass() == domainClass &amp;&amp; instance[property].toString() == text }?.key } } static DomainClassLookupPropertyEditor newInstance(Class domainClass, String propToLookup) { new DomainClassLookupPropertyEditor(domainClass: domainClass, property: propToLookup) } } public class MyPropertyEditorRegistrar implements PropertyEditorRegistrar { static Map&lt;Class, String&gt; domainClassByPropertyCustomBinders = [ (User): 'id', (Role): 'authority' ] public void registerCustomEditors(PropertyEditorRegistry propertyEditorRegistry) { domainClassByPropertyCustomBinders.each { domainClass, prop -&gt; registerDomainClassLookupPropEditor(propertyEditorRegistry, domainClass, prop) } } private registerDomainClassLookupPropEditor( PropertyEditorRegistry propertyEditorRegistry, Class domainClass, String propToLookup ) { propertyEditorRegistry.registerCustomEditor( domainClass, DomainClassLookupPropertyEditor.newInstance(domainClass, propToLookup) ) } } The part where the object is searched in the existing session is a bit cryptic, but is based on a code that I have used before (see Grails – how to see what objets are in Hibernate session) and was already in my always-growing GrailsUtils class :-) . So far it has worked properly in all scenarios (single / multiple, directional/unidirectional, mandatory/optional relationships), but I wouldn't be surprised if I ran into more problems in the future :sad: . If that's the case, I'll update this post with my findings :roll: .</description></item><item><title>Grails - No such property for class: org.codehaus.groovy.grails.web.taglib.NamespacedTagDispatcher</title><link>https://blog.deigote.com/2014/07/14/grails-no-such-property-for-class-org-codehaus-groovy-grails-web-taglib-namespacedtagdispatcher/</link><guid>https://blog.deigote.com/2014/07/14/grails-no-such-property-for-class-org-codehaus-groovy-grails-web-taglib-namespacedtagdispatcher/</guid><pubDate>Mon, 14 Jul 2014 18:15:29 +0000</pubDate><description>Behind that obscure title lies a problem that I recently had with Grails and that consumed half of my morning. The solution was rather simple but finding it was hard for me (although once it has happened once to you, I guess it is one of the ones that you won't forget). When rendering a certain template (no matter what controller, taglib or parent template invoked that rendering), I was getting an error like: groovy.lang.MissingPropertyException: No such property: id for class: org.codehaus.groovy.grails.web.taglib.NamespacedTagDispatcher The exception was being thrown when null-safely accessing a variable that was optional in the template model, so some renderings wouldn't include it. After a while, I discovered that NamespacedTagDispatcher is the class used to make all the taglibs namespaces available as objects in both controllers or views (so you can do but also ${g.message(...)}, and in the second case g would be an instance of NamespacedTagDispatcher). After a bit of thinking I realized I recently included a new tablig whose namespace was exactly the same as the variable that was crashing. So when the variable was not passed as part of the model, instead of being null, it became a NamespacedTagDispatcher for invoking the tags contained in that taglib. I don't know if there's a solution for preventing this (other than choosing very concrete namespaces), but this is yet another reason to avoid using views for other than coordinating taglibs invokations (no logic in the views at all). The way templates work right now, with model being implicitly spread to variables, and no "method signature", is evil (666) .</description></item><item><title>Fish shell - using modules to import functions</title><link>https://blog.deigote.com/2014/05/19/fish-shell-using-modules-to-import-functions/</link><guid>https://blog.deigote.com/2014/05/19/fish-shell-using-modules-to-import-functions/</guid><pubDate>Mon, 19 May 2014 19:59:42 +0000</pubDate><description>I recently decided to give fish shell a try. I've always been reluctant to change my shell: bash has certainly its flaws, but it is widely spread. But lately I'm trying to go easier on embracing new things, since my natural approach is to be (extremely) skeptical about them (although the main reason to start using fish was its funny webpage, to be honest :-D ). So far the experience has been pretty satisfiying (the documentation is a bit poor, but it's expected in a your project like this), but one of the weakest points of bash, in my opinion, is the lack of a "dependencies" manager, and it seems that fish lacks that feature too. A shell always comes with a scripting language, but is like if the people behind these languages wouldn't take them seriously. "Meh, is just for scripts... why complicate them with dependencies?" Well, scripts are extremely powerful and repeating code is The Programmer's Bane :lol: , so I think it would be great to have a mechanism to easily "include libraries" in your config file. Since I'm trying to be less reluctant to new, non standard things :-D , I decided to start using a custom mechanism in fish, which so far I've found to work out fine. Original as I am, I called it fish-modules :-D . Getting fish-modules The first step is to clone the fish-modules project. It can be put anywhere you prefer. In my case, I found convenient to add it as a submodule of my fish config repository, which was already a git project. /usr/local/ or $HOME/local could be suitable choices as well. add-fish-modules-as-git-submodule.shcd $HOME/.config/fish git submodule add git@github.com:deigote/fish-modules.git fish-modules git ci fish-modules .gitmodules -m 'Added fish-modules as a submodule for convenience' Creating the modules Creating a module is as easy as creating a git repository with a directory functions and, optionally, a directory completions. Using the same conventions defined by the fish shell, the former can contain files where functions are defined (in a one-per-file basis), and the latter will be used to define the auto-completions of those functions. An example of a module would be the gh-issue flow fish module. Defining the modules as dependencies The first step would be to create a file in fish home (defaults to $HOME/.config/fish) called modules_config.fish. Each module would consists on a call to the implicit function module followed by the git repository route, the relative path and, optionally, the branch to use (defaults to master). An example of a possible modules config file is: modules_config.fishmodule "git@github.com:deigote/fish-common.git" fish-common module "git@github.com:deigote/gh-issues-flow.git" gh-issues-flow Updating the modules Once your modules are defined, and assuming you have fish-modules in $HOME/.config/fish/fish-modules, you can init or update them using the command: update-fish-modules.sh~/.config/fish/fish-modules/update_modules.fish This will create the directory modules and will clone each specified module inside of it. Next time you invoke it, it will just perform a pull. Making the modules accesible in your shell Last step is having the functions and completions accesible in each fish shell you open. Assuming again that you have fish-modules in $HOME/.config/fish/fish-modules, that is as easy as adding the following line to your $HOME/.config/fish/config.fish : config.fish# Some other fish configuration goes here # Fish modules source $HOME/.config/fish/fish-modules/add_modules_to_path.fish If everything goes as expected, when opening a new terminal you will be able to use all the modules functions. An easy way to check if that's the case is to echo the $fish_function_path to see if each module functions path is defined. Future I'd like to support dependencies definitions in the modules themselves, but I didn't have the time yet. Other than that, I think this mechanism is simple enough and can encourage fish users to share their magic without having to share the whole fish configuration folder (which is not only painful in terms of merging, but can also have privacy issues). But I also think it would be very neat to have something similar out of the box: it would be optional to have, simple to use and it would not add extra grammar.</description></item><item><title>Grails - Is my bean a singleton?</title><link>https://blog.deigote.com/2014/05/06/grails-is-my-bean-a-singleton/</link><guid>https://blog.deigote.com/2014/05/06/grails-is-my-bean-a-singleton/</guid><pubDate>Tue, 06 May 2014 12:50:00 +0000</pubDate><description>At an interesting discussion about how to bulk-delete objects in Grails, I suggested using the sessionFactory bean to explicitly flush the session when required. One of the participants was concerned about the sessionFactory not being a singleton, in which case injecting it in a controller or service (or any other bean for that matter) would be very expensive as a new instance would be created each time. I was pretty sure that bean would be a singleton... why wouldn't it be, when even in the SessionFactory documentation is said that "Usually an application has a single SessionFactory instance"? And being Grails a convention over configuration framework, the normal thing to do would be to follow that convetion :-) . But still, he had a point: being pretty sure about something doesn't make it true :) . I couldn't find documentation on how the session factory is configured (an old topic in Grails: where are the Spring and Hibernate specifics documented?), but luckily, is very easy to access that information at runtime: GrailsCheckBeanConfigurationAtRuntime.groovydef grailsApplication // Injected by default in controllers, accessible as a regular bean elsewhere assert grailsApplication.mainContext.getBeanDefinition('sessionFactory') instanceof org.springframework.beans.factory.support.GenericBeanDefinition // Have I any non-singleton bean ? grailsApplication.mainContext.getBeanDefinitionNames().any { !grailsApplication.mainContext.getBeanDefinition(it).singleton } You can see which beans are configured, and see their specifics by accessing their properties (each definition is an instance of the GenericBeanDefinition class).</description></item><item><title>Grails - query or criteria against a string/value pairs map property</title><link>https://blog.deigote.com/2014/04/21/grails-query-or-criteria-against-a-stringvalue-pairs-map-property/</link><guid>https://blog.deigote.com/2014/04/21/grails-query-or-criteria-against-a-stringvalue-pairs-map-property/</guid><pubDate>Mon, 21 Apr 2014 10:35:37 +0000</pubDate><description>Grails has a feature that I find sometimes useful: mapping a simple map of string/value pairs using GORM. That is, given a domain class, if you create a property whose type is Map, and the name of the property is not the name of an association (hasMany, etc), this property will act as a String to String map than will be automatically persisted and retrieved by GORM. You only need to care about filling the map up as you would do with a normal map (keeping in mind, of course, that both the keys and values must be strings). But, if you carefully read what I wrote, you might be wondering why I just said that GORM will take care of persisting and retrieving. What about querying? Well, like many other areas in Grails, the documentation only covers the Grails specifics, leaving the Hibernate / Spring / other components out for you to find :-) . I guess is hard to find a balance on that topic, but in any case, I couldn't find how to query a domain class using the contents of its key/value pairs properties. Immediately after after posting a question in Stackoverflow, I discovered how to do it with HQL. Let's use the classic Author domain class as an example, just as the Grails documentation does: class Author { Map bookTitlesByIsbn = [:]// map of ISBN:book names } Given an ISBN and a book title fragment, you could query the Author domain class like the following: String isbn = params.isbn, partialTitle = params.title Author.executeQuery("from Author a where a.books['${isbn}'] like '%${partialTitle}%'") It probably doesn't make much sense to have the ISBN and not the title, as both are "user input", but for me, the common usage of this type of properties would be to store the entries of an enum as keys, so latter you could query by value for those entries. I created a demo app that illustrates the example, and for the lazies who don't want to download and run it :-D , I deployed it in Heroku. Sadly, I couldn't find how to do the same with Hibernate Criterias, which I usually prefer over HQL: the former is based on closures and methods (i.e it has a DSL), so the readibility and composibility is way better. But still, I found pretty neat that the map syntax worked in HQL the way it does :-) .</description></item><item><title>Grails - my domain class instance says its class is abstract!</title><link>https://blog.deigote.com/2013/11/18/grails-my-domain-class-instance-says-its-class-is-abstract/</link><guid>https://blog.deigote.com/2013/11/18/grails-my-domain-class-instance-says-its-class-is-abstract/</guid><pubDate>Mon, 18 Nov 2013 09:56:18 +0000</pubDate><description>I recently faced a weird problem when using Grails and a domain class hierarchy that contained abstract classes, let's say: abstract class A { ...} abstract class B extends C { ...} class C extends A { ...} class D extends B { ...} So the problem was that a certain instance of the class D, in a certain context (i.e. given the same instance, it didn't show the problem always, but actually only when used in a certain gsp), was saying that its class was B (which is absurd, since B is abstract and therefore it can't be anybody effective class!). I found out that the instance was actually a Hibernate proxy, which shouldn't be a problem if I accessed the class using the Grails domainClass attribute. But still was. Let's put it in code: void testThatTheEffectiveClassIsNotAbstract(Long id) { assert B.get(id).getClass() != B_$$_javassist_100 assert B.get(id).domainClass.clazz != B Sql.newInstance(ctx.dataSource).eachRow("select class from a where id = ${id}") { it.class == D.name } } So, this test was failing in a certain situation for only certain instances. WTF? Anyway, I'm sick of having problems with the whole Hibernate proxy thing and I couldn't spend time figuring out the whole thing (and moreover, it was impossible for me to reproduce it in a test case), so I ended up adding the the following method to my (constantly growing) GrailsUtils.groovy class (although maybe I should rename it to GrailsHacks.groovy :-( ): import java.lang.reflect.Modifier import static org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsHibernateUtil.unwrapIfProxy static Class getDomainClassInstanceEffectiveClass(instance) { Class proxiedClass = instance.domainClass.clazz Modifier.isAbstract(proxiedClass.getModifiers()) ? unwrapIfProxy(instance).getClass() : proxiedClass } which actually got the correct class everytime. Surprising? I don't know what to think anymore...</description></item><item><title>Temacos traducidos: John Mayer - Stop This Train</title><link>https://blog.deigote.com/2013/08/08/temacos-traducidos-john-mayer-stop-this-train/</link><guid>https://blog.deigote.com/2013/08/08/temacos-traducidos-john-mayer-stop-this-train/</guid><pubDate>Thu, 08 Aug 2013 15:06:18 +0000</pubDate><description>Aunque en Europa no es especialmente conocido (al menos que yo sepa, igual es sólo en España o que yo vivo en una burbuja, que también puede ser :-D ), John Mayer parece que es toda una celebridad en USA. Yo, para variar, lo conocí por recomendación de mi hermano (que, por cierto, aprovecho para comentar que ahora anda de lleno en una nueva y espectacular banda, The Dog Pack :-D ), justo cuando publicó el disco que para mi gusto marca una diferencia en su música, Continuum. Digo esto porque los discos anteriores no me terminan de enganchar, pero éste y los posteriores me parecen otra película diferente (Battle Studies me gusta, aunque no me entusiasme, y Born And Raise me parece buenísimo, y eso que al principio se me hacía un poco duerme-ovejas :lol: ). Del mencionado Continuum hay muchos temas que me encantan, pero el que no me canso nunca de oir es Stop This Train. Me parece una canción realmente redonda, técnicamente soberbia pero en apariencia sencilla, muy bonita y con una letra de esas que te hace pensar que te identificas especialmente con ella, pero que realmente habla algo tan universal como el miedo a hacerse mayor. Ninguna versión de las que he oido me gusta más que la original en estudio: Ver el vídeo original A continuación, letra original y mi intento de traducción (como siempre, toda corrección será más que bienvenida). Original Traducción No I'm not color blind I know the world is black and white Try to keep an open mind but... I just can't sleep on this tonight Stop this train I want to get off and go home again I can't take the speed it's moving in I know I can't But honestly won't someone stop this trainDon't know how else to say it, don't want to see my parents go One generation's length away From fighting life out on my ownStop this train I want to get off and go home again I can't take the speed it's moving in I know I can't but honestly won't someone stop this train So scared of getting older I'm only good at being young So I play the numbers game to find a way to say that life has just begun Had a talk with my old man Said help me understand He said turn 68, you'll renegotiate Don't stop this train Don't for a minute change the place you're in Don't think I couldn't ever understand I tried my hand John, honestly we'll never stop this train See once in a while when it's good It'll feel like it should And they're all still around And you're still safe and sound And you don't miss a thing 'til you cry when you're driving away in the dark. Singing stop this train I want to get off and go home again I can't take this speed it's moving in I know I can't Cause now I see I'll never stop this train No, no soy daltónico Sé que el mundo es en blanco y negro Intento tener la mente abierta, pero... Simplemente no puedo dormir con esto en la cabeza esta noche. Parad este tren, me quiero bajar y volver a casa, no aguanto la velocidad a la que se mueve. Sé que no puedo, pero sinceramente, nadie va a parar este tren?No sé de qué otra manera decirlo, no quiero ver a mis padres irse. Una generación de distancia de empezar a luchar la vida por mi cuentaParad este tren, me quiero bajar y volver a casa, no aguanto la velocidad a la que se mueve. Sé que no puedo, pero sinceramente, nadie va a parar este tren? Tan asustado de hacerme viejo, sólo se me da bien ser joven. Así que juego con los números para encontrar una forma de decir que la vida acaba de empezar. Hablé con mi padre, le dijé que me ayudase a entender. Me dijo "cumple 68, y renegociarás, no pares este tren, no cambies ni por un minuto el sitio en el que estás, no pienses que yo lo pude entender. Yo jugué mi mano, John, sinceramente, nunca pararemos este tren". Mira, de vez en cuando, cuando todo vaya bien Todo se sentirá como debería ser Y todavía están contigo, y tú todavía estás seguro y sano y no echas de menos nada, hasta que lloras cuando estás alejándote en la oscuridad. Cantando, parad este tren, me quiero bajar y volver a casa No aguanto la velocidad a la que se mueve Sé que no puedo, porque ahora veo, que nunca pararé este tren. No cambies ni por un minuto el sitio en el que estás :-) .</description></item><item><title>Grails - Quickly examine a domain class associations</title><link>https://blog.deigote.com/2013/07/30/grails-quickly-examine-a-domain-class-associations/</link><guid>https://blog.deigote.com/2013/07/30/grails-quickly-examine-a-domain-class-associations/</guid><pubDate>Tue, 30 Jul 2013 09:00:11 +0000</pubDate><description>When your Grails model gets a bit complex, you may find yourself with conflicts in your domain classes associations (I like some parts of GORM, such as dynamic finders, but I think the relationships stuff could be improved). In my case, I usually end up finding problems when I mix inheritance and different relationships between the same pair of objects (actually, the latter is enough, but also easier to detect), and I have to use the mappedBy option to resolve them. Anyway, here it goes a simple method to examine the main properties of an association, that reveals such problems (and maybe others) very clearly, so you can be certain that you are actually solving something with the mappedBy, and not just "fishing" (I used to try to "fish" a lot when I was less experienced with Grails): def grailsApplication def logDomainClassAssociations(Class someDomainClass) { grailsApplication.getDomainClass(someDomainClass.name).associations.collectEntries { assoc -&gt; [ (assoc.name) : [ 'bidirectional', 'circular', 'otherSide.name', 'owningSide', 'hasOne', 'manyToOne', 'oneToMany', 'manyToMany', ].collectEntries { prop -&gt; [ (prop) : resolveNestedProperty(assoc, prop) ] }] }.each { assocName, assocProperties -&gt; log.info "$assocName: $assocProperties" } } This assumes that you declare this method in the a class that contains the all-mighty :lol: nested property resolver method that I posted a few days ago (in my case, I usually create a GrailsUtils class and then declare it as a bean in the resources.groovy file). Last but not least, the properties that I used are the ones I usually find most useful, but you can adapt it to your needs using the Grails Domain Class API.</description></item><item><title>Groovy - Simplest way of resolving a nested property</title><link>https://blog.deigote.com/2013/07/24/groovy-simplest-way-of-resolving-a-nested-property/</link><guid>https://blog.deigote.com/2013/07/24/groovy-simplest-way-of-resolving-a-nested-property/</guid><pubDate>Wed, 24 Jul 2013 09:00:53 +0000</pubDate><description>So let's say that in Groovy you find yourself wanting to do something like this: [ 'name', 'lastName', 'address.street'].collect { propertyToResolve -&gt; [(propertyToResolve): user[property] } You will find that the automatic getter (using it with the map syntax or as a property doesn't change anything) won't parse the argument to resolve the property in the whole object graph, but it will just search for a property in the object where is called (which absolutely make sense, of course :-D ). The next piece of code is one that I like to have in my typical grailsUtils bean: def resolveNestedProperty(bean, String nestedProperty) { nestedProperty.tokenize('.').inject(bean) { valueSoFar, property -&gt; valueSoFar[property] } } Then you will be able to resolve the previous example by doing: [ 'name', 'lastName', 'address.street'].collect { propertyToResolve -&gt; [(propertyToResolve): grailsUtils.resolveNestedProperty(property, user) } Yes, yes, I know: nothing really fancy or new, but it came in handy many times and I wanted to write it down :-D . Update: I updated the method in order to be more powerful (using Eval) yet faster when possible (by detecting if the expression needs Eval or not using regular expressions). So now it looks like the following: static resolveNestedProperty(bean, String nestedProperty) { nestedProperty ==~ /[a-zA-Z0-9]+/ ? bean[nestedProperty] : nestedProperty ==~ /[a-zA-Z0-9.]+/ ? nestedProperty.tokenize('.').inject(bean) { valueSoFar, property -&gt; valueSoFar ? valueSoFar[property] : null } : Eval.me('bean', bean, "bean.${nestedProperty}") }</description></item><item><title>Grails - publish a plugin in a self-hosted maven repository</title><link>https://blog.deigote.com/2013/06/10/grails-publish-a-plugin-in-a-self-hosted-maven-repository/</link><guid>https://blog.deigote.com/2013/06/10/grails-publish-a-plugin-in-a-self-hosted-maven-repository/</guid><pubDate>Mon, 10 Jun 2013 10:08:28 +0000</pubDate><description>Context and motivations Since a few versions ago, grails includes the possibility of packaging your plugin as an old good JAR file. This can be done by using the --binary option: grails-timestamped $ grails package-plugin --binary Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8 -Xmx2048m -Xms256m -XX:PermSize=512M -XX:MaxPermSize=2048M | Packaging Grails application..... | Plugin packaged grails-plugin-timestamped-0.3.jar grails-timestamped $ ls target/*.jar target/grails-plugin-timestamped-0.3.jar This allows a developer to publish closed plugins (as with the traditional packaging, installing a plugin means that you'll get the source code in your $HOME/.grails) and to gain some speed in compiling / deployment operations, since the plugin doesn't need to be compiled. Another benefit that I've not seen mentioned anywhere is that this allows a plugin to provide AST transforms that can be used by other plugins (as, for example, the timestamped plugin does). The reason is that an AST transform needs to be available at compile time, so if you compile it in the same "compilation execution" as the classes where it's been applied, it won't be able to do its work, and all plugins are compiled in the same "compilation execution" (but not in the same "compilation execution" as the main project, being that the reason why the AST transform will work in the project). There is a problem with the binary packaging though, and is that right now the grails plugins official portal doesn't support it. You have then to publish it to a maven repo and add it as a maven dependency. Too much work? Not really! Grails Plugin Maven Deployer I created a small scripting tool that can create a maven repo structure from a grails plugin. You can just put that structure in any webserver (or even Github or Github pages), and you are ready to go. The Grails Plugin Maven Deployer can be found in Github, and this is an example of using it to publish the timestamped grails plugin: Prepare a temp directory with the plugin and the deployer for a demo: $ mkdir grails-plugin-maven-deployer-demo &amp;&amp; cd grails-plugin-maven-deployer-demo $ mkdir -p maven/releases/ $ git clone https://github.com/deigote/grails-timestamped $ git clone https://github.com/deigote/grails-plugin-maven-deployer Using the deployer: $ grails-plugin-maven-deployer/deploy.sh grails-timestamped/ com.deigote.grails-plugins timestamped maven/releases/ $ ls -R maven/releases/ If everything goes well (if not, open an issue and I'll try to help :-D), you'll see a maven repo in the maven/releases (the destination directory passed as the fourth) for the artifact timestamped (the plugin name, passed as third argument to the script) and the group id com.deigote.grails-plugins (passed as second argument to the script). The first argument is, of course, the path to the plugin to publish :-D . Then you just can publish the destination directory in any webserver and include it as a dependency. For example, I published the maven/releases/ in Github Pages, which allows me to reach it by including the following in the project's BuildConfig.groovy: dependencies { ... compile 'com.deigote.grails-plugins:timestamped:0.3' } repositories { inherits true mavenRepo 'http://deigote.github.io/grails-timestamped/maven/releases/' ... }</description></item><item><title>New Grails plugin - Timestamped</title><link>https://blog.deigote.com/2013/06/03/new-grails-plugin-timestamped/</link><guid>https://blog.deigote.com/2013/06/03/new-grails-plugin-timestamped/</guid><pubDate>Mon, 03 Jun 2013 09:46:06 +0000</pubDate><description>Plugin URL: grails.org/plugin/timestamped Plugin documentation: deigote.github.io/grails-timestamped/guide/single.html Demo project with integration tests: github.com/deigote/TimestampedDemo I recently created a small Grails plugin to use it as part of my work at tadoº, the awesome company I'm currently working for :-) . The plugin aims to provide a more declarative way of making a domain class auto timestamped. Right now, for making a domain class auto timestamped, you need to declare two properties with the proper type, which is a bit of a DRY violation. Also, these properties aren't part of the domain class logic, so I prefer them to be declared elsewhere. With these things in mind, the plugin provides an annotation which, when used in a domain class, triggers an AST transform that inject the auto timestamping properties in that domain class. The most simple example would be as following: package timestampeddemo import com.tado.timestamped.transform.Timestamped @Timestamped class FullTimestamped { } Since the most common option is to inject both properties, the default is to do so, but you can configure which events you want to consider: package timestampeddemo import com.tado.timestamped.transform.Timestamped @Timestamped(create=false) class UpdateTimestamped { } package timestampeddemo import com.tado.timestamped.transform.Timestamped @Timestamped(update=false) class CreationTimestamped { } The plugin is prepared to work with the joda-time plugin, so if present, the generated timestamping properties will be typed as org.joda.time.Instant instead of the old, not-so-good java.util.Date. But if you happen to prefer any other class, you can specify it as a part of the Timestamped annotation: package timestampeddemo import com.tado.timestamped.transform.Timestamped @Timestamped(clazz='java.lang.Long') class CustomClassTimestamped {} This, of course, only make sense if you provide the proper persistence auto timestamping support for the specified class, as happens for example with the joda-time plugin. Last, but not least, the plugin can be included as a tradicional plugin or as a maven dependency. The later allows the plugin to be used by other plugins, as it will be precompiled and the AST transform will be then available in plugin compile time as well. More info on this subject can be found in the installation chapter of the guide.</description></item><item><title>Grails - small and simple method to convert objects to JSON</title><link>https://blog.deigote.com/2013/01/12/grails-small-and-simple-method-to-convert-objects-to-json/</link><guid>https://blog.deigote.com/2013/01/12/grails-small-and-simple-method-to-convert-objects-to-json/</guid><pubDate>Sat, 12 Jan 2013 11:03:14 +0000</pubDate><description>I was playing around with Grails and JSON and came up with a small method to convert a given collection of objects into JSON (typically, domain class objects, but it would work with anything). It's nothing new or fancy, but maybe usefull for anybody who is starting to explore Grails JSON capabilities. For the sake of the example, I'll put the method in a JSONUtils class: import grails.converters.JSON class JSONUtils { protected static buildJSON(objectsToBuild, properties) { objectsToBuild.inject([], { objects, object -&gt; objects &lt;&lt; (properties.inject([:], { objectMap, property -&gt; objectMap &lt;&lt; [(property): object[property]] })) }) as JSON } } You could use it in a controller as following: import static JSONUtils.buildJSON class PersonController { def personService static personJSONProperties = [ 'name', 'gender', 'age'] def peopleByAge(Integer age) { buildJSON(personService.findByAge(age), personJSONProperties) } } I'm thinking that this could be a small but usefull AST transformation...</description></item><item><title>Bash - find directories of certain sizes</title><link>https://blog.deigote.com/2013/01/11/bash-find-directories-of-certain-sizes/</link><guid>https://blog.deigote.com/2013/01/11/bash-find-directories-of-certain-sizes/</guid><pubDate>Fri, 11 Jan 2013 14:49:15 +0000</pubDate><description>I often find myself trying to know which directories are consuming most of my persistent memory (I would say hard disk, but it isn't a disk - and probably, even hard - anymore), and always get disappointed with myself for not being able to remember the way to do it in the terminal :) . If you are dealing with files, you can use the allmighty find command with the size filter, for example: find . -type f -size +100M But that won't work with directories. After all, I guess they don't take much spaces themselves - the files contained by them are the ones that does :-) . So what I usually end up doing is finding directories with a certain depth, and then calculate their sizes and filter with grep. This would be an example: find $HOME -type d -mindepth 1 -maxdepth 3 -exec du -hs {} \; | grep -E "[0-9]{1}(\.[0-9]{1,2})?G" | sort -n This would list the directories contained in the user's home, recursing til a max depth of 3 levels, and them calculate all their sizes. After that, it would filter by the sizes whose size is 1 gigabyte or more. Last, the sizes are sorted with a numeric criteria. You can change the last letter to filter by megabytes (M), and the count of the first regular expression so it takes only numbers of a given lenght. For example, to get sizes in the range [100M-1G), you would use the following regular expression: "[0-9]{3}(\.[0-9]{1,2})?M". And to find directories with a size of at least 10 gigabytes, you would use: "[0-9]{2}(\.[0-9]{1,2})?G". You can also change the mindepth and maxdepth params in order to filter how deep you want the recursion. And if you don't provide a maxdepth param and set the base directory as /, the whole filesystem will be analized :).</description></item></channel></rss>