Generate ID from UUID

Posted on 2 CommentsPosted in java

This is a method to generate a long id in the positive space. There are few issues to consider with this method – UUID is 16 bytes / 128 bits – Long is 8 bytes / 64 bits This means that we will loose some information, if we don’t want to lose that we could […]

Configuring Java JDK on Ubuntu

Posted on Leave a commentPosted in Uncategorized

This is an easy way to configure java on a linux box, all this information is available online. First we need to obtain the build. sudo wget Extract from tar sudo tar xzvf jdk-7u75-linux-x64.gz Create symbolic link so we can later update the version sudo ln -s /opt/jdk1.7.0_75/ /opt/java we edit the /etc/profile and […]

Tokenizing/splitting string in c++

Posted on Leave a commentPosted in cpp, Uncategorized

This method uses strtok to tokeninze our string given a specific delimeter, results of that are put into supplied vector. There are few other ways we can do this but this one is straight forward. #include <iostream> #include <string> #include <string.h>   #include <memory> #include <stdlib.h> #include <stdio.h> #include <list> #include <vector>   using namespace […]

Calculating partial Hausdorff Distance

Posted on 1 CommentPosted in cpp

  struct Point { Point(int_t _x, int_t _y) : x(_x), y (_y) {   }   int_t x; int_t y; };     typedef std::list<Point*> points_t;   double euclideanDistance(const Point& lhs,const Point& rhs) { double p1 = std::pow((float)(rhs.x – lhs.x), 2); double p2 = std::pow((float)(rhs.y – lhs.y), 2); double vd = std::sqrt(p1 + p2);   […]