Skip to content

Instantly share code, notes, and snippets.

@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 / 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

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...
@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
/*
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]-->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 1.5.4-dev">
<meta name="author" content="Dan Hyun">
<title>Testing Ratpack Applications</title>
@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 / h4x.html
Last active December 29, 2015 18:57
hax.html
<script>
var CONST = {
terminalWidth: 72
};
var STYLE = {
terminal: 'font-family: monospace; background: black; color: green; font-size: 20px; padding-left: 25px; padding-top: 200px; padding-bottom: 200px;'
};
function frameRunner(frames) {
@danhyun
danhyun / build.gradle
Created December 3, 2015 17:08
jOOQ code gen from properties
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.postgresql:postgresql:9.4-1206-jdbc42'
classpath 'org.jooq:jooq-codegen:3.7.1'
classpath 'org.jyaml:jyaml:1.3'
}
}