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
@Configuration | |
@EnableCaching | |
@ConditionalOnExpression("${spring.cacheable.cache}") | |
public class EhCacheConfiguration { | |
@Autowired | |
private net.sf.ehcache.CacheManager cacheManager; | |
@Bean(name = "cacheManager") | |
public CacheManager ehCacheCacheManager() |
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
public class Memoizer { | |
public static class MemoizeFunction<T, R> implements Function<T, R> { | |
private final Map<List, R> cache = new HashMap<>(); | |
private final Function<T, R> function; | |
public MemoizeFunction(Function<T, R> function) { | |
Objects.requireNonNull(function); | |
this.function = function; |
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
import java.util.Arrays; | |
import java.util.List; | |
public class TestHelper { | |
public static Throwable shouldFail(Runnable code) { | |
try { | |
code.run(); | |
} catch (Throwable ex) { | |
return ex; |
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
Benchmark Mode Thr Count Sec Mean Mean error Units | |
g.j.Benchmark.complexTestBoon thrpt 1 20 1 16050.900 232.105 ops/s | |
g.j.Benchmark.complexTestGroovy thrpt 1 20 1 1132.776 29.978 ops/s | |
g.j.Benchmark.complexTestGson thrpt 1 20 1 6149.003 111.183 ops/s | |
g.j.Benchmark.complexTestJackson thrpt 1 20 1 15056.591 307.194 ops/s | |
g.j.Benchmark.complexTestNewGroovy thrpt 1 20 1 12886.050 113.192 ops/s | |
g.j.Benchmark.javaObjectsTestGroovy thrpt 1 20 1 18.706 0.207 ops/s | |
g.j.Benchmark.javaObjectsTestGson thrpt 1 20 1 188.108 3.821 ops/s | |
g.j.Benchmark.javaObjectsTestJackson thrpt 1 20 1 353.901 5.103 ops/s |
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
// convert a method name to a variable name (remove ‘get’ and uncapitalize) | |
def toVariableName = { String methodName -> | |
if (!methodName || !methodName.startsWith('get')) return methodName | |
def variableName = methodName - 'get' | |
return "" + Character.toLowerCase(variableName.charAt(0)) + variableName.substring(1); | |
} | |
// some closure shared variables | |
def x = 42 |
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
Result : 567399.330 ?(99.9%) 4926.983 ops/s | |
Statistics: (min, avg, max) = (555682.417, 567399.330, 576296.450), stdev = 6156.507 | |
Confidence interval (99.9%): [562472.347, 572326.313] | |
Benchmark Mode Thr Count Sec Mean Mean error Units | |
g.j.Benchmark.characterJsonParserGroovy thrpt 1 20 1 567399.330 4926.983 ops/s | |
g.j.Benchmark.fastJsonParserGroovy thrpt 1 20 1 584611.082 18457.878 ops/s | |
g.j.Benchmark.parserGson thrpt 1 20 1 271117.797 6513.312 ops/s | |
g.j.Benchmark.parserJackson thrpt 1 20 1 243472.297 1353.115 ops/s |
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
/** | |
* Enables code completion for Geb inside Cucumber step implementations. | |
*/ | |
def forwardedMethods = ["go", "to", "via", "at", | |
"waitFor", | |
"withAlert", "withNoAlert", "withConfirm", "withNoConfirm", | |
"download", "downloadStream", "downloadText", "downloadBytes", "downloadContent", | |
"report", "reportGroup", "cleanReportGroupDir"] | |
def scriptContext = context(filetypes: ['.groovy'], pathRegexp: ".*/test/cucumber/.*", scope: closureScope()) |
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
(ns clj-wp-import.core | |
(:require [clojure.java.io :as jio] | |
[clojure.string :as str])) | |
(defn post-files | |
[f] | |
(file-seq (jio/file f))) | |
(defn remove-pre-code | |
[txt] |
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
def factorial | |
factorial = { n, c -> | |
if (n == 1) | |
c(1) | |
else | |
factorial(n - 1, { m -> c(n * m) }) | |
} | |
def result = null | |
factorial(4, { x -> result = x }) |
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
@BeforeClass void setup() { | |
SwingUtilities.metaClass.static.invokeLater = { Runnable runnable -> | |
runnable.run() | |
} | |
Thread.metaClass.static.start = { Runnable runnable -> | |
runnable.run() | |
} | |
} |
NewerOlder