Archive for the ‘Uncategorized’ Category

Bit Operations

January 29, 2018



Square Brackets – SPOJ

September 24, 2017

Given n integers and k values <= 2n. Find the number of proper bracket expressions (proper starting and ending brackets) with “[” enforced in each p[k] positions. (more…)

Matching or stable marriage problem

April 28, 2016

Stable marriage problem or stable matching problem is a popular algorithm to match two set of entities where both have preferences over the other set. Elements of a set give ratings or state their choices from the other set. The problem is to find better match (if not best). Here is a java implementation of the algorithm (in a modified form, where one set prioritizes elements from another set, but another set does not have any say on how they get prioritized).


Looking at STS log for Spring MVC Project

April 6, 2016

STS comes with several tools. In this post, I am going try to explain how to look into the activities of a basic Spring Web MVC project created by STS.


JADE Agent Communication

March 4, 2016


JADE is also known as Java agent development framework. It can be used to pass messages using agents which supports distributed communication. To read about jade and work with tutorial visit In this tutorial, I will try to show code for agent communication. For any type of communication to happen, you need a listener (receiver) and sender of the message. In jade we spawn the listener agent first and then multiple sender’s (with their own identity) can send message to the listener agent. In a real world application the listener could be used to trigger different events in your application.

In one of my group projects (Nyx, intrusion detection system), we used it as sensor agent (sense intrusion in network captured packets and alert), monitor agent (which listens for any message from sensor) and response agent (that does the action like alert, send email and so on).


Create opengl glfw3 project in Code::Blocks

July 2, 2015


In this tutorial, I will explain the process needed to create a project in Code::Blocks (1.1), using glfw3 (2.5) and mingw (tdm64-gcc-


Write a simple jini application

November 20, 2014


In this tutorial, I plan to show how to write a very simple jini application. This tutorial uses code from Chapter 9 of Jan Newmarch‘s website. For this tutorial you will create 4 files. You can download the source code from this link. If you want a more comprehensive example, you can view the source code for this project (medical_report_system-final).

  1. is an interface that has two very simple methods (to send hello message and to receive hello message).
  2. implements these methods, and are hosted on server side. Client interact with this class through the HelloIntf interface.
  3. HelloServer is our service provider. It registers itself with the lookup service, and sends the object of the interface to this lookup service, when it is requested (In other words Server knows about HelloImpl).
  4. HelloClient is our client. It uses the HelloIntf  interface methods to send and receive messages from the service provider (our server) using the lookup service. It knows nothing about the implementation. Client however needs a proxy object (which in our case is just a jar created using interface). This proxy object is provided during our implementation through a webserver which we host using a tool that comes with jini.

Whenever we transfer message using RMI it has to implement interface. Also the methods throw RemoteException. Therefore, during implementation in both HelloServer and HelloClient we need to catch RemoteException while implementing or calling these methods.


Running a simple jini example

November 10, 2014


Since JINI is an old technology and if your code does not work, help that you get from the web can be little confusing (including mine :). JINI has changed to Apache River. There can be lots of disparity in articles between the old and the new versions. I hope Jini gets further development and more focus, because it is an amazing technology. If you are unfamiliar with JINI read this article. For this tutorial, I will be using the clock example from Jan Newmarch’s Guide to Jini Technologies. I hope this will help you explore more about JINI.


PDF extraction using Java

December 5, 2012

There are some command line tools e.g “pdftotext” that command comes handy whenever we want to extract text from a PDF file. After the text is extracted we can apply some parsers and filters to get whatever information we need.

When I am working in java environment I find this method not work as I wanted. I could however start a new process, perform the text extraction using above process, read the file and come back to java. That requires a lot of context switch and is an inefficient method. The biggest problem of this is, when do we decide to return from the process it created as a separate thread. Well there are techniques where we can come back from the process with text we parsed, but using external process that needs to return something in a synchronous way is inefficient. Using external methods becomes most useful when you don’t have as efficient method in your programming language of choice or when the external process is independent of current task. E.g One case I would recommend is image conversion using ImageMagick.


Automate Spring MVC Project

November 23, 2012


There are times, when you want to try out small things, but which requires a full fledged development environment, without the overwhelming details of the project. You just want the minimal project where you can try out small examples, before you can integrate it in the main project. The danger of even using a copy of a big project to try out small things, can sometimes be very complex. You can easily get off track and be confused on where did you made the changes (don’t count svn diff on this).