Skip to content

Instantly share code, notes, and snippets.

John Urberg jurberg

Block or report user

Report or block jurberg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View define-example.html
<a onclick="view.person.showPerson(); return false;">Show person</a>
<div id="person-div"></div>
View define-example.js
define('view/person', ['domain/person', 'jQuery', 'window'], function(Person, $, Win) {
var person = Person.createPerson();
return {
showPerson: function() {
Win.alert('Person updated!');
jurberg / requirejs.gsp
Last active Dec 12, 2015
Use different Require.JS main when running in a war
View requirejs.gsp
<script src="js/lib/require-2.1.2.js"
data-main="js/bootstrap${grailsApplication.isWarDeployed() ? '-build' : ''}">
jurberg / requirejs.groovy
Last active Dec 12, 2015
Run the Require.JS optimizer when creating a war file.
View requirejs.groovy
eventCreateWarStart = { warName, stagingDir ->
def curDir = new File('Scripts');
ant.exec(outputproperty: "cmdOut", errorproperty: "cmdErr", resultproperty: "cmdExit", failonerror: "false", executable: "java") {
arg(line: "-cp ${new File(curDir, 'js.jar').absolutePath}")
arg(line: "")
arg(line: "${new File(curDir, 'r.js').absolutePath}")
arg(line: "-o")
arg(line: "name=bootstrap")
arg(line: "baseUrl=${stagingDir}/js")
arg(line: "out=${stagingDir}/js/bootstrap-build.js")
jurberg / eventWebXmlEnd.groovy
Created Jan 24, 2013
Adding a context-param to the beginning a Grails app web.xml
View eventWebXmlEnd.groovy
eventWebXmlEnd = { String tmpfile ->
def contextParam = '''<context-param>
<description>Spring Expression Language Support</description>
def root = new XmlParser().parse(webXmlFile)
root.children().add(0, new XmlParser().parseText(contextParam))
new XmlNodePrinter(new PrintWriter(new FileWriter(webXmlFile))).print(root)
jurberg / Jaxb-no-jxc.groovy
Created Dec 2, 2012
Generate JAXB classes without jaxb-jxc on your classpath
View Jaxb-no-jxc.groovy "") {
arg(value: "-d")
arg(value: "src/java")
arg(value: "-p")
arg(value: "")
arg(value: "etc/schema/books.xsd")
jurberg / GenerateSources.groovy
Created Nov 28, 2012
Groovy script to generate JAXB classes from an XSD
View GenerateSources.groovy
// Add the following to BuildConfig.groovy:
// build('com.sun.xml.bind:jaxb-xjc:2.1')
// build('com.sun.xml.bind:jaxb-impl:2.1')
target('generateSources': "Generate JAXB classes from a schema") {
def classpath = grailsSettings
Ant.taskdef(name: "xjc",
classname: "",
classpath: classpath)
jurberg / drop_constraints.sql
Created Nov 28, 2012
Drop all table constraints in Oracle
View drop_constraints.sql
-- Drop all table constraints:
(SELECT c.owner, c.table_name, c.constraint_name
FROM user_constraints c, user_tables t
WHERE c.table_name = t.table_name
AND c.status = 'ENABLED'
ORDER BY c.constraint_type DESC)
dbms_utility.exec_ddl_statement('alter table "' || c.owner || '"."' || c.table_name || '" disable constraint ' || c.constraint_name);
jurberg / XmlToFlatFileMapping.groovy
Created Nov 11, 2012
Convert XML to Flat File Mapping
View XmlToFlatFileMapping.groovy
def mapping = [[closure: { book.@id.text() }, length: 5],
[closure: {',')[0] }, length: 15],
[closure: {',')[1] }, length: 10]]
jurberg / XmlToFlatFileTest.groovy
Created Nov 11, 2012
Convert XML to Flat File Test
View XmlToFlatFileTest.groovy
def sep = System.getProperty('line.separator')
def expected =
"bk101Gambardella Matthew " + sep +
"bk102Ralls Kim " + sep +
"bk103Corets Eva " + sep
void testParsing() {
def books = new XmlSlurper().parseText(data)
assertEquals expected, xmlToFlatFile(books, 'book', mapping)
You can’t perform that action at this time.