Groovy functional sugar: Trampoline

Based on Gr8-Docs, recursive algorithms are often restricted by the maximum stack height (physical limit). If you call a method that recursively calls itself too deep, you will eventually receive a StackOverflowException. An approach that helps in those situations is using Closure and trampoline capability. The trampoline() method on a closure is wrapped in TrampolineClosure […]

Managing dependencies in groovy scripts

Imagine you want to write a Groovy script and this script uses a the 3rd party library. How to do? There are some solutions, such as: 1) Bootstrapping groovy with bash in the groovy script: #!/bin/bash //usr/bin/env groovy -cp extra.jar:some-spring-jar.jar:etc.jar -d -Dlog4j.configuration=file:/etc/myapp/log4j.xml “$0” $@; exit $? import org.springframework.class.from.jar //… code goes here… println ‘Wicket!’ 2) […]

Script to open new tab on MAC terminal

In my dev environment I used to start many services every day manually, thinking about how to make my life easier I wrote a script that aggregates all scripts, however, each one was running on different terminals in a new window, something like: open -a Terminal.app “/usr/local/Cellar/mongodb26/2.6.8/bin/mongod” I didn’t like the solution with several windows open, so I added […]