Pages

Wednesday, December 17, 2014

This is a random post

This post - is more of a compulsion. It has been a while I did not update my blog even after promising myself to do so. Recently one of my friend Amit reminded me that I have a blog and he would like to have it updated by me frequently. He himself runs a blog www.ultimateinversion.com posted some cool posts like Google Tricks and Lucid Chart Google Drive.   I really don't have anything specific to share at this point but I decided to go ahead and post. Hence its a kind of compulsion for me. I have been active in the social networking sites and micro-blogging sites lately and posting all interesting stuff that I come across there. I will probably put some of them here. Therefore this post is not only going to be random but also there would be some randomness among the sentences as well. I learned from my friend and writer Kunal - when you can't organize your text, just do bullets. And I am going to do so now.

Shazam Lyrics Sync
  • I discovered Shazam app not only recognizes any song that is playing within seconds but also it syncs the lyrics of the playing song. Its amazing. Now you can walk up to any bar and pretend to know all the lyrics of the song that is being played :) In fact it could highlight the talks during a concert show recording. What amazes me is that their are so many variants of the song and the matching window is so small that sometimes it is a part of multiple repeats, still it figures out the current block of lyrics and highlights.
  • Lately I have been seeing a lot of my Facebook friends posting their travel photos in Facebook and look happiest of their all time in their lives. May be I am jealous ? But i personally don't like to post a lot of photos in Facebook , at least I would probably like to post it to very close friends or share by email. Anyway good for them but I came across this video . The bottom line is I don't really care about their family photos who are just acquaintance to me . Also therse days there has been a trend of posting restaurant food pictures on Facebook. What they are eating is never interesting to me. May be its just part of the expenses they are recovering by sharing the photos with everyone on Facebok.


if Andromeda galaxy was brighter.

  • This is our neighbor Andromeda Galaxy if it were brighter. A lot of us start looking for a tiny patch in the sky when hear the word galaxy. Some of them are really big but just faint enough to require a telescope and long exposure. Rosette Nebula is another such object which is 3 times wider than moon. (Via Reditt)
  • Participated in Devthon where the city hackers got together to help Cyberabad Police in Hdyerabad . All thanks to Harish Krishnan and Prashant Venkatasubban for providing such an one of its kind platform , that was hard to imagine few years ago. It was amazing to see how the Cyberabad police department came out to help us to help them to ultimately help us. Also I could see so many bright young engineers and product designers who would probably even reject offers from the Googles and Facebooks to do something on their own. Being raised in a police officer's family it was privilege to be involved with this and encourage you to subscribe to Devthon if this excites you.
  •  
     

Wednesday, November 5, 2014

Finally DSLR meets Telescope

After prolonged resistance for buying a DSLR, I finally got a Canon EOS 600D it. The main reason was not probably photography. I have done enough photography using my point and shoot camera Sony CyberShot HX9V. It not only had a decent zoom of 16x but also very portable enough to carry in a jeans pocket. The reason why avoided was that it itself is a luggage when you travel. Secondly I was afraid of tuning into yet another IT employee claiming/wannabe professional photographer for whom a Photoshopped stray dog picture from DSLR becomes "Wile Life Photography".

Anyway I had to buy an DSLR someday to connect my telescopes to it and get some long exposure. I have done afocal photography earlier by keeping the point and shoot camera in front of the eyepiece but one can not get a long exposure in the method unless you use another tripod and OK with trails.

The preparation began when I went to USA last time where I got a telescope motor which can keep my alt-azimuth mount moving and cancelling effect of earth's rotation. I also bought a T-ring and adapter , one end of which can screw into a DSLR body and other end can go into the eyepiece holder of the telescope. All these things are not easily available in India.

Finally since it was winter I went for a DSLR and there was a couple of reason for looking into only Canon. Firstly the T-ring adapter thread was canon EOS comparable. Secondly most of my friends had Canon EOS , so I could exchange gears with them. Otherwise Nikon D5200 seemed to be a good deal in that price. Even the mirror less cameras like EOS M are really handy.

Here are the picture I shot last week after hooking up the DLSR body on to my telescope. Looks like I have to focus more precisely using the telescope knob after digitally zooming in the live view.




Notice the sound of the motor stops somewhere in the midway and the moon slowly starts to get out of the field of view.

In the coming days as I get more clear skies, I will try to capture the constellations and  brighter deep sky objects.

Monday, October 27, 2014

Thursday, October 9, 2014

My name sent to mars



When I saw last 240,543 forms had been submitted for boarding passes. Get yours here. Last Day to Register: Oct. 31, 2014

