Jun
17
2010
0

Change your current Grails version with a simple shell script

Working with applications on multiple versions of Grails can be a pain. First you have to set your GRAILS_HOME environment variable, and then you have to make sure that the grails shell script (or grails.bat) is in your path. Since I have to switch versions frequently, I whipped up a simple shell script to make this easy. This is *nix specific (and may even be bash-specific), but it works for me.

Usage

$ ./setGrailsVersion 1.3.2
$ grails
Welcome to Grails 1.3.2 - http://grails.org/
Licensed under Apache Standard License 2.0
.......

$ ./setGrailsVersion 1.2.2
$ grails
Welcome to Grails 1.2.2 - http://grails.org/
Licensed under Apache Standard License 2.0
.......

Prerequisites:

  • Unzip your versions of grails side-by-side in a known directory. I use ~/grailsBase, so a valid install would be ~/grailsBase/grails-1.3.2
  • Leave your GRAILS_HOME environment variable set to ~/grailsBase/grails
  • Leave your PATH environment variable with an entry to ~/grailsBase/grails/bin
  • Save this script along side your installs. For me, this means I save it at ~/grailsBase/setGrailsVersion.sh

Script:

#!/bin/sh

##
## Switches grails versions by changing the the symlink ~/grails to a
## ~/grails-$VERSION
##
## Author: Dan Lynn (dan@danlynn.com)
##

if [ -z "$1" ]; then
	cat <<End-of-message
Usage:
	$0 [version]

The version argument must be a valid grails installation and comes in the standard grails versioning scheme.

Examples:
	$0 1.3.2
	$0 1.2.2

End-of-message

	exit 1
fi

DIRNAME=`dirname "$0"`
NEW_GRAILS_HOME="$DIRNAME/grails-$1"

if [ ! -d $NEW_GRAILS_HOME ]; then
	echo "$NEW_GRAILS_HOME doesn't exist!" >&2
	exit 1
fi

rm "$DIRNAME/grails"
ln -s $NEW_GRAILS_HOME "$DIRNAME/grails"
Written by Dan in: General |
Jan
27
2010
0

Server-side Prototype JS in classic ASP

Back in 2007, I found myself doing a lot of classic ASP work in VBScript. For anyone who has had to endure this, I created a library to help you out (released under the MIT open source license). Since classic ASP runs under Microsoft Active Scripting, this means you can write ASP pages in page in any supported scripting language; I’ve even gotten Python working under classic ASP.  The library allows you to use a more functional programming idiom on the server-side, thanks the Prototype library and JScript, a supported scripting language. I’ve merely reposted my original version, but I plan to update it to the latest version of the Prototype library and move the code to either GitHub or Google Code. Until then, give it a shot.

Written by Dan in: General | Tags: , , , , ,
Nov
18
2009
0

Verified by Visa’s insecure password requirements

Several retailers have signed up for Visa’s Verified by Visa program, which adds an additional step to the familiar online credit card process. Theoretically, this step makes the transaction more secure by allowing you to specify and use a password in addition to the usual details like “name on card” and “billing address”. Unfortunately their password requirements are terrible. Passwords must contain at least 6 characters and at most 8 characters, must contain at least one letter and at least one number and no special characters allowed.

Here is their javascript password validator:


if( (/\W/).test(document.passwdForm.pin1.value) || (document.passwdForm.pin1.value.length < 6) || (document.passwdForm.pin1.value.length > 8 ) )
{
    alert("Your password does not conform to the Password Policy. Please try again.");
    document.passwdForm.pin1.focus();
    return false;
}

For a feature that supposedly exists to protect my money on the web, this is just pathetic.

Written by Dan in: General |
Nov
05
2009
0

Groovy deserialization troubles

In a grails application, I needed to persist a complicated expression tree to the database, but I didn’t want to have Hibernate generate a database table for the information as it would greatly affect read performance (lots of joins) and I don’t need to have relational access to subsets of the tree. I decided to serialize the entire tree into a BLOB.

After creating a Hibernate userType to handle the serialization/deserialization, I ran into a ClassNotFoundException when attempting to deserialize my object.  I found out that this is due to java using the “last defined ClassLoader” when deserializing with an ObjectInputStream, which might not be the right ClassLoader in a Groovy environment (see: http://jira.codehaus.org/browse/GROOVY-1627.

The solution? Subclass ObjectInputStream to allow you to pass in a predefined ClassLoader and override the resolveClass(ObjectStream classDesc) to use this ClassLoader parameter:


public class ClassLoaderAwareObjectInputStream extends ObjectInputStream {

 private ClassLoader myClassLoader;

 public ClassLoaderAwareObjectInputStream(ClassLoader myClassLoader) throws IOException, SecurityException {
 super();
 this.myClassLoader = myClassLoader;
 }

 public ClassLoaderAwareObjectInputStream(InputStream in, ClassLoader myClassLoader) throws IOException {
 super(in);
 this.myClassLoader = myClassLoader;
 }

 @Override
 protected Class resolveClass(ObjectStreamClass desc) throws IOException,
 ClassNotFoundException {
 String name = desc.getName();
 return Class.forName(name, false, myClassLoader);
 }
}

Thanks to Satish Gunnu for the tip.

Oct
27
2009
0

Why I choose to run linux

Automatic Updates automatically restarts your computer for you

Automatic Updates automatically restarts your computer for you

Written by Dan in: General |
Jun
25
2009
2

Happiness is a 3-minute build

We just recently moved our continuous integration server to new hardware and removed a costly database comparison step, which shortened our build time from 10 minutes to less than 3. Half the time is spent on unit tests, and we include a build versioning step which prepares every build for potential release.

Cutting those seven minutes out of the feedback loop may not seem like much, but when you consider that we average about 20 builds per day that’s significant savings, even if there were only one developer waiting on the build results each time. Next up: database versioning using liquibase.

Written by Dan in: General | Tags: ,
Feb
23
2009
0

with spring comes flying weather

I’m excited for spring to arrive. It’s been far too long since I’ve been up in the air without the roar of a jet engine and the annoying beeps and dings of the seatbeat-sign.

My Wing - Advance Epsilon 4

My Wing - Advance Epsilon 4

It was too windy to fly that day

It was too windy to fly that day

Written by Dan in: General | Tags:
Jan
01
2009
3

danlynn.com at last

I finally got ahold of the domain danlynn.com. I had to wait about 5 years for this other Dan Lynn who lives in Sugar Hill, Georgia to cede the domain, but it’s mine now. Posts might be photography, bits of code, experiments in the kitchen, paragliding horror stories, or anything else that I find interesting that I think a few people might appreciate as well.

Written by Dan in: General |

Powered by WordPress | Theme: Aeros 2.0 by TheBuckmaker.com