If this blog helped you in any way, please donate a dollar here

Sunday, November 16, 2014

Removing CLOSE_WAIT connections

Hello folks, just thought I would share something I came with during one fine day at work.

Recently, we faced a problem where there were a lot of CLOSE_WAIT connections on our server which caused a variety of issues on the server. It seemed like there was a bug in the application (a java based app) but hunting it down was a pain, fixing it would also take a long time. Instead what we did, was to restart the application at periodic intervals which seemed to clean up the CLOSE_WAIT connections.

However, we wanted to remove CLOSE_WAIT connections without killing the process. We found that we could do the same with tools like :
We tried them out but none of them seemed to be of much use for CLOSE_WAIT connections. So I hacked into the source code of killcx and found this interesting bit of code:
my $packet = Net::RawIP->new({
      ip => {  frag_off => 0, tos => 0,
               saddr => $dest_ip, daddr => $local_ip
      tcp =>{  dest => $local_port, source => $dest_port,
               seq => 10, syn => 1
I modified this and wrote this utility that removes all CLOSE_WAIT connections: https://github.com/rghose/kill-close-wait-connections

This seemed to do the trick! Happy hacking.

Sunday, November 2, 2014

Identifying the actor

So, here I am at Candies, Bandra looking at an all too familiar Bollywood actor, who was also a customer there. He played the villain or cop in many movies, I know him. He had his son with him as well. They bear an uncanny resemblance. I want to go up there and get a picture clicked with him. Wait, what was his name?

I asked my friend who was with me, he too seemed clueless. He also wanted to get a picture clicked, but what if he asked his name? We were terrified of that prospect, as we saw a young woman probably in her 30s, go up to him and click one herself. Damn. Shes knows his name for sure.

In our dilemma and brain racking to recollect his name, he was done with his buying and he left. Leaving me pondering over this problem of his identity. So I came home and tried searching Google, assuming it will read my brainwaves. No use. I could not find a Bollywood actor who visited Candies often, he was not a very well known figure like say, Shahrukh Khan for instance, but he was pretty well known. Now I decided to do this: http://en.wikipedia.org/wiki/List_of_Indian_film_actors!

Again, there were too many! So I made these:

a) Python script to get the images from an infobox element in a page here.
b) Shell script to automate this here.

Armed with these tools, I did this:
# wget http://en.wikipedia.org/wiki/List_of_Indian_film_actors
# grep '<li><a href=' List_of_Indian_film_actors | grep 'title' > list
Deleted the last irrelevant line and fired up "./parse_names.sh list"

I made myself some coffee, came back to my laptop and casually started browsing the thumbnails from my file manager. Found him!

Saturday, August 16, 2014

[OFF] One Night in Bangkok

It was the last day of my travel when I was alone in Bangkok, my friends having left the city the night before my flight was scheduled to take me back to my city, Mumbai.

My friends just left for Kolkata, I was sitting in my hotel room next to a Bangladeshi restaurant. I was searching for a cheap hotel to stay in as I was almost broke by now. The first hotel I was referred to by a member of the Bangladeshi hotel offered me a dorm room for 400 baht with a common bath. I decided to look elsewhere.

The next hotel I went to, a Thai woman referred me to "Mike's" hotel nearby as I told them I was searching for a cheap hotel to stay in. Being unaware, I went to "Mike's" hotel that looked pretty expensive and I was expecting a rub-down as I asked the reception if they have any cheap rooms in store. The manager, probably an American, told me that this is an expensive hotel and I should try another hotel nearby (The same hotel the Bangladeshis had referred to me). No rub-down from him. I could see the smirks on the Thai hotel attendants nearby.

As I came back to the hotel I was told that the dorm room was booked already. All this in a span of around 20-30 minutes. He seemed disinterested to entertain me at all. I decided to book the 'expensive' room (600 baht) with double bed room and an attached bath. I was pretty exhausted and decided to look no further and book this room instead. Being expected to the kind of hospitality we had in the past few days, I was, to say the least, surprised. However the attitude of the Thai-people did cause a bit of a deja-vu.

On our first night in Bangkok we visited "Soi-Cowboy", the almost too well known and infamous street in Bangkok. On our way back, we decided to try some local cuisine from what we call a Box-Shop (Baksho Dokan in bangla). They had some sort of noodle soup with chicken legs and pieces. We decided to try one bowl first. The three of us decided to share this Thai road-side delicacy. I found it pretty good! The three of us decided having various opinions about the food we were having. All of a sudden, a middle aged local approached us and suggested in some broken English that he could buy us a meal and flashed some cash at us. I was surprised but then realised his tone of sarcasm and contempt. I could see the others smirking close by. This guy told us, he could buy us some more food and was taunting us. I was a bit out of place when I suggested, "Yeah, sure, why not!"

Then I realised, this was not funny, and he was taunting us (for what, it eludes me totally, maybe because he felt we are too poor to afford ourselves a meal, I kind of agree with the poor part though). Some other locals stepped in with big grins on their faces and moved him away. We went on with our meal and we ordered one more. The stares however haunted us, as perhaps the sight of seeing three Indians sharing a meal reminded them of how impoverished and malnourished our country is. I kind of enjoyed the stares, made me feel famous for some time. *wink*

The next experience that I will remember was in Koh Lanta, an island in south Krabi. We had rented a scooter and a bicycle from this restaurant "Sugar and Spice" which was run by a local woman. We returned the scooter and were waiting for one of my friends who was riding the bicycle. As he returned, we wanted to take a tuk-tuk (a localised auto-rickshaw) back to our hotel. The woman offered to drop us back for a subsidised rate in her scooters. She had been hesitant earlier when we had asked if we could ride three of us on a bike but now she said, she could do it. We started talking. She said about how bad the season is in Krabi and it becomes hard for them to make a living. The economy there was based on tourism and in the seasons when the rush is low, they are forced to do odd jobs, just like this one. As we almost agreed on her proposal, a tuk-tuk appeared and she suggested we take that instead as that would be good for us. It cost us just the same. We said our goodbyes and went back.

There is so much more I wish I could talk about the next experience we had in Pattaya. Hear me out. We were returning to our hotel room from the very glamorous and glitzy, Walking Street. Our hotel room was next to Patong Beach and I had taken note of the street name where our hotel was located. The three of us, we booked a taxi-van for 100 baht to leave us at  our hotel at Soi 4, Patong Beach. From what the hotel guys told us, this is already a rip-off.

A taxi-van is van with two long seats at the back with the back open from entry and exit of passengers. The driver and her assistant, who were both women, sat in front. They stopped near the Sleeping Market of Patong Beach indicating we had reached the place. I then realised there were probably 2 instances of that name "Soi 4" and then an argument ensued. A policeman intervened and we agreed on paying extra (150 baht in total now) for reaching our hotel room, now that she was clarified about the location.

She stopped about a kilo-meter from the hotel room claiming she cannot go further as there was a roadblock. Normally, taxi-vans take an U-Turn from a bend about half a kilo-metre on that road which we suggested to her. Now she started arguing that she will not be going any further. We decided to persist and stay in the van. She got agitated and came out. She started saying things in Thai with broken English in parts. What I could make out from that was, "This is Thailand". We did not budge. Then she went back in front and came back with what looked like a clever machete inside a cover, standing right out side the exit of the taxi-van. Aggressively gesturing at us to get down and pay up. She was almost screaming at the same time. "This is Thailand", she repeated. Then she went on speaking up some more Thai and then "Pay" is what we understood. One of my friends tried calling up the police right at that instant. She got inside and waved the machete right at him. We were pretty scared now. I told her, we will pay but once we get down from the vehicle. She understood. I could see the other woman hiding in just behind us, enjoying the action probably. She got down blurting out in Thai, things we did not understand. We got down, paid the money and quietly everyone noted the taxi number in their heads.

As the Taxi-sped off, we decided to call the authorities. To our surprise, my friend was told to speak in Thai else they cannot register a complaint. I tried now. The operator told me we would have to call back between 8 am and 10 pm. I wonder why they called the police, an emergency service.

The next day, the day we were to leave Pattaya was another experience altogether. We were going for Para-Sailing and had to keep our bags somewhere on the beach. We kept them at an umbrella spot which had some reclining beach seats. As we were about to leave, we bargained a bit for the beers and beach seat charges. The vendor, a woman, was friendly and we had a chat brewing up. I told her, Thailand is a beautiful place with beautiful women. She replied that "they" find foreigners more beautiful and handsome because of the shape of their noses! She heard a lot about India and gestured about something they put in their eyes. Kajal, I told her. She nodded, even though she knew nothing about it. I told her about "Mehendi" as she was saying something about tattoos and hands. She said she would like to have them. I said, the next time, I would bring them for her.

I am not sure if there would be a "next-time" but for sure if there is I would like to come back to meet the people I had met.

(To be continued...)

Saturday, August 9, 2014

[OFF] The Campus experience from the other side

"The grass is always greener on the other side"

A lot of thoughts cropped up on my mind, the day I was knowing for sure I was to visit NIT, Durgapur, the college from where I completed my post-graduation studies and got recruited to Directi, for recruiting students as part of Directi's panel. The roles had reversed.

Initially I was very enthusiastic but later on it faded away as thoughts of meeting a certain placement officer made me pretty uncomfortable. He was however, not present and that made this visit quite enjoyable! 

Going back to Kolkata after almost 4 months was an amazing experience. After landing at the airport, the first thing we did was head off to Park Circus and of course, Arsalan! This was one place that was on my Zomato wishlist for a long time. Biryani in stomach, now was the time for some "Mishti Doi". We headed off to NIT Durgapur stopping at Shaktigarh for some snacks. One of my Mumbai colleagues fell in love again when he had a sample of "Jhal Muri". How he blushed! We headed off again and it was pretty fun in the car, as always with fun folks like me. (That was sarcasm in case you missed it)

We reached our hotel, the Peerless Inn just next to City Residency and we were given personal rooms for each. I had another Bong for company and we calmly headed off for some local produce. The old box-store ("Baksho Dokan") from where we always bought our greens proved to be handy. Yes, I had missed the shop initially but we were pointed out to the right direction.

It was good. This was the same stuff we had in our 2 years of stay in this fine college. With it came back so many memories. Some so distant that cannot be reached by any means. Came back the years of friendship, struggle, shame, laughter, adventure and verbs that need to be reinvented, to correctly and completely define what had transpired.

We came back to the hotel and gorged on the parcel Biryani and ordered some more food. Hunger had played its part. The next day was campus placement and so we called it a night.

As I entered the main gate of the college I found nobody there. I went to the wing where the placement cell was located earlier. It looked empty, but as I entered the cabin of Mr. Laik I was greeted with a familiar face and a happy voice. He was surprised to see me and happy at the same time. It was good to see him as well. 

I called my colleagues in and we were in the cabin. The placement officer now had come. He had been replaced with someone else this time. I sighed in relief! We made our way up to the auditorium where the HR started his presentation. I was invited to give a talk. Being short of words, I tried appearing professional and saying how good the company is. After the presentations were over we started the MCQ Test. Chaos ensued, question papers were short. After a brief delay we selected 39 for the coding round. We were given lunch from Bapida's canteen and the familiar tastelessness was revisited again. After this we started the interview round.

It felt different and strange on the other side of the table. However, I realize nothing has changed. I wanted to do well in the interviews! I still have my share of good and bad. The students too have that. The guy we ended up hiring was in fact an M.Tech. student.

We had a good nights sleep. The next morning we were off to Kolkata Airport. We had overslept a bit as one of my colleagues wanted to visit Dakkhineshwar temple and it was not possible that day. Instead, we had Lyangcha at Shaktigarh and headed to the airport. While returning, Rohit raided a sweet shop. Then we were off.

While coming back, I had a strong urge, not to. It is a beautiful city, my hometown. Of all its dirt, filth, potholes, it still remains the most beautiful city on Earth. It is my hometown. Amar Sohor.

Sunday, July 27, 2014

[chords] Tomaye niyei golpo hok by Anupam Roy

Initial humming:

G               C
Hmmm.... Mmmm 

G                   B
Vijche kaak, aayna thak
C                       D
Dekhuk tomay fuler dol
G                    , B
Pother baank, aante jak
C                      D
Brishti dhowa kolsi jol
Sohor toli jure golir more more
D                  C        G
Tomay niyei golpo hok

G                  ,B
Vijche kaak, aayna thak
C                       D
Dekhuk tomay fuler dol
G                     ,B
Pother baank, aante jak
C                      D
Brishti dhowa kolsi jol
Sohor toli jure golir more more
D                  C        G
Tomay niyei golpo hok
G       D                      C
Jaani tomar chonde ontomil nei
Tomar urdho gaani
D                    C                        G
Balish chera swopno dhowa urche uruk
Urche uruk

(Similar pattern for the rest)

Tomar chokh, meghla hok
Tomar kothai porche mon
Aangul chonwa mudradosh
Tomar kothar khub ojon
Haajar korotaali tomay bole khali
Tomay niyei golpo hok
Jaani tomar chonde ontomil nei
Tomar urdho gaani
Balish chera swopno dhowa urche uruk
Urche uruk
Urche uruk
Urche uruk

Jaani tomar chonde ontomil nei
Tomar urdho gaani
Balish chera swopno dhowa urche uruk
Urche uruk
Urche uruk

Please post improvements to this! Thanks!

EDIT 1 : Thanks for the improvement s/Bm/Bmajor :) It does sound better

Thursday, July 10, 2014

Client IP based session validation in OpenAM

In Single Sign On (SSO), the cookie itself is the sole mode of validation for most systems.

With OpenAM, one can assign extra attributes to the session other than the cookie. Validation based on client IP addresses can be done as well. What this means is that, when the IP address changes of an user, the user has to login to OpenAM (or Relying Party/Service Provider )  again, since his session is no longer valid for the IP.

So this is how one would do this:

Go : Configuration -> Server & Sites -> Default server settings

 Then to advanced:

Friday, July 4, 2014

[OFF] An amazing person

Yesterday, I came in touch with an amazing person. Someone who has faced a lot of hardships in their life. It was striking, as to what all that person had faced and all because of love. I write about Love a lot. I like to believe that it is the greatest feeling of all, and if I may, the sole purpose of humanity and life.

This person was a different person now. Finally this person has come to terms with the life that has been given. From now on I will refer to this person as "L". Make no mistake, this is only a pseudonym, by which I have decided to refer this person as. Making assumptions on this person's age, gender, caste or color will get you no-where! It would also be wrong to assume that this person refers to myself, i.e., the author of this page, since, let me reiterate, this is only a pseudonym.

Now, let me continue.

"L" had never thought things would be the way they are. "L" always believed no matter what had happened, Love would triumph everything. It turns out, this assumption was wrong. It so happened that this love dis-integrated and brought out the worst in "L". Days never seemed worse. Nights never seemed scarier. It was a dark time. Even the rains had shunned her. She had become a stranger to herself. It was almost as if she had lost touch with herself. The real "L".

The life she led was filled with smiles and happiness all around. She was like a desert inside in the middle of the ocean. The nights were the worst. When everything was quiet all around it would seem like her existence did not matter. It was so deathly quiet that she could hear hes own tears flow down. She could hear her heart beating very slowly. Blood oozing out of her at times. She could hear the deathly frozen feelings inside her.

What had become of "L"? All I can say now is that, "L" was sick. She is fine now. The doctors have done a great job. Inspired by a certain Mithoon Chakraborty movie, the doctors have cured this person. Maybe not as advanced as a brain transplant, but it worked.

Sometimes, it so happens that, "L" wishes to go back. To do it all over again. Surely the mistakes will not be repeated. Surely this ship would not sink all over again. Surely. Then the boulder of doubt hits her and she snaps out of this imaginary construction in her dreams. Realization dawns upon "L", that things can never be the same again. The past has, made "L" wiser and it has contributed to whatever is to become of "L".

I am so glad I met this person.

Sunday, June 22, 2014

[OFF] Shingara Dadu

When I was very young, about 6 or 7 maybe, I remember having a visitor at home. A friend of my grandfather whom I referred to as "Shingara Dadu" in Bangla. Translated to English that means, well, "Shingara"-Grandfather.

What is a "Shingara" you ask?

That is a "Shingara", or samosa, when translated to Hindi.

Does that mean he had some super "Shingara" powers? Did I bite him and come to this conclusion that his skin tastes like "Shingara"?

Apart from the fact that I was not not a cannibal (and probably am not now) let me tell you in all honesty that this nomenclature was done by me on the basis of pure love.

In my home, we had a tradition that whenever a guest would come during a Puja, we would serve them "Shingara"s and "Mishti" (Sweets). Since he would come just after a Puja, these Shingaras would be given to him. However, sometimes, he would come when none of these servings would be available. All I could offer him was some imaginary "Shingaras".

Yes, imaginary. I would cook them up and serve it to him, in my imaginary yet well stocked kitchen, which he would graciously accept. He would pretend to eat them as well, praising the fine taste and cooking prowess it had required.

He carried a walking stick with him and wore black specs with thick glasses. He was lean and tall, around 5 feet 11. He would talk slowly and softly. I remember.

One day, he died.

I was pissed off. Who would eat my "Shingaras" now? I hated him so much for that.

I realised much later what that meant. It was not his fault he did not come. His time was over. My "Shingaras" had killed him. I never give my imaginary "Shingaras" to anybody else now.

I dismantled my kitchen.

PS: I only play Kitchen Scramble now.

Thursday, June 5, 2014

Omniauth OpenAM Gem

Hello people, here's presenting a brand new gem!

For folks, who think they hit a jackpot, think ruby. Yeah, well, this is an omniauth gem for Ruby on Rails people for openam. There has been an outstanding request for this gem on the requests page and here it is:


You can get the full list of omniauth gems here:


For those who are still confused, omniauth is one of the marvels of ruby which provides options for authentication options to devise based on external providers. I am still a newbie here, so pardon me please.

Friday, May 30, 2014

OpenAM database connectivity with MySql

This post comes after a long time. I had been really stuck with my project in creating a Single Sign On implementation. I was working with an amazing piece of software, OpenAM, formerly OpenSSO, currently maintained by the Forgerock community. 

My setup: I used Tomcat with Mysql and OpenAM 11.0.0 running on Centos

So first things first, install mysql-connector-java for your operating system and you should get a jar file. Here is what I got on my box:

# rpm -ql mysql-connector-java | grep jar
Now copy this to your tomcat installation directory. At "$CATALINA_HOME/lib" and restart tomcat.

Friday, March 21, 2014

Setup gitlab with OpenAM (OpenID Connect)

OpenAM, formerly OpenSSO, is an amazing piece of offering for providing Identity Management capabilities in an organisation. So this is what I wanted to do, integrate OpenAM with Gitlab.

Like in my previous post on integrating with an OpenID provider (which is different from OpenID Connect) we follow similar steps. We are going to use OpenAM as an Openid Connect provider.

OpenID Connect protocol, finalized on 26th February, 2014 is a not a very new protocol and has existed for a long time.[1] It is OpenID protocol encapsulated in OAuth2 protocol.

Gitlab configuration:

Saturday, February 22, 2014

Tor browser bundle released

Gone are the days that the internal was the ultimate symbolism of freedom in the planet and lo and behold! The Internet that knows more about you than your mom does, is here. Thanks to Edward Snowden, the world has learned about  spying and snooping all over the world. Someone who the entire world had almost shunned is now being relooked upon, as he is being nominated for the prestigious Nobel Peace Prize. [1]

Ironically, even after Obama was left red faced and  promised (some) spying will end, [2] the Indian Government is getting started with NETRA NEtwork and TRaffic Analysis System. [3]

Thankfully however, there are places in the Internet that are virtually untraceable. The "tor" network happens to be one of those amazing inventions man has made. For those who used tor earlier, they would know it was such a pain to connect to the network, Vidalia came and made it oh so simple! Here's a image poached off the internet to show Tor really works:

Saturday, February 15, 2014

[OFF] Valentine's Day

The worst part about Valentines day is when you see everyone partying with their special someone and oozing out love when you are alone trying to fake a smile just to show how you are happy for them. Sometimes it appears so silly what these lovebirds will do. Some play the peacock, some dance like Pelvis Grizzly, some bump into lamp-posts, and the list goes on. One often wonders if they are really in love or just in the mood to invoke some jealousy by showing off. Cause, yes, invoke they do and oh man I just want to murder them with a pump-action shotgun with blood squishing all over the floor and probably some in their lover's mouth as well.

But that's just me. And all of this is just a joke! Ha! I am a harmless man who loves joking. Bad joke you say?

"You know I actually have a book. You don't want to get on that book do you?"

Craziness apart, valentines day, I felt was always one invented by the corporates. I am talking about the Archies, Hallmark and the kind. The kind that wants feelings, to be measured by the amount of money you spend. The hype surrounding it, the demand, everything was almost artificial. To me, if you are in love, everyday should be a celebration of that love. Do something small, yet thoughtful that will help in expressing the overflowing love you have in your heart. One day is just too small a time period for that.

Running an errand, writing something, composing something, drawing something is far more romantic than some card or gift you can buy off the Internet. Just looking into the eyes of the person you love, is a lot more romantic than anything else. You don't have to kiss, you don't have to hug, you don't even have to talk. Silence is the language of love. It is but a silent understanding, that is understood in the language of the heart.

Being a computer scientist (lol!) and a logician (roflmao!), I never really believed in the concept of souls (what? am I on drugs?), and that somethings need to be felt with the heart. This was until I fell in love. It feels everything I never wanted to feel. The opposite of what I understood love stood for.

Yesterday, I missed her a lot. True story.

Saturday, February 8, 2014

[OFF] Homesick

Here I am on a Saturday morning sitting on my bed in an empty room trying to do something. I think about calling her up, but she is busy now. I think about watching a movie, but I cannot make up my mind. I think about playing my guitar, or figuring out the Rubic's cube. I think about a lot of things and the last thing I think about makes me open up my blog.

What was the last thing I thought about then? Well, it was a vague little feeling mixed with laziness (the laptop is at an arms stretch), sadness (really have no clue where that came from), happiness (I am pretty rich, I should be happy right?), hunger and something I would call nostalgia. Yes, that is pretty much it.

Sometimes I have had feelings that I cannot describe myself. Sometimes I don't feel anything at all. This is one of the former times. I am not sure what I am feeling, but am definitely not feeling nothing. As I sit on my bed looking outside I can see a huge building full of little flats. I can see little children swinging on the swing. I can two others playing on a slide. I can see a bird fly by. I can see an old man sitting still near the playing children. I light a cigarette.

You see, by lighting a cigarette I am claiming I am not affected by what I see. I claim to be macho and carefree. But somewhere deep inside me, like very deep, pitch dark and not visible to the naked eye, lies a little child wanting to sob and go outside and play. Wanting to sob at all the bad things I have done and beg forgiveness from all the people I have hurt. The weakest part of me I hide so well.

The point is however, not the empowerment of women, nor the RTI, nor making silly wisecracks at my namesake, no, none of that. The point is, well, I really don;t know. I have no point to make. I am just homesick.

Just something I read the other day: "We are born alone in this world, live alone, die alone, love just creates the illusion we are not."

Tuesday, February 4, 2014

DejaVu Trends - The final story

Looks like the blog worked more than the threats to lodge a police complaint. For those who are clueless, please read my previous rant for DejaVu Trends (https://dejavutrends.com) and how I believed them to be fraudulent.

Okay, so I visited the MIDC police station the day I had posted the blog and really what I was told that it was all my fault that I had paid them in the first place (I know that, that is why I am here in the first place *frustration*). They told me to file a complaint to the consumer court and they would take action only if they court directs them! Realising they would be of no help I decided on
1. Go to consumer court and wait for ages.
2. Try the Juhu address of the Directors of the companies. This address was available on Ministry of Corporate Affairs website.

Friday, January 31, 2014

Dejavutrends - Fraud Avoid, the story

I had deleted the following post after insistence on the part of the company representatives who said they are actually honest and are trying very hard to meet demands. I put this post back up sighting the following:
  1. They deleted me from their facebook page
  2. They deleted their facebook page!
People who are looking to file cases against this company might find some handy information contained in this post. Read on.

Hello folks, this is regarding one of the amazing scams that runs in the city of Mumbai. Some of you must have heard of, or have got e-mails from Deja Vu Trends (https://dejavutrends.com) regarding their e-shopping website. They are selling products at very cheap prices and they even have a HTTPS SSL Certificate!

Well, let me tell you about this company in depth. If I had not bought something from this website I would not have known about this scam but since I have (been duped) I gleefully blog about it! What I bought was a WD External Hard-disk which they have no intention of shipping to me. It has been over 2 weeks and all I hear is that the product is being shipped. They have provided any tracking code nor do they have an option to cancel the order (and opt for a refund). Repeated calls to their customer care center did not prove to be fruitful for 2 reasons.