Skip to content

Instantly share code, notes, and snippets.

View robfletcher's full-sized avatar

Rob Fletcher robfletcher

View GitHub Profile
@robfletcher
robfletcher / layout.html
Created March 3, 2011 19:13
A really simple boilerplate for a common page layout where the content sits in a central column with header and nav above and footer below. The column is always at least as high as the browser viewport.
<!doctype html>
<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]-->
<!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]-->
<!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Centered column with fixed footer</title>
<meta name="author" content="Rob Fletcher">
@robfletcher
robfletcher / chgrails.sh
Created November 23, 2010 15:11
bash script to change current Grails symlink
#! /bin/sh
VERSION=$1
GRAILS_DIR=/opt/grails-$VERSION
GRAILS_SYMLINK=/opt/grails
if [[ ! -d $GRAILS_DIR ]]; then
echo "Error: $GRAILS_DIR does not exist"
exit 1
fi
if [[ -e $GRAILS_SYMLINK ]]; then
class GreetingController {
def index = {
[message: message(code: "greeting.message", args: [params.name])]
}
}
import groovy.transform.*
import org.junit.*
import org.openqa.selenium.*
import org.openqa.selenium.support.ui.*
import org.openqa.selenium.firefox.*
import static org.junit.Assert.*
import static org.hamcrest.Matchers.*
class AutocompleteTests {
@artifact.package@import spock.lang.*
import grails.plugin.spock.*
class @artifact.name@ extends @artifact.superclass@ {
def "feature method"() {
}
}
package com.github.robfletcher.grails.validation
import org.codehaus.groovy.grails.validation.AbstractConstraint
import org.springframework.validation.Errors
class AcyclicConstraint extends AbstractConstraint {
static final String DEFAULT_MESSAGE_CODE = "default.acyclic.violation.message"
static final String NAME = "acyclic"
@artifact.package@import grails.test.*
import org.junit.*
import static org.junit.Assert.*
import static org.hamcrest.CoreMatchers.*
import static org.junit.matchers.JUnitMatchers.*
class @artifact.name@ {
@Before void setUp() {
}
class TagListEditor extends PropertyEditorSupport {
void setAsText(String text) {
value = text.split(/,\s*/).collect {
Tag.findByName(it) ?: new Tag(name: it)
} as Set
}
String getAsText() {
value?.name?.join(", ")
}
class TagListEditor extends PropertyEditorSupport {
void setAsText(String text) {
value = text.split(/,\s*/) as Set
}
String getAsText() {
value?.join(", ")
}
}
@robfletcher
robfletcher / DomainClassLookupPropertyEditor.groovy
Created February 26, 2010 13:25
PropertyEditor implementation used for binding to Grails domain objects by unique property value
import java.beans.PropertyEditorSupport
import org.apache.commons.lang.StringUtils
class DomainClassLookupPropertyEditor extends PropertyEditorSupport {
Class domainClass
String property
String getAsText() {
value."$property"