Uncategorized

RabittMQ RPC Request/Response example

Posted on

RabittMQ RPC Request/Response example using hoplin.io library Following example creates RPC client and then setups Async response handler, which follows by the request to get processed. Hoplin client supports both Direct-Reply and Queue per Request/Response patterns. This is the binding that is used to create our client.

development

Extended GIT Information in bash PS1

Posted on

Extended GIT Information in bash PS1 This will generate shell similar to this : Multiline version: ┌──┤ greg: ~/dev/discovery/discovery-agent │ master ≡ !1 +2 -2 ≡ 2 weeks ago └── λ Format `branch ≡ changes additions deletions ≡ last commit` Example `master ≡ !1 +2 -2 ≡ 2 weeks ago` Since we are interested in […]

Uncategorized

Hamming distance calculation

Posted on

This is a small snippet of how to calculate hamming distance in cpp with small bit of assembly for doing a population count. Code typedef unsigned long long hash_t;   #include <iostream> #include <bitset>   int popcount64(const hash_t& val) noexcept { int ret; __asm__ ("popcnt %1, %1" : "=r" (ret) : "0" (val)); return ret; […]

Uncategorized

Histogram Comparison for Image Analysis

Posted on

DRAFT This is the first article in the series on Image Comparison using Local Binary Patterns. Complete code is on github lbp-matcher We will start off by looking at different methods of comparing histograms. Histogram Intersection Log Likehood Chi Squared Kullback Leibler Divergence All our operations will be performed on 8bpp(bits per pixel) images anything […]

cpp

Overloading by return value in C++

Posted on

Here we have a method that allows us to determine return parameter type using templates and operator overloading in C++. This is something that I needed for a project that I am working on where a method call would give me the expected type based on the return type. Usage There is two way of […]

Uncategorized

Kryo (missing no-arg constructor): java.nio.HeapByteBuffer

Posted on

While serializing ByteBuffer using Kryo we will run into the following issue. Class cannot be created (missing no-arg constructor): java.nio.HeapByteBuffer To fix this we can create a custom serializer that will take a ByteBuffer and serialize it to and from Kryo. Serializer is rather simple all we need is two pieces of data, length of […]

Uncategorized

Exponential backoff

Posted on

In a variety of computer networks, binary exponential backoff or truncated binary exponential backoff refers to an algorithm used to space out repeated retransmissions of the same block of data, often as part of network congestion avoidance. Wikipedia Exponential backoff Here is an implementation in Java /** * Calculate Exponential backoff * * @param attempt […]