Skip to content

Instantly share code, notes, and snippets.

@bodiam
bodiam / file.adoc
Last active July 5, 2016 13:58
Output of ./gradlew bestbooks-export:dependencies
testCompileOnly - Compile dependencies for source set 'test'.
+--- project :bestbooks-core
|    +--- org.springframework.boot:spring-boot-starter-freemarker: FAILED
|    +--- org.springframework.boot:spring-boot-starter-web: FAILED
|    +--- org.springframework.boot:spring-boot-devtools: FAILED
|    +--- org.springframework.boot:spring-boot-starter-actuator: FAILED
|    +--- org.springframework.boot:spring-boot-starter-undertow: FAILED
|    +--- org.springframework.boot:spring-boot-starter-security: FAILED
|    +--- org.springframework.boot:spring-boot-starter-data-jpa: FAILED
@bodiam
bodiam / AsciiLite.groovy
Created April 19, 2016 13:50
AsciidoctorJ has a dependency on JRuby, which is quite a heavy library to download and load. This one is based on Groovy, and could easily be ported to Java, and while limited, does provide quite some functionality.
/**
* A very basic regex based parser for Asciidoc.
*
* Based on Slimdown (Markdown) parsers:
* - https://gist.github.com/jbroadway/2836900
* - https://gist.github.com/renehamburger/12f14a9bd9297394e5bd
* - https://gist.github.com/paulcuth/8967731
*
* @author Erik Pragt
*/
@bodiam
bodiam / healthcheck.groovy
Created May 25, 2015 20:16
A small script to check the health status of your Grails 3 and Spring Boot applications
#!/usr/bin/env groovy
import groovy.json.JsonSlurper
/**
* Displays the status of registered Spring Boot URL's.
* To register URL's, create a file called healthcheck.txt in the following format
*
* <name>,<url>
*
* Eg: healthcheck.txt:
@bodiam
bodiam / asciidoc.css
Last active August 29, 2015 14:19 — forked from imjasonh/markdown.css
Render HTML as unrendered Asciidoc - See http://jsbin.com/mifepiqosa/1/edit?html,css,output
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@bodiam
bodiam / benchmark.java
Created November 22, 2014 23:32
AsciiDoc benchmark for JDK 1.6 and JDK 1.8
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.io.FileReader;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException, ScriptException {
ScriptEngineManager manager = new ScriptEngineManager();
@Grab(group='org.gperfutils', module='gbench', version='0.4.2-groovy-2.1')
import java.lang.String
trait NoStackTrace {
Throwable fillInStackTrace() {
return this
}
}
class ExpensiveException extends RuntimeException { }
void "test filter with find on name"() {
setup:
new Conference(
name: 'test',
startdate: new Date()
).save(flush: true)
expect:
service.filterConferences(new FilterCommand(name: name)).size() == expected
@Grab(group = "org.twitter4j", module = "twitter4j-core", version = "4.0.2")
import twitter4j.*
Twitter twitter = new TwitterFactory().instance
def user = twitter.verifyCredentials()
println "Nb followers de ${user.name} (alias ${user.screenName}) : ${user.followersCount}"
long cursor = -1
def followers = twitter.getFollowersList(user.screenName, cursor, 200)
followers.each {println "${it.screenName} - ${it.name}"}
@bodiam
bodiam / NoStackTrace.groovy
Created July 29, 2014 20:46
Using a Groovy Trait to make exceptions usable for flow control.
@Grab(group='org.gperfutils', module='gbench', version='0.4.2-groovy-2.1')
import java.lang.String
trait NoStackTrace {
Throwable fillInStackTrace() {
return this
}
}
class ExpensiveException extends RuntimeException { }
@bodiam
bodiam / switch.sh
Created July 10, 2014 11:28
Switch Java version
export JAVA_HOME=$(/usr/libexec/java_home -v 1.6)