Tuesday, August 26, 2014

Load Testing Using Gatling

Gatling is an open source load testing framework based on Scala programming language. One of the advantage of Gatling over other load testing framework that I have used is that the code is very elegant and readable, thanks to its own DSL. One may not have prior knowledge of Scala to get started with Gatling. There are some documentation in the Gatling website which will help you write simple HTTP calls to your webservices but it gets bit difficult to incorporate the exact scenario of your test case because there are not much variety of example code which you can quickly edit and use. In this article I will try to show most of the structural construct that are frequently used while making a series of dependent web-service calls, typically used by a mobile game client while interacting with the game server.

Setup instructions are well described in the getting started tutorial. Following scala code will make a POST request to a mock REST endpoint that I have created using mockable.io.

Simple Request



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21


package package1

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
import io.gatling.jsonpath._

class Test1 extends Simulation {

  val httpConf = http
    .baseURL("http://demo1263864.mockable.io/") 
    .acceptHeader("application/json") 

  val scn = scenario("Simple scenario")
    .exec(http("First Request")
      .post("gatling")
      .body("""{"data":1}""")
      .headers(headers_1).check(jsonPath("$.result").is("SUCCESS")))

  setUp(scn.inject(atOnceUsers(1)).protocols(httpConf))
}


Above code just sends following request
POST http://demo1263864.mockable.io/gatling
with request body as
{"data":1}
I have kept the request body very simple as it does not have any effect. My REST services always responds with a fixed response, that is


1
2
3
4
5
6
7
8


{
  "result": "SUCCESS",
  "data": [
    {
      "score": 200
    }
  ]
}



Note that jsonPath("$.result") fetches the top level JSON attributes and checks if it's value is "RESULT", otherwise it shows as one failure ("KO") in the final report. We could also check the HTTL status using .check(status.is(200))) . More about check().

Custom Headers and Body


1


  val headers_1 = scala.collection.mutable.Map("Content-Type" -> "application/json")


Notice that I have used a mutable map to initialize the header and later converted to a Map (immutable) because sometimes output of one requests might have to be input in the second request as part of request header or body. e.g.


1
2
3
4
5
6


  val scn = scenario("Simple scenario")
    .exec(http("First Request")
      .get("gatling").headers(headers_1.toMap)
      .check(jsonPath("$.result").is("SUCCESS"), jsonPath("$.data[0].score").saveAs("score")))
    .exec(http("Second Request").post("gatling1").headers((headers_1 += "score" -> "${score}").toMap)
      .body(StringBody("""{"data":"${score}"}""")).check(status.is(200)))



In this case the attribute "score" is fetched from the output of the first request and then fed to the header and body of the second request. .saveAs("score") saves the value of score in the session with key "score" and makes it available to be fetched later. The session separate for all users that are injected by the setup(). So all user specific data which does not need to be shared across users should be saved in the session. "${score}" is an EL expression used for retrieving the value saved earlier in the session. More about session.

Looping

Let's say our output JSON array is as follows , which contains an array which we need to loop over.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17


{
  "result": "SUCCESS",
  "data": [
    {
      "playerId": 1,
      "score": 200
    },
    {
      "playerId": 2,
      "score": 300
    },
    {
      "playerId": 3,
      "score": 400
    }
  ]
}


Our code to consume it and iterate over all the player/score entry would be


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12


  val scn = scenario("Simple scenario")
    .exec(http("First Request")
      .get("gatling")
      .headers(headers_1.toMap)
      .check(jsonPath("$.result").is("SUCCESS"), jsonPath("$.data[*]").ofType[Map[String, Any]].findAll.saveAs("pList")))
    .foreach("${pList}", "player") {
      exec(session => {
        val playerMap = session("player").as[Map[String, Any]]
        val playerId = playerMap("playerId")
        session.set("playerId", playerId)
      })
    }



In above code snippet we are looping over a JSON array which output of the earlier request. pList stores the all the entries in the JSON array temporarily in the session and then .foreach block loops over it feeding one at a time with the session key "player". In this loop at the end we save the required value with session.set method. Since session is immutable all the session manipulation code wrapped around a session function as above.

Notice that "$.data[*]" is jsonPath expression to get hold of all the elements of the array attribute "data". More about jsonPath expressions.


We can also use a counter to loop over a list and fetch corresponding element from another list when more than one list is saved in the session. This is useful when the JSON structure is nested. Refer the following JSON structure.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12


