Skip to content

Instantly share code, notes, and snippets.

@yonatang
yonatang / Dockerfile
Last active August 29, 2015 14:12
docker - logstash
FROM dockerfile/java:oracle-java7
ENV KB_PKG_NAME kibana-4.0.0-beta3
RUN \
cd / && \
wget https://download.elasticsearch.org/kibana/kibana/$KB_PKG_NAME.tar.gz && \
tar xvzf $KB_PKG_NAME.tar.gz && \
rm -f $KB_PKG_NAME.tar.gz && \
mv /$KB_PKG_NAME /kibana
@yonatang
yonatang / SortedSetTest.java
Created April 8, 2015 07:37
Orika SortedSet test
package orika;
import ma.glasnost.orika.MapperFacade;
import ma.glasnost.orika.impl.DefaultMapperFactory;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.SortedSet;
import java.util.TreeSet;
var n = 4, // number of layers
m = 58, // number of samples per layer
stack = d3.layout.stack(),
layers = stack(d3.range(n).map(function() { return bumpLayer(m, .1); })),
yGroupMax = d3.max(layers, function(layer) { return d3.max(layer, function(d) { return d.y; }); }),
yStackMax = d3.max(layers, function(layer) { return d3.max(layer, function(d) { return d.y0 + d.y; }); });
var margin = {top: 40, right: 10, bottom: 20, left: 10},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
@yonatang
yonatang / prompt-to-localStorage.js
Created March 7, 2016 13:54
Prompt to LocalStorage in Javascript
var localStorageKey=prompt('Enter your key');
var localStorageValue = prompt('Enter your value');
localStorage[localStorageKey]=localStorageValue;
@yonatang
yonatang / graph1.json
Created June 15, 2016 18:32
simpsons paradox
[
{"xOrder":0,"x":"Women", "y0": 0.0, "y1": 0.3, "color":"#e377c2", "id":"0"},
{"xOrder":0,"x":"Women", "y0": 0.3, "y1": 1.0, "color":"#c7c7c7", "id":"1"},
{"xOrder":1,"x":"Men", "y0": 0.0, "y1":0.46, "color":"#1f77b4", "id":"2"},
{"xOrder":1,"x":"Men", "y0": 0.46, "y1": 1.0, "color":"#c7c7c7", "id":"3"}
]
@yonatang
yonatang / graph1.json
Created June 17, 2016 20:52
simpsons paradox
[
{"xOrder":0,"x":"Women", "y0": 0.0, "y1": 0.3, "color":"#e377c2", "id":"0"},
{"xOrder":0,"x":"Women", "y0": 0.3, "y1": 1.0, "color":"#c7c7c7", "id":"1"},
{"xOrder":1,"x":"Men", "y0": 0.0, "y1":0.46, "color":"#1f77b4", "id":"2"},
{"xOrder":1,"x":"Men", "y0": 0.46, "y1": 1.0, "color":"#c7c7c7", "id":"3"}
]
@yonatang
yonatang / Counter.java
Created June 17, 2017 18:43
Static counter in Java
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
public class Counter {
private final static ConcurrentHashMap<String, AtomicInteger> map=new ConcurrentHashMap<>();
public static int inc(String name){
return map.computeIfAbsent(name, x -> new AtomicInteger()).getAndIncrement();
}
@yonatang
yonatang / TestMain.java
Created March 14, 2020 05:46
resilience4j Iissue: llegalStateException: Required to bind 2 arguments, but only bound 1
import io.github.resilience4j.bulkhead.annotation.Bulkhead;
import io.github.resilience4j.bulkhead.annotation.Bulkhead.Type;
import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker;
import io.github.resilience4j.retry.annotation.Retry;
import io.github.resilience4j.timelimiter.annotation.TimeLimiter;
import java.util.Date;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.PostConstruct;
@yonatang
yonatang / Simulation.java
Created March 29, 2020 04:02
SickSimulation
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang.math.RandomUtils;
public class Simulation {
static int N = 8000000;
static int ROUNDS = 24;
@yonatang
yonatang / Demo.java
Last active March 10, 2023 18:13
Micrometer issue with prometheus
import io.micrometer.core.instrument.DistributionSummary;
import io.micrometer.prometheus.PrometheusConfig;
import io.micrometer.prometheus.PrometheusMeterRegistry;
public class Demo {
public static void main(String[] args) {
PrometheusMeterRegistry registry = new PrometheusMeterRegistry(
PrometheusConfig.DEFAULT
);