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
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 / 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 / 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 / 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' : ''}">
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!');
View define-example.html
<a onclick="view.person.showPerson(); return false;">Show person</a>
<div id="person-div"></div>
View require-express-setup.js
app.all('/:controller/:action/:id?', function(req, res) {
require(['app/controller/' + req.params.controller], function(Controller) {
Controller[req.params.action](req, res);
app.all('/:controller', function(req, res) {
require(['app/controller/' + req.params.controller], function(Controller) {
Controller.index(req, res);
View requirejs-url-setup.js
UrlMappings.config.forEach(function(mapping) {
app[mapping.verb](mapping.route, function(req, res) {
require(['app/controller/' + mapping.controller], function(Controller) {
Controller[mapping.action](req, res);
View _test-dialog.gsp
<r:require module="test_dialog"/>
<div id="test-dialog" title="Test Dialog">
<div class="test-dialog-content">
This is a test.
View ApplicationResources.groovy
modules = {
application {
resource url:'js/application.js'
test_dialog {
dependsOn 'jquery, jquery-ui'
resource url:'css/testDialog.css'
resource url:'js/testDialog.js'
You can’t perform that action at this time.