{
  "result": "SUCCESS",
  "data": [
    {
      "playerId": {
        "id": 2,
        "version": 1
      },
      "score": 200
    }
  ]
}




 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17


  val scn = scenario("Simple scenario")
    .exec(http("First Request")
      .get("gatling")
      .headers(headers_1.toMap)
      .check(jsonPath("$.result").is("SUCCESS"),
        jsonPath("$.data[*].playerId.id").findAll.dontValidate.saveAs("ids"), jsonPath("$.data[*].playerId.version").findAll.dontValidate.saveAs("versions")))
    .exec(session => {
      val ids = session("ids").as[Vector[String]]
      val versions = session("versions").as[Vector[String]]
      val validIds = new ListBuffer[String]()
      ids.indices.foreach { i =>
        if (versions(i) == "0") {
          validIds += opptetrisIds(i)
        }
      }
      session.set("validIds", validIds.toList)
    })


In above code we save both the Ids and corresponding versions in separate list and then loop over the ids. We create a new list of IDs for which the corresponding version is 0. Finally we save the filtered Ids for further processing.

Flow branching


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


  //Global Users
  val userMap = scala.collection.concurrent.TrieMap[String, String]()
  //Randomiser 
  val rnd = new scala.util.Random


  val headers_1 = scala.collection.mutable.Map("Content-Type" -> "application/json")

  val scn = scenario("Simple scenario")
  exec(session => {
    var newUser = (rnd.nextInt(10) > 8 || userMap.size < 1)
    session.set("newUser", newUser)
  })
    .doIfOrElse(session => session("newUser").as[Boolean]) {
      exec(
        http("If request")
          .post("gatling")
          .headers(headers_1.toMap)
          .body(StringBody("""{}""")).asJSON
          .check(status.is(200)))
    } {
      exec(session => {
        val index = rnd.nextInt(userMap.size)
        val userArray = userMap.toArray.map(x => Array(x._1, x._2))

        session.set("id", userArray(index)(0))
          .set("version", userArray(index)(1))
      })
        .exec(http("Else Users")
          .post("gatling")
          .headers(headers_1.toMap)
          .body(StringBody("""{"id":"${id}, "version":"${version}"}""")).asJSON
          )
    }




In the above code we maintain a global map. Let's assume we need a pool users who will be making requests to the server and we also need the user to be an existing user sometimes and a brand new users otherwise. Say 2 in 10 users should be new and rest should be taken from the existing pool. We maintain a global userMap where we store all the newly created users and we refer the same map to fetch existing users. The global map is visible to all the threads so its not specific to any session.

Finally the load test plan is the most important part of the whole activity where you should be able to control the arrival of the users. e.g. if you want 10 users to arrive in uniform rate over the span of 30 seconds following should be your injection code.


1
2


  setUp(
    scn.inject(rampUsers(10) over (30 seconds)).protocols(httpConf)))


There are several other ways to create the desired pattern in this tutorial.

References

Sunday, July 20, 2014

Its all over ! - FIFA 2014

The FIFA world cup was pretty much over when German Mario Goetze received the ball on his chest and kicked it inside the Argentine goal post. The world cup season of 1998, 2002 , 2006 and 2010 have been special (be it good or bad) for me , not sure what was special personally this time but I followed almost every match this time.

In India Sony SIX broadcasted this event but it started with a very disappointing manner given the fact that John Abraham was in the analyst panel in first few matches. He had done some great movies but no way qualified to be there. Actors should be called to these event only if they paid a lot to do their film promotion :).

Apart from cable TV the XBMC plugin Sports Devil played a very important role in live streaming the matches. Both ESPN and BBC 5 Live were airing the audio commentary which was a live saver when were driving during matches.

Friday, July 18, 2014

Media features

To kill the daily commute time in city traffic I listen to couple of podcasts. While Indicast is release once a month on an average, BBC World Update : Daily commute is published everyday with news summery everyday.

Last week I sent an audio captured in my village to BBC and featured it in their "World Update" program which is hosted by Dan Damon. You can listen to the episode, you can seek to 40 mins.
Here is the actual clip published by them.



Previously I sent a picture to the Indicast which got featured in the Episode 197 Check out the last 4:05 minutes.

 

Finally NewsLaundry featured a clip from Aaj Tak channel I sent. Check out this episode at 23:02.



Earlier Clothesline featured one more clip pointed by me and Madhu Trehan was generous enough to give me credit also :)

Monday, July 14, 2014

Bidar Trip 2014

