Skip to content

Instantly share code, notes, and snippets.

@tvinke
tvinke / error.gson
Created June 6, 2018 11:58
Rendering the Exception in a Grails JSON View
response.status 500
def e = request.getAttribute('javax.servlet.error.exception')
if (e instanceof Exception) {
// since its almost always an InvocationTargetException get actual cause
e = ((Exception)e.getCause())
}
// us JSON API support - see http://views.grails.org/latest/#_json_api_support
json jsonapi.render(e)
@tvinke
tvinke / JsonTable.groovy
Created April 18, 2018 14:57
Groovy script to output JSON from standard input as a table to the terminal (examples of CliBuilder, JsonSlurper and ANSI coloring)
// Small JSON printer
//
// Just feed some JSON to this script to display it in tabular form.
// Usage e.g.
// http api.example.com/users/1 Authorization:"..." | groovy JsonTable.groovy
//
// Limit amount of rows
// http api.example.com/users Authorization:"..." | groovy JsonTable.groovy -l 10
//
@tvinke
tvinke / GroovyAnsi.groovy
Created April 18, 2018 14:21
Simple ANSI colors in the terminal written in Groovy
// Ansi colors in Groovy
// Author: Ted Vinke
import static Ansi.*
println color("BOLD", Ansi.BOLD)
println color("ITALIC", Ansi.ITALIC)
println color("UNDERLINE", Ansi.UNDERLINE)
println color("BLINK", Ansi.BLINK)
println color("RAPID_BLINK", Ansi.RAPID_BLINK)
println color("REVERSE_VIDEO", Ansi.REVERSE_VIDEO)

Keybase proof

I hereby claim:

  • I am tvinke on github.
  • I am tvinke (https://keybase.io/tvinke) on keybase.
  • I have a public key whose fingerprint is 2C35 7D95 D5E4 2CC3 6604 891C FAEF 78C0 CD43 8C6B

To claim this, I am signing this object: