Skip to content

Instantly share code, notes, and snippets.

Avatar

Marcin Gryszko mgryszko

View GitHub Profile
@mgryszko
mgryszko / ParApplicativeTest.kt
Created May 30, 2020
Arrow ParApplicative mapN combining effects sequentially (unlike parMapN)
View ParApplicativeTest.kt
import arrow.fx.IO
import arrow.fx.extensions.io.concurrent.concurrent
import arrow.fx.extensions.io.concurrent.dispatchers
import arrow.fx.fix
import kotlin.test.Test
fun f1(): IO<String> = IO {
"f1 ${Thread.currentThread().name}"
}
@mgryszko
mgryszko / CaffeineRefreshableCacheTest.kt
Created Mar 26, 2020
Characterisation test of Caffeine refreshable cache
View CaffeineRefreshableCacheTest.kt
import com.github.benmanes.caffeine.cache.CacheLoader
import com.github.benmanes.caffeine.cache.Caffeine
import com.github.benmanes.caffeine.cache.Ticker
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicInteger
class CaffeineAsyncRefreshableCacheTest {
@Test
@mgryszko
mgryszko / dyson_jsonp_endpoint.js
Created Nov 30, 2015
Render conditionally JSON or JSONP in Dyson
View dyson_jsonp_endpoint.js
function renderJsonp(res, callback) {
res.append('Content-Type', 'application/javascript');
res.send(callback + '(' + JSON.stringify(res.body) + ');');
}
function renderJson(res) {
res.send(res.body);
}
function render(req, res) {
@mgryszko
mgryszko / ddd_practice.md
Created Sep 21, 2013
DDD practice - shipping
View ddd_practice.md

Use cases

Book new cargo

Shipping agent provides origin, destination and arrival deadline. Origin and destination as UN locode [1].

System assigns a unique tracking id. Tracking id should be unique and generated by the system.

Cargo is initially unrouted.

Route new cargo

You can’t perform that action at this time.