With not many option to go for a day long drive around Hyderabad I have been planning visit Bidar for a while now. Its situated in the state of Karnataka about 115 KM from Hyderabad. I was told the road to Bidar (Major part is National Highway 9 ) is in pretty bad condition but I realized it was an overstatement. It was not to bad. Pretty much like national highways of 1990s which used to be 2 lanes without any divider and  with large amount of stretches which are not smooth (the vehicle and the tires make noise ). In fact the state highway 14 (from Zaheerabad to Bidar ) was new.

Entrance of the Fort. Remember to blow horn as per the instruction written in the board (Compulsory Horn) otherwise vehicles coming from other side may block your way.[/caption]

Bidar Fort with beautiful garden[/caption]





Gurdwara[/caption]

Had "Langar" for lunch inside the Gurdwara, it was really good to see so many dedicated people working without any expectation to feed so many people. However as usual I have never liked the laws and restrictions imposed by religion. In the case remember to keep your head covered with clothes all the time. Its quite understandable that every religion has a specific set of rules so that the followers just follow it blindly , may be because sometimes its difficult to explain and convince each person. Rather religion just imposes the rules (possibly making people afraid of gods). Most of the rules were made for some good reason e.g. one needs to wash their hand and remove their shoes before entering a temple , possibly because no one wants the dirt outside to enter the place. Its probably most complex in Hinduism because of the fact the its the oldest one and no one really knows why the rituals were made. One of my friends said that one should not travel with bananas , possibly because you may just peel it and make someone slip ?



Sunday, July 13, 2014

Tadoba Trip 2014

We drove about 400 KM north of Hyderabad to reach Tadoba Andheri Tiger reserve which is famous of tiger sighting and other animals and birds. Lucky did see a tiger in one of the safaris on Gypsy.


My friend Joydeep Mitra captured some good snap of it.



Following was pretty much where where we went. The road condition is very good as of now.

Tuesday, July 1, 2014

English - 2020 V2 (Now for Hindi, Bengali or Telugu speakers)

During 2012 Christmas holiday English 2020, an easy to use English speaking software course was launched. The author of this product is my uncle Dr. Ranbir Sinha who is an educator, inventor and scientist. He received his Ph.D. from University of Minnesota in 1994. While he has contributed to the most successful space rocket projects  till date, he has also spend his last few years researching about how English is spoken all over the world and what is the best way to speak that is correct. He wanted to come of with a "standard" version of speaking English,  so that everyone can understand every other English speakers by correcting some obvious mistakes in the sounds. He has also involved various language experts from many English speaking countries in this project to make it perfect from all perspectives. Tough I contributed to this project voluntarily, I personally find this product incredibly useful for the following reasons.

image description

  •  English speakers around the world, do not understand each other easily.
    English is a popular language in India, with most of the official work being done in English, most of the educated people know this language fluently. Even I used to consider myself  fluent in English till I talked to someone outside India. While people at my work in India could easily understand me in English, my colleague in USA could not. I had to repeat several times and ask him to repeat before we could get the complete sentences. Soon I realized that I have to get rid of the regional accent and speak slowly to make him understand. I could not ask him the same but he realized and slowed down soon and we conversed happily there after :) . The lesson was that both of us had to come down to a common ground where we could understand each other easily. Imagine the whole world doing that ? Your parents from India go to Canada and at the immigration  counter both understand each other without asking each other to repeat over and over again ? The problem was never that one party knows little or more English, it is all about how they sound, where they pause and if they are allowing the other party recognize the words at one go. The usual problem is to pronounce a very familiar word in such a way that it sounds alien and it makes the whole sentence unclear. Remember humans recognize the patterns, do a lot of approximation to understand something and not necessarily listen in very detail and break down every word and apply grammar to it (what we do while writing/reading ) . Hence every word we say has to sound familiar to other party.

  • There are qualified people not able to make themselves a good candidate for a job.
    Lately I have been taking interviews for my company.I am mostly looking at the problem solving and Java/Database skills but I must admit sometimes I have given preference to candidates who speak better.  The communication skills does matter in day to day work. In the past I really had tough time speaking and dealing with colleagues who are excellent coders but can't complete a single sentence while discussing about some design or problem. Its painful when it takes several minutes to convey a single statement to others while working on tough deadlines. When working as a team you don't want to scratch your head to make someone come to the point. You also don't want spending all your day asking them to repeat and guess what he is trying to say. Not only me , I think a lot of recruiters now a days are making sure the candidate it able to communicate in a clear and concise manner, especially in telephonic rounds. I may sound biased but I am sorry, I want to increase productivity of team instead of wasting time understanding each other. Good programming skill non necessarily make you a valuable member of the team. English-2020 can just solve this problem if yours. You don't need to learn English all over again , you just have to listen carefully and try to say the words and sentences in the same way when you use them. You will be able to showcase your skills in a better way to interviewer.  There are so many engineers and so many jobs but it does not impress me when one says "En-vee-ron-ments" while saying "Environments", "egg-nest" while saying "against" and "Fix-ed" while saying "Fixed"

  • You don't need to learn difficult words to converse fluently in English
    To be honest I learned English mostly from TV and Newspaper. I was in a school where the teaching medium was primarily in the regional language. Hence my vocabulary is very small and I realized that  in day to day conversation I don't even have to know a lot of words for which I already know an alternate word. All one need to do is to pronounce the known words correctly so that it sounds familiar to others and understandable. English 2020 course is exactly does the same. It has about 2000 words that we already know and use daily but you will spot the difference why the other party always asks us "can you come again ? " or "I didn't get you" or "Pardon me" again and again when you try to say these words. Its just that we speak too fast without respecting the syllables. Some people are just in a hurry to finish the words. There no point in speaking long words from dictionary and  sound something else. This product also has translations in Hindi, Bengali and Telugu to help the native speakers of these languages understand the English words used in case they are not familiar with them.


