Wednesday, February 27, 2013

Symbolic links in Windows 7

This is just a quick note on how to create symbolic directory links in Windows 7. I like to use this for development languages/frameworks (e.g. groovy, grails) so that I can easily change the version of the language that I'm using. For example, I'll have the following setup C:\dev\lang\groovy C:\dev\lang\groovy\groovy-2.0.0 C:\dev\lang\groovy\groovy-2.1.1 C:\dev\lang\groovy\groovy-latest Where groovy-latest is a symlink to the version of groovy I want to use. I found the full directions on how to create a symbolic link in Windows here: http://www.howtogeek.com/howto/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux/ Here is the quick version using my above example. The command for making symlinks is called "mklink":
cd c:\dev\lang\groovy
mklink /D  groovy-latest groovy-2.1.1
The /D flag indicates this is a directory link. If the link exists already you have to remove it first:
cd c:\dev\lang\groovy
rmdir groovy-latest
mklink /D  groovy-latest groovy-2.1.1

Friday, February 22, 2013

Grails pretty print using deep JSON Converter

Here's a simple little Grails code sample to enable pretty printing on your JSON Converter when using the deep option:
def index() {
    def all = Product.list()
    withFormat {
        json {
            JSON.use("deep"){
                def c = all as JSON
                c.prettyPrint = true
                render c
            }
        }
        xml {
            XML.use("deep"){  
                render all as XML 
            }
        }
    }
}
After figuring this out I also discovered the JSON View extension for Chrome, which negated my need for pretty printing JSON.