Skip to content

On Cloud [0-9]

January 7, 2016


Pretty much excited to start a not for profit activity which would be helpful to everyone !!!

There are certain things which will give you satisfaction to the core and i believe we got this idea while driving [?] (Thanks to the Bangalore traffic – Don’t blame the Bangalore traffic, we don’t know,  it can spark the next big idea)

Stay tuned for the updates.


Picture Courtesy –

Labour Laws in India

January 2, 2016

To understand the Labour Laws in India one has to go through (The given list is incomplete)

  • Industrial Disputes Act, 1947
  • Trade Unions Act, 1926
  • Workmen’s Compensation Act, 1923
  • Factories Act, 1948
  • Minimum Wages Act, 1948
  • Employees State Insurance Act, 1948
  • Payment of Wages Act, 1965
  • Payment of Bonus Act, 1965
  • Payment of Gratuity Act, 1972
  • Maternity Benefit Act, 1961
  • Industrial Employment (Standing Orders) Act, 1946
  • Employees Provident Fund and Miscellaneous Provisions Act, 1952
  • Mines Act, 1952
  • Equal Remuneration Act, 1976
  • Employers Liability Act, 1938
  • Apprentices Act, 1961
  • Child Labour (Prohibition and Regulation) Act, 1986

The are other specific acts for Beedi Workers, Cine Workers, Building & Construction workers, Plantation Labours, Journalists / Newspaper Employees etc.,

The amount of thought and the work which has gone inside framing all these is mind boggling!



Map – Java, Scala, Ruby

December 25, 2015

names =

startTime =

(0..200000).each do |i|
#puts “adding #{i} to the list.”
# pushes the i variable on the *end* of the list
names[i] = “Jagan”+i.to_s