Quickly learn to say 2000 very useful sentences in English correctly. 20 Text + audio lessons covering 10 practical situations where you need to speak English. Simple and clear expressions with a combination of American and British English. No complicated grammar, no old-fashioned English and no slang or local dialects - only standard English that is understood all over the world. Topics covered are: Essential English for daily use with friends and neighbors, at school or workplace, in a restaurant, going shopping, meeting new people, making friends, etc. Two special lessons absolutely essential for travelers to foreign countries. The method used in organizing the content is Memory-Web-Association-Method for quickly absorbing and recalling useful information making it an efficient learning process. It is best suited for students 10 years old to any age, those who can read English and wish to practice speaking English on their own. The level is beginner to intermediate.

How to get it ?
To order this product right now you can write to sales@english-2020.com The product is on sale now and details can be found at the website http://www.english-2020.com This product also comes with a FREE video DVD explaining how common words should be spoken.

ISBN : http://www.isbnservices.com/isbn/978-1-63315-440-7/

Product Blog : http://spokenenglish2020.blogspot.ch/p/about-spoken-english-2020.html

 

Thursday, May 1, 2014

Stephen Chin's JUG Visit

Stephen Chin visited Java User Group Hyderabad and gave a presentation about Java 8 Lambdas and Devices as part of his final phase of NightHacking tour. Its him who founded Java Users Group Hyderabad few years ago and recently @rajonjava has taken the leadership who also founded India's most active JUG Chennai .

It was great fun listening to him and this could be organized in my old office at Oracle Campus with help of my friend and ex-colleague Bhaskar . 

Here is the full video of the presentation.



 

Sunday, April 6, 2014

Travelogue : Hyderabad - Bangalore - Mysore - Bangalore - Hyderabad Roadtrip

Finally I took out some time to go for a road trip and break my personal record of driving alone.

Following was created using Google Map Engine. However it did not allow me to create more than 3 layers without paying a monthly free.



While traveling its useful to note down the coordinates of the place of interest because later it may not be easy to find in the maps for reference. I used an app called GPS essentials which has a "Waypoint" marker that allows the current coordinates to be labeled and saved.  These coordinates were in GPS format i.e. 17° 28.345' instead of 17°28'20'' or 17.493°. The later two format is easily recognized by Google maps. I used an online latitude/longitude converter to find the Google Maps friendly coordinates and marked the spots. For future I have created the below Wolframalpha widget to make this conversion one-click.

 



Thanks to @Aditya_Rao for guiding me in the Mysore city and suggesting the must see spots.

Total distance drove in the trip was 1694 KM.

 

Friday, March 7, 2014

FM Transmitter using RaspberryPi

I was looking for a FM radio transmitter and came across this article which explains the use of a raspberryPi to make a quite powerful radio transmitter. There are some commercially available short range FM transmitter for cars which has FM tuner. Also there are few long range one available which claims to have almost small city wide range ( of course it is not legally allowed to transmit strong FM signal without a license  )

Pi

Last weekend I tried to follow the above article and succeed ! Also I used a micro USB cable as antenna connected to the 7th pin in the RaspberryPi. The signal was surprisingly strong, I could receive it in my neighbor's house also. I am sure I can make a better antenna.

TODO : I need to find a way to transmit streamed audio next.