2009/06/14
I’ve recently thrown together a few different command line aliases that have been very helpful in my grails development and I thought others might benefit from them.
The aliases are primarily just the first letter of the words in the command, which makes them easy to remember (and saves on typing). Some examples:
gta # grails test-app
gtai # grails test-app -integration
gtaud AuthorService # grails-debug-suspend test-app -unit AuthorService
Read the rest of this article »
2009/06/1
The need to add some functionality an existing method, but avoiding cutting and pasting the old implementation has come up a few times over the last week.
Sometimes, creating a subclass isn’t feasible, often because you don’t control all of the places where that class gets used. Read the rest of this article »
2009/05/26
On my MacBook pro, I’ve got 4 removable hard drives (2 physical in 2 partitions each) and a JungleDisk mount.
I found it painful to manually eject each individual drive in the finder so I threw together this quick AppleScript to eject all the disks.
tell application "Finder"
eject (every disk)
end tell
Just open up /Applications/AppleScript/ScriptEditor.app and paste that in. Then choose “Save As” and pick “Application”. That will compile the script and create a .app file that you can click on to run, or you can put it in your path and execute it there.
I think the same kind of script could be created with the command line “diskutil eject” command, but this seemed cleaner as I wasn’t able to come up with a generic way to figure out which disks were “ejectable” and which weren’t. AppleScript is able to figure that all out for you.
2009/05/13
Over the years, I’ve had a number of requests for me to share my zshrc file with friends and coworkers. In the past, I’ve normally trimmed out the sensitive parts by hand and then e-mailed the most useful stuff. I’ve always intended to make this an easier process and I’ve finally gotten around to it.
I’ve created a new bitbucket repository to hold my shared zshrc configuration. You can get it for yourself by cloning the repository:
cd ~
hg clone http://bitbucket.org/tednaleid/shared-zshrc/
Read the rest of this article »
2009/04/14
Creating maintainable test data is hard.
Often an entire object graph needs to be created to support the instantiation of a single domain object. This leads to either the cutting and pasting of that creation code, or relying on a canned set of objects that we’ve grown over time and maintained as the domain objects change. After a while, adding just one more Widget to that set of canned data ends up breaking tests just about every time.
There has to be a better solution, right? Read the rest of this article »
2009/04/7
Groovy 1.6.1 was released today, and it includes a patch I submitted a few weeks ago to make working with regular expressions much more groovy. Thanks to everyone that voted for the patch in the Groovy JIRA.
The main functionality is the addition of a variety of find and findAll regular expression aware methods that have been added to string.
Read the rest of this article »
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 »
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 »
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 »
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