names.each_pair {|key,value| puts “#{key} = #{value}”}
endTime =

p startTime
p endTime



package com.jasokan.test;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;

public class TestMap {

public static void main(String[] args) {
Map<Integer, String> nameMap = new HashMap<Integer, String>();

Calendar startTime = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(“HH:mm:ss”);

for (int i = 0; i < 200000; i++) {
nameMap.put(new Integer(i), “Jagan” + i);

for (Integer name : nameMap.keySet()) {

String key = name.toString();
String value = nameMap.get(name).toString();
System.out.println(key + ” ” + value);


Calendar endTime = Calendar.getInstance();




import java.util.Calendar

object TestMap {
def main(args: Array[String]) {

var names: Map[Int, String] = Map()

val startTime = Calendar.getInstance().getTime()

for (i <- 1 to 200000) {
names += (i -> (“Jagan” + i.toString()));

names.keys.foreach { i =>
print(“Key = ” + i)
println(” Value = ” + names(i))

val endTime = Calendar.getInstance().getTime()



Run the programs to get the time taken :)

But an interesting problem to observe

Please watch the Creation and printing of Map in Scala!




Concurrent calls to an API using Ruby

December 18, 2015

Got an interesting problem

  1. We need to read a csv file in chunks
  2. Process the chunk of data (transformation)
  3. Once the data is transformed, call the URLs concurrently

This is to avoid the sequential operation. For example, you have a REST API by which you update the address of the employees.

The addresses are going to be different and their details as well (employee id and others)

The bottleneck will be the database which can be handled by throttling the count of concurrent calls.

There are two gems which came handy to solve this problem

  1. Typhoeus
  2. Smarter CSV

Code sample

Reading the csv file in chunks

options = {:chunk_size => 30}
n = SmarterCSV.process(file_name, options) do |chunk|
process(chunk, otherArguments)

Creating the chunk requests

def process(chunk,otherArguments)
urlArray =
chunk.each do |row|
request_body_map = {
:test => row[:test]
urlArray << row[:test].to_s + request_body_map.to_json
callConcurrent(urlArray, url)

Calling the requests Concurrently

def callConcurrent(requestDetails, url)
bodyString = “”
hydra =
requestDetails.each do|website|
request =
method: :put,
body: bodyString
request.on_complete do |response|
p request + ” === ” + response.code.to_s;


There is a significant improvement in processing the data. Identify the load and tweak the chunk count and you will be able to achieve better performance.


Creating Capped Collections using Ruby – Sample Program

August 18, 2015

require ‘mongo’


client =[ ‘<hostname/ip>:<port>’ ],:database => ‘<databasename>’, :user => ‘<username>’, :password =>'<passwprd>’)

collection_name = {

“COLLECTION1” => 1610612736,
“COLLECTION2” => 1610612736 #SIZE in bytes (Here it is 1.5G)

collection_name.each do |collectionValue|
collectionDetail = client[collectionValue[0], :capped => true, :size =>collectionValue[1]]



Running Scala

February 23, 2015

As mentioned earlier, using the Scala – IDE for running the program. But how we can run it from the command line was the question and using the following steps, one can run their Scala program. Please note, the following sequence needs Scala-IDE! In the following example, i’m casbah for MongoDB!

Following is the package structure of the firstTrial project.


Click on the export in the File menu and following window will be displayed



Use the jar file and set the classpath.

Set classpath=h:\mongo-java-driver-2.13.0.jar;h:\slf4j-api-1.7.10.jar;h:\slf4j-log4j12-1.7.10.jar;h:\log4j-1.2.17.jar;h:\log4j-core-2.1.jar;h:\scala-library-2.11.5.jar;h:\json4s-core_2.11-3.2.11.jar;h:\paranamer-2.5.6.jar;h:\json4s-native_2.11-3.2.11.jar;h:\casbah-commons_2.11-2.8.0.jar;h:\casbah-core_2.11-2.8.0.jar;h:\casbah-gridfs_2.11-2.8.0.jar;h:\casbah-query_2.11-2.8.0.jar;C:\Users\Jagannathan\Downloads\scala-library.jar;C:\Users\Jagannathan\Desktop\firstTrial.jar;%CLASSPATH%;.

Run the program as

Java com.jagan.myscala.package

You will get the output!

Will write more details in the next post.

The roads

February 12, 2015

This is a nostalgic post due to the amount of time which took to phrase it.

Off late, there are several things which are debated on the web.

The basics of being successful in India is difficult as you have to be a successful

  • Son
  • Father
  • Husband
  • Brother
  • Coder
  • Worker and others

According to everyone their perspective is always correct. No one can understand what is the essential part of winning over other’s confidence. India is a country where there are several beliefs. You have your own Religion, Region, State, County and others. Added to these, there are several family beliefs.

So, there is no right or wrong and the action taken during that situation is correct according to that person. Everyone can point fingers, but not taking decision is also a wrong decision. So, please decrypt yourselves :)

Empathy – This word is very much needed to be successful for every human being. What is Empathy?

Empathy is the capacity to understand what another person is experiencing from within the other person’s frame of reference, ie, the capacity to place oneself in another’s shoes.

This needs good amount of maturity. This is where an adult differs from a Kid. I can cite so many instances where i had the experience of convincing my kids. Both will be adamant to have an Icecream. They cannot think about us on the aftermath of having an icecream when you have cold.

Follow me and let’s go denotes the same. That is the difference the empathy creates. A single hand cannot create sound.

Recently read a message in facebook and i like it. Team work is not group of people who work together. It is a group of people who trust each other. This is one of the well written statement!

All we are talking about is about our perspectives. There is GenX and GenY. God only know how these cyber-era kids are going to be. The meaning of life is different for them. Let me take an example, most of the people who started working after 2K would have seen a computer during the school final. But in today’s world, they are seeing the computer as soon as they are born!

The situations are going to be different everyday and the business and the perception changes as the day progresses.

If you feel, this is abstract, i wanted to be in this way. Drop a mail to for further debates :)


Get every new post delivered to your Inbox.