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 […]

java

PhantomSQL 2.0

Posted on

Since the beginning of this project, I have learned many lessons. First of all the syntax of the language was to closely related to SQL, as this was the language that I wanted to mimic and fit into this framework. Main reason for that was that I wanted something familiar to the end user, I […]

Uncategorized

Random number between two values

Posted on

This is a small utility class that allows us to obtain a random number between two values that are uniformly distributed in the range of ‘low’ to ‘high’. This works for floats, doubles and integers. The inner working of this class are straight forward, our uniform(int, int) method uses the nextInt(int) method of Random class […]