Skip to content

Instantly share code, notes, and snippets.

View bherrmann7's full-sized avatar

Bob Herrmann bherrmann7

View GitHub Profile
// validate a schema using relagNG
// 1. download jing from http://code.google.com/p/jing-trang/
// 2. copy the jing.jar into $GROOVY_HOME/lib
// 3. now copy/paste this into the groovy console and have fun!!!
import com.thaiopensource.util.PropertyMapBuilder;
import com.thaiopensource.validate.*
import com.thaiopensource.validate.rng.CompactSchemaReader;
import com.thaiopensource.xml.sax.ErrorHandlerImpl;
import org.xml.sax.InputSource;
@bherrmann7
bherrmann7 / gist:208598
Created October 12, 2009 18:21
how to record some of what a closure does when it runs
// CriteriaRecorder - this gist lets you wrap a closure so you can record and manipulate the list of things the closure attempts to invoke.. Good for unit testing closures which build up GORM requests
class Node {
String name
def args
String render(StringBuilder sb, int level){
sb.append ' '.multiply(level*4)
sb.append name+'('+args.join(',')+')\n'
int numberOfColumns = row.getMetaData().getColumnCount();
print "Columns:"
(1..numberOfColumns).each {n ->
print " $n:${row.getMetaData().getColumnName(n)}"
}
println('')
package jbum.pdf;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
// Firebug script to set all checkboxs
ee = document.getElementsByTagName("input"); for(i=0;i<ee.length;i++){ ee[i].checked = true };
/*
* HumanTime.java
*
* Created on 06.10.2008
*
* Copyright (c) 2008 Johann Burkard (<mailto:jb@eaio.com>) <http://eaio.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
// Groovy script to dump the browser's headers
ServerSocket ss = new ServerSocket();
ss.bind(null)
println "listening on "+ss.getLocalPort();
Socket s = ss.accept()
s.getInputStream().eachLine { line ->
println line