This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* HumanTime.java | |
* | |
* Created on 06.10.2008 | |
* | |
* Copyright (c) 2008 Johann Burkard (<mailto:[email protected]>) <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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Firebug script to set all checkboxs | |
ee = document.getElementsByTagName("input"); for(i=0;i<ee.length;i++){ ee[i].checked = true }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int numberOfColumns = row.getMetaData().getColumnCount(); | |
print "Columns:" | |
(1..numberOfColumns).each {n -> | |
print " $n:${row.getMetaData().getColumnName(n)}" | |
} | |
println('') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// input: someGroovyCodeToTakeCamelCaseAndMakeItNicer | |
// output: Some Groovy Code To Take Camel Case And Make It Nicer | |
def str = 'someGroovyCodeToTakeCamelCaseAndMakeItNicer'.collect { | |
(Character.isUpperCase(it as char)?' ':'') + it | |
}.join() | |
str = str[0].toUpperCase() + str[1..-1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Just cut/paste this into a GroovyConsole to evaluate. (last line is used for testing) | |
// input: MY_ENUM_NAME output: myEnumName | |
String enumToJava(String name){ | |
boolean lastUnder=false | |
name.collect { | |
if(it=='_') { | |
lastUnder = true; | |
return '' | |
} | |
def c = it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
assert getEnumName('getPoeHoeFoe') == 'POE_HOE_FOE' | |
String getEnumName(methodName){ | |
def str = methodName.collect { | |
(Character.isUpperCase(it as char)?'_':'') + it | |
}.join() | |
str = str[4..-1].toUpperCase() | |
} |
OlderNewer