Archive of published articles on March, 2009

Back home

Groovy: Enhancement to String class to add a regexp find method

2009/03/28

I just submitted a groovy patch that enhances the String class with a “find” method that makes working with regular expressions much easier.

One of the most common use cases is to search a string for a regular expression pattern. If a match is found, then do something with the matched value.
Read the rest of this article »

4 Comments

Enabling HTTPS support in curl installed through MacPorts on OSX

2009/03/16

I ran into an issue today when trying to use curl to post something to an https endpoint on one of my Grails applications. Apparently, recent macports versions of curl don’t have full ssl support enabled by default (I have no idea why, this seems like one of the basic use cases of curl).

This is what I was seeing:

% curl -k https://www.google.com
curl: (1) Protocol https not supported or disabled in libcurl

After a bunch of fiddling around looking at the Portfile (located at /opt/local/var/macports/sources/rsync.macports.org/release/ports/net/curl/Portfile), I saw that there was something called a variant that seemed to talk about ssl support.

I’d never needed to install a variant of a port before, but it’s actually pretty easy to do. Just add a “+” with the variant name at the end of the install command.

sudo port install curl +ssl

Read the rest of this article »

17 Comments

Tropo: interesting new IVR platform by Voxeo that supports Groovy

2009/03/14

Late last night, I ran across Tropo, a new IVR platform by Voxeo that supports a large variety of modern scripting languages, including my current favorite, Groovy (it also supports JavaScript, Ruby, Python, Jython, and PHP).

They just opened their “early beta” to the public about 10 days ago and have free accounts for developers to try things out.

They also have a github repository with a bunch of sample applications, and the adapter code that they’re using to make their core functionality available to all these different languages.

It’s nice to see an IVR company support all these modern things. VoiceXML has been rotting in a dungeon for the last 5 years and making a programming language out of an XML syntax was wrongheaded to begin with. Bringing languages like Groovy to bear on IVR problems will enable much more robust applications and quickent development.

Tropo’s documentation is a good start, but there are a number of holes in it since it’s so new. Because we have access to all of the yummy Groovy metaprogramming and reflection, we can find out lots of information about the system and it’s functionality for ourselves.

Read the rest of this article »

3 Comments

Bash/Zsh aliases to switch Groovy and Grails version

2009/03/8

I work on a couple of different grails projects that use a variety of versions of groovy and grails. I’ve thrown together a quick shell script that makes it easy to create a new alias to switch between different versions depending on what project you’re working with.

function switchGrails() {
    echo "Switching to groovy version: $1"
    echo "Switching to grails version: $2"
    sudo rm /usr/local/{groovy,grails}
 
    sudo ln -s /usr/local/$1 /usr/local/groovy
    sudo ln -s /usr/local/$2 /usr/local/grails
    echo "Done!"
    ls -latr /usr/local/{groovy,grails}
}
 
alias g104='switchGrails "groovy-1.5.7" "grails-1.0.4"'
alias g11rc2='switchGrails "groovy-1.6.0" "grails-1.1-RC2"'

You can create your own aliases like the ones above to switch to the groovy/grails combinations that you happen to be working with.

Just stick the code above in your .profile/.bashrc/.zshrc file and restart your shell to make the aliases available.

This function assumes that you’ve got you’ve got groovy and grails installed in your /usr/local directory and that you use a symlink at /usr/local/groovy that $GROOVY_HOME is pointed to and /usr/local/grails that $GRAILS_HOME is pointed to. If those assumptions aren’t correct for you, you’ll have to tweak the script.

It also uses “sudo” as it assumes that /usr/local is owned by root and not by your logged in user. If you’ve chowned the directory to yourself, you can remove the sudo (and the need to enter your password).

Now it’s easy for me to switch between different projects by just typing the appropriate alias:

pollux% g104
Switching to groovy version: groovy-1.5.7
Switching to grails version: grails-1.0.4
Done!
lrwxr-xr-x  1 root  wheel  23 Mar  8 19:55 /usr/local/groovy -> /usr/local/groovy-1.5.7
lrwxr-xr-x  1 root  wheel  23 Mar  8 19:55 /usr/local/grails -> /usr/local/grails-1.0.4
 
 
pollux% g11rc2 
Switching to groovy version: groovy-1.6.0
Switching to grails version: grails-1.1-RC2
Done!
lrwxr-xr-x  1 root  wheel  23 Mar  8 19:56 /usr/local/groovy -> /usr/local/groovy-1.6.0
lrwxr-xr-x  1 root  wheel  25 Mar  8 19:56 /usr/local/grails -> /usr/local/grails-1.1-RC2
5 Comments