Skip to content

Instantly share code, notes, and snippets.

@danhyun
danhyun / embedded_spock_tests.groovy
Created April 12, 2016 21:07 — forked from mostlylikeable/embedded_spock_tests.groovy
Programmatically run spock tests
package foo
@Grab('org.spockframework:spock-core:1.0-groovy-2.3')
import org.junit.runner.*
import spock.lang.Specification
import spock.util.EmbeddedSpecRunner
/*
@danhyun
danhyun / kimchi.adoc
Last active May 23, 2020 21:18
Kimchi Recipe
@danhyun
danhyun / snippet.kt
Created August 30, 2019 18:10
spring mock mvc rest assured please stop encoding my paths
RestAssuredMockMvc.requestSpecification = MockMvcRequestSpecBuilder()
.setMockHttpServletRequestBuilderInterceptor { b ->
b.with { r -> r.apply { requestURI = pathInfo } }
}.build()
@danhyun
danhyun / unpack.js
Created August 19, 2019 23:00
recursively unpack elastcisearch nested aggs
let unpack = (a) => Object.entries(a)
.filter(([key, value]) => value.buckets)
.flatMap(([key, value]) => value.buckets
.flatMap(b => {
let current = {
[key] : b.key,
doc_count: b.doc_count
}
let unpacked = unpack(b)
if (unpacked.length == 0) {
@danhyun
danhyun / Reader.java
Last active September 26, 2018 22:38
`Reader` and `TryReader` monads as demonstrated by Mario Fusco (@mariofusco) Devoxx 2015
public class Reader<R, A> {
private final Function<R, A> run;
public Reader(Function<R, A> run) { this.run = run; }
public <B> Reader<R, B> map(Function<A, B> f) {
return new Reader<>( r -> f.apply((apply(r))) );
}
public <B> Reader<R, B> flatMap(Function<A, Reader<R, B>> f) {
@danhyun
danhyun / .bashrc
Last active June 11, 2018 09:39
Configure `Dockermachine` and Windows to share folders
function mysqlUrl {
local ip=`docker-machine ip default`
local port=`docker inspect --format='{{(index (index .NetworkSettings.Ports "3306/tcp") 0).HostPort}}' mysql`
echo "$ip:$port"
}
@danhyun
danhyun / blockdiag.gradle
Last active November 28, 2017 19:36
gradle + docker + blockdiag
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.bmuschko:gradle-docker-plugin:3.2.1'
}
}
// use fully qualified class name
@danhyun
danhyun / paths.lua
Created November 6, 2015 16:53
Feed in a csv of host,path entries to wrk2
counter = 1
-- Initialize the pseudo random number generator - http://lua-users.org/wiki/MathLibraryTutorial
math.randomseed(os.time())
math.random(); math.random(); math.random()
function file_exists(file)
local f = io.open(file, "rb")
if f then f:close() end
return f ~= nil

Kombucha

1 gallon of tea

  1. Boil 1 gallon of water

  2. Let cool to roughly 130-170F before adding tea to avoid harsh bitterness

  3. Steep tea (i steep for like 30-40 minutes) (5 bags, 2 green 3 black)

  4. Stir in sugar and make sure it’s completely disolved (2 cups of sugar)

  5. Let sweetened tea cool down to a bit warmer than room temp

@danhyun
danhyun / bash
Created July 5, 2016 14:09
passing env and java opts to apps created via gradle's application plugin
$ env JAVA_OPTS="-Dratpack.port=8080" build/install/todo-backend-ratpack-java/bin/todo-backend-ratpack-java
2016-07-05 10:07:55,058 INFO r.s.RatpackServer [main] Starting server...
2016-07-05 10:07:55,785 INFO r.s.RatpackServer [main] Building registry...
2016-07-05 10:07:56,455 INFO c.z.h.HikariDataSource [main] HikariCP pool HikariPool-0 is starting.
2016-07-05 10:07:56,761 INFO r.s.RatpackServer [main] Initializing 1 services...
2016-07-05 10:07:57,176 INFO r.s.RatpackServer [main] Ratpack started for http://localhost:8080
$ env RATPACK_PORT=8080 build/install/todo-backend-ratpack-java/bin/todo-backend-ratpack-java
2016-07-05 10:08:30,856 INFO r.s.RatpackServer [main] Starting server...
2016-07-05 10:08:31,540 INFO r.s.RatpackServer [main] Building registry...