Skip to content

Instantly share code, notes, and snippets.

View rhyolight's full-sized avatar

Matthew Taylor rhyolight

View GitHub Profile
<gui:dataTable
id="${searchTableId}"
draggableColumns="true"
columnDefs="${columnDefinitions}"
controller="search" action="$action"
params="${searchURLParams}"
paginatorConfig="[
rowsPerPage: 10,
template : '{PreviousPageLink} {PageLinks} {NextPageLink} {CurrentPageReport}',
pageReportTemplate : '{totalRecords} total records'
@rhyolight
rhyolight / gist:142053
Created July 7, 2009 12:45
Config for a groovy script that transforms this into a btrace java source file
btrace {
templates {
// all methods within mydomain classes
methodTimerTemplate {
template = 'btrace-templates\\ManyMethodTimerTemplate.template'
targetClasses {
'/com\\\\.mydomain\\\\..+/' {
targetMethods = [ '/.+/' ]
}
}
@rhyolight
rhyolight / gist:142054
Created July 7, 2009 12:46
A groovy template for SimpleTemplateEngine that creates a btrace Java source file
import java.util.Map;
import static com.sun.btrace.BTraceUtils.*;
import com.sun.btrace.annotations.*;
@BTrace
public class ManyMethodTimerTemplate {
@TLS private static Map<String, Long> startTimes = newHashMap();
<% targetClasses.eachWithIndex { className, classData, classIndex -> %>
<% classData.targetMethods.eachWithIndex { targetMethod, methodIndex -> %>
def kleinFactory = new KleinFactory()
def kleins = []
while (kleinFactory.isAlive())
kleins << kleinFactory.createKlein()
function Rectangle(w,h) {
this.width = w;
this.height = h;
}
Rectangle.prototype.area = function() {
return this.width * this.height;
};
function PositionedRectangle(w,h,x,y) {
Rectangle.call(this, w, h);
// extends and inherits
function heir(p) {
function f() {}
f.prototype = p;
return new f();
}
// extending without inheriting
function mixin(from, to) {
var property;
for (property in from) {
if (!to.hasOwnProperty(property)) {
to[property] = from[property];
}
}
return to;
}
// Method 2: constructor returning an object literal with methods attached
function Rectangle2(w,h) {
var width = w, height = h;
return {
getWidth: function() { return width; },
getHeight: function() { return height; },
setWidth: function(w) { width = w; },
setHeight: function(h) { height = h; },
area: function() { return width * height }
};
function Rectangle(w,h) {
this.width = w;
this.height = h;
}
Rectangle.prototype.area = function() {
return this.width * this.height;
};
function heir(p) {
function f() {}
f.prototype = p;
return new f();
}
PositionedRectangle.prototype = heir(Rectangle.prototype);
PositionedRectangle.prototype.constructor = Rectangle;