Skip to content

Instantly share code, notes, and snippets.

View MichalAdorno's full-sized avatar
🎯
Synchronizing

Michal Z. MichalAdorno

🎯
Synchronizing
  • Distributed
View GitHub Profile
@jeffsheets
jeffsheets / AccountControllerTest.groovy
Created June 20, 2014 20:18
Spock test with Mocks of Spring MVC Rest Controller using standaloneSetup and mockMvc
import groovy.json.JsonSlurper
import org.springframework.test.web.servlet.MockMvc
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.http.HttpStatus.*
import spock.lang.Specification
/**
* A Spock Spring MVC Rest unit test that doesn't require a full spring context
*/
@dpryden
dpryden / ClassLoaderLeakExample.java
Created October 20, 2014 00:01
Example of a ClassLoader leak in Java
import java.io.IOException;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
/**
* Example demonstrating a ClassLoader leak.
*
* <p>To see it in action, copy this file to a temp directory somewhere,
@Rocketeer007
Rocketeer007 / pom.xml
Created March 12, 2017 13:37
Surefire, Failsafe and Jacoco configuration for build
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>default-prepare-agent</id>
@elizarov
elizarov / Main.kt
Created March 9, 2018 10:05
Kotlin Coroutines, a deeper look
// Inspired by http://akarnokd.blogspot.ru/2017/09/rxjava-vs-kotlin-coroutines-quick-look.html
// Requires Kotlin 1.2.30 or later
// Uses kotlinx.coroutines library
import kotlinx.coroutines.experimental.*
import kotlin.system.*
suspend fun f1(i: Int): Int {
println("f1 attempt $i")
delay(if (i != 3) 2000 else 200)
@zhunik
zhunik / docker-compose.yml
Created September 14, 2018 15:12
docker-compose Postgres health-check
version: "3"
services:
postgress:
....
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
app: