Skip to content

Instantly share code, notes, and snippets.

@ambalashov
ambalashov / docker-cleanup-resources.md
Created June 7, 2017 10:47 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@ambalashov
ambalashov / FieldBenchmark.java
Created February 15, 2017 23:04 — forked from raphw/FieldBenchmark.java
Java MethodHandle and reflection benchmark
package benchmark;
import org.openjdk.jmh.annotations.*;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.concurrent.TimeUnit;
public class AcceptGzipEncodingFeignRequestInterceptor implements RequestInterceptor {
private static final String ACCEPT_ENCODING_HEADER = "Accept-Encoding";
private static final String GZIP_ENCODING = "gzip";
private static final String DEFLATE_ENCODING = "deflate";
@Override
public void apply(RequestTemplate template) {
@Bean
public Action<Chain> handlers(PersonRepository persons,
HotStream<Person> personStream,
ObjectMapper jsonMapper,
ModelMapper beanMapper) {
return (chain) -> {
chain.handler("person", ctx ->
ctx.byMethod(spec ->
spec
.get(c -> {
{
"title": "rtb_trace",
"services": {
"query": {
"list": {
"0": {
"query": "_type:rtb_trace",
"alias": "",
"color": "#7EB26D",
"id": 0,
@ambalashov
ambalashov / ProxyProblemExample.java
Last active September 13, 2015 08:31 — forked from thomasdarimont/ProxyProblemExample.java
Hack for allowing dedicated proxy settings to be used for URL with http and https protocol handling in JavaFXs Webkit based WebView. Tested with JDK8
package de.tutorials.training.fx.proxy;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
import java.net.InetSocketAddress;
@ambalashov
ambalashov / kafka.md
Last active August 29, 2015 14:26 — forked from ashrithr/kafka.md
kafka introduction

Introduction to Kafka

Kafka acts as a kind of write-ahead log (WAL) that records messages to a persistent store (disk) and allows subscribers to read and apply these changes to their own stores in a system appropriate time-frame.

Terminology:

  • Producers send messages to brokers
  • Consumers read messages from brokers
  • Messages are sent to a topic
@ambalashov
ambalashov / pr.md
Last active August 29, 2015 14:22 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

;; Datomic example code
(use '[datomic.api :only (db q) :as d])
;; ?answer binds a scalar
(q '[:find ?answer :in ?answer]
42)
;; of course you can bind more than one of anything
(q '[:find ?last ?first :in ?last ?first]
"Doe" "John")
@ambalashov
ambalashov / handle_SIGTERM_gignal.clj
Last active August 29, 2015 14:10
SIGTERM handle
(defn shut-down-hook []
;; Release resources etc.
)
(defn -main [& args]
(.addShutdownHook (Runtime/getRuntime)
(Thread. shut-down-hook)))