Search within this blog

Tuesday, August 31, 2010

I got a strange spam today


Today, just a few minutest ago, I got this mail in my CSE inbox.



Obviously this is a spam. But something else made me curious. This mail says I need to contact someone called Frank. What is more interesting is, just the previous day, I was Googling a lot about FRank, a learning based ranking algorithm. Is this mere coincidence or there is something else?

Friday, August 27, 2010

Full day break

Today I got an unexpected off day. Early in the morning my phone rang. I woke up, talked sweet for some time and then went to sleep again. Like all the other people in nearby rooms, I have caught cold too. So, going to sleep did not seemed to be an bad idea. I turned the alarm clock off... I was close to the alarm time anyway so I became over confident.

Overconfidence never pays. When I woke up again it was 10:55. I had a lecture from 11:00. At that point of time, I had two options:
  1. Abandon all natural things you do when you wake up and RUSH to the school
  2. Be natural! and abandon the lecture
Obviously I choose the second option. With toothbrush in my mouth I awakened up my computer. There was one email from another Prof. that audit people need not attend the afternoon quiz.

Voila!!! I had a full day break.

Tuesday, August 24, 2010

Setting up PHP within Apache Tomcat

PHP by default comes with Apache web server. But when we tried using PHP at our server we faced problem. The reason was we already use Apache Tomcat and Tomcat already uses port 80.

We needed to install PHP within Tomcat. We needed one additional software: PHP Java Bridge for that.

We were lucky to see one nice tutorial on the web. It almost spoon-feeds.

Tuesday, June 29, 2010

First day Second Show

From here let me take you one month back. After a tedious end semester examination we all were tired. In engineering end semesters are always tedious, as you hardly study throughout the semester and the whole load concentrates. So on the day of the last exam we decided to hang out.

We needed a place to go. First of all we made lots of debates and discussion. And as time passed in discussion and view - counter-views, the schedule of most of the movie halls became unsuitable. Except one, Hind. We decided to go there. Although the movie was not of choice for most of us.

The six of us went outside the college and weighted for the bus. Now, I have a theory in this. Whenever you weight for a bus say S-12, all the bus except that would pass you. So, it is no wonder that we saw two back to back S-9s and some of the rarest buses we never get in the days of requirement. After waiting for (say,) 30 minutes, we did some calculation. Suman pointed out if we share the taxi fare among six of us, then it is almost comparable to the bus fare. We agreed and took a taxi. It is no wonder that as soon as we got inside, an S-12 passed by.

The movie was Jhoom Barabar Jhoom (first day second show). Whoever have watched the movie knows how it is. It is one of the most Codopyrine movies i have ever seen. No story, no screen play, no acting and of course, no ticket to hollywood. Believe me, it is really hard to undergo Bobby Deol in the latter half of the movie. The songs were in the same category except Bol Na Halke Halke.

But none of us could possibly think of for what I would remember the day later on. That was the first day I suspected the entry of someone else in my life.

From here the post takes an acute angle turn.

We sat side by side in the movie hall. Could I concentrate on the movie fully? When we came out (all six of us, if people wants disambiguation) it was raining. We stopped for a roll. Egg roll mixed with Calcutta rain is a kind of irresistible taste. Now one after another the copy-book cliches started happening around me. We both became deserted near the foot-over bridge near Sealdah. It started raining heavily and we found there was only one umbrella (that too a small, fragile, sealdah market special). This was the beginning of a long story.

Thursday, June 17, 2010

Creating Multiple Processes under Windows (repost)

The following code illustrates how multiple processes can be spawned run in parallel under Windows. Here Windows API is used for system calls (like fork in Linux). The compiler I used is Microsoft Visual C++ 6.0.


There are three C source files:

  1. Win32Process1.c for Win32Process1.exe
  2. Win32Process2.c for Win32Process2.exe
  3. Win32MulProc.c for Win32MulProc.exe

Win32Process1 & Win32Process2 are similar. They both print integers 0 onwards with a specific delay between two integers. The delay can be specified by command line. If no delay is specified in command line then they goes for default delay which is set to 500ms.

Win32MulProc creates and runs Win32Process1 & Win32Process2 as child processes. It uses CreateProcess API call. Win32MulProc also has a loop that prints integers as before with specific delay. The delays for all 3 processes can be set by command line like
> Win32MulProc 500 250 250

The three processes the main one, Win32Process1 and Win32Process2 runs simultaneously.

The main process waits until the children completes.

CODES:

Win32Process1.c 1/27/2007

/**

* Win32Process1.c

* Code for Win32Process1.exe

*

* This is the code for the child process Win32Process1 which will be

* created by parent process Win32MulProc

*

* Author: Joydip Datta

* Date: 3:09 PM Saturday, January 27, 2007

*/

#include stdio.h

#include stdlib.h

#include windows.h

// a simple process thats counts 1 2 3 4 etc until Esc is hit

// a specific delay is imposed between each count

#define DEFAULT_DELAY 500 //ms

int main(int argc, char * argv[]) {

int delay, i, ch;

printf("\nProcess Win32Process1 started...\n");

if(argc>=2) //delay specified

delay = atoi(argv[1]);

else //delay not specified

delay = DEFAULT_DELAY;

for(i=0;;i++) {

if(kbhit())

if((ch=getch())==27)

break;

printf("Win32Process1: %d\n",i);

Sleep(delay);

}

printf("\nProcess Win32Process1 ended...\n");

}

Win32Process2.c 1/27/2007

/**

* Win32Process2.c

* Code for Win32Process2.exe

*

* This is the code for the child process Win32Process2 which will be

* created by parent process Win32MulProc

*

* Author: Joydip Datta

* Date: 3:09 PM Saturday, January 27, 2007

*/

#include stdio.h

#include stdlib.h

#include windows.h

// a simple process thats counts 1 2 3 4 etc until Esc is hit

// a specific delay is imposed between each count

#define DEFAULT_DELAY 500 //ms

int main(int argc, char * argv[]) {

int delay, i, ch;

printf("\nProcess Win32Process2 started...\n");

if(argc>=2) //delay specified

delay = atoi(argv[1]);

else //delay not specified

delay = DEFAULT_DELAY;

for(i=0;;i++) {

if(kbhit())

if((ch=getch())==27)

break;

printf("Win32Process2: %d\n",i);

Sleep(delay);

}

printf("\nProcess Win32Process2 ended...\n");

}

Win32MulProc.c 1/27/2007

/**

* Win32MulProc.c

* This is the parent process that calls and run two child processes

* Win32Process1.exe and Win32Process2.exe

* (and of course there is the main process)

* (To check how Windows handles multi programming)

*

* Author: Joydip Datta

* Date: 3:41 PM Saturday, January 27, 2007

*/

#include stdio.h

#include windows.h

#define DEFAULT_DELAY 500

#define PROCESS1 "Win32Process1"

#define PROCESS2 "Win32Process2"

int main(int argc, char* argv[])

{

STARTUPINFO si1,si2;

PROCESS_INFORMATION pi1,pi2;

int delayMain,delayP1,delayP2, i, ch;

char cmd1[50],cmd2[50]; //commands for two child processes

printf("\nProcess Main started...\n");

//delay calculation

if(argc>=4) {//delay specified

delayMain = atoi(argv[1]);

delayP1 = atoi(argv[2]);

delayP2 = atoi(argv[3]);

}

else //delay not specified

delayMain = delayP1 = delayP2 = DEFAULT_DELAY;

//setup commands

sprintf(cmd1,"%s %d",PROCESS1,delayP1);

sprintf(cmd2,"%s %d",PROCESS2,delayP2);

printf("\nPreparing to open two child processes...\n");

//CREATE 1ST PROCESS

//ALLOCATE MEMORY

ZeroMemory(&si1,sizeof(si1));

si1.cb=sizeof(si1);

ZeroMemory(&pi1,sizeof(pi1));

//create child process

if(! CreateProcess(NULL,

cmd1,

NULL,

NULL,

FALSE,

0,

NULL,

NULL,

&si1,

&pi1))

{

fprintf(stderr,"err: Win32Process1 creation failed");

return -1;

}

//CREATE 2ND PROCESS

//ALLOCATE MEMORY

ZeroMemory(&si2,sizeof(si2));

si2.cb=sizeof(si2);

ZeroMemory(&pi2,sizeof(pi2));

//create child process

if(! CreateProcess(NULL,

cmd2,

NULL,

NULL,

FALSE,

0,

NULL,

NULL,

&si2,

&pi2))

{

fprintf(stderr,"err: Win32Process2 creation failed");

return -1;

}

//loop for main process

for(i=0;;i++) {

if(kbhit())

if((ch=getch())==27)

break;

printf("Main: %d\n",i);

Sleep(delayMain);

}

printf("\nLoop of Process Main ended.\nBut Process Main will wait for her children...\n");

//parent will wait till child completes

WaitForSingleObject(pi1.hProcess,INFINITE);

printf("1st child complete\n");

WaitForSingleObject(pi2.hProcess,INFINITE);

printf("2nd child complete\n");

//close handles

CloseHandle(pi1.hProcess);

CloseHandle(pi1.hThread);

printf("\nProcess Main ended...\n");

return 0;

}

References:

- Galvin

- MSDN

Joydip Datta
1/27/2007 4:41:36 PM

Creating Threads in Windows

Like process you can also create threads in windows at ease. The thing is similar to pthread_create in Linux. This code is mostly taken from Galvin. You use the CreateThread API call and pass the thread function to it. The following code illustrates this. The code is taken from Silberschatz, Galvin, Gagne: Operating System Concepts, 7th Edition: Figure 4.7. But the code was not working for some reason, so, i made a few changes and post it here. The changes are in bold. I also added a few comments to describe the code more elaborately.

File: Win32ThrdCreat.c
---------------------------------------

/*
MULTITHREADED C PROGRAM USING WIN32 API

CREATES A CHILD THREAD TO CARRY OUT 'thread_func' FUNC.

MAIN THREAD AND CHILD THREAD RUNS CONCUURENTLY

1/2 S DELAY IS IMPOSED IN EACH THREAD FOR DEMONSTRATION PURPOSE

Galvin p 31
Modified by: Joydip Datta
Date: 9:56 AM Thursday, December 14, 2006
*/

#include
#include

DWORD Sum=0; //shared data

//the thread runs in this separate function
DWORD WINAPI thread_function(LPVOID Param)
{
DWORD Upper = * (DWORD*) Param;
long i;

for(i= 0; i<= Upper; i++){
printf("Child Thread: %ld\n",i);
Sum+=i;
Sleep(500);//pause for 1/2 s
}

return 0;
}

int main(int argc, char * argv[])
{
DWORD ThreadId;
HANDLE ThreadHandle;
long Param,i;

//perform basic err chk
if(argc != 2){
fprintf(stderr, "An Integer parameter is requirred");
return -1;
}

Param = atoi(argv[1]);

if(Param <>
fprintf(stderr,"An Integer param >=0 is requirred");
return -1;
}

//create the thread
ThreadHandle = CreateThread(
NULL, //default security attribs
0, //default stack size
thread_function, //pointer to thread func
&Param, //parameter to Thread func
0, //default cration flags
&ThreadId//returns the thread Id
);


for(i=0;i
printf("Main Thread: %ld\n",i);
Sleep(500); //pause for 1/2 s
}

if (ThreadHandle != 0) {
//wait for the thread object to finish
WaitForSingleObject(ThreadHandle, INFINITE);

//close the thread handle
CloseHandle(ThreadHandle);

printf("Sum: %ld",Sum);
}
return 0;
}

Monday, June 14, 2010

Being mad in Mumbai rain.. Childhood returns

I was inside lab. My lab doesn't have a window. So, I had no idea about what was going on outside. I came out and saw the earth getting soaked under Mumbai rain. I wrapped my pen, copy, earphone and mobile in a polythene bag, took my bi-cycle and went outside. Rolling through the slippery downhill road, I felt the raindrops all over my face, washing away the salts. Within a few moments I was all drenched. The rain is so heavy in Mumbai, that you can not even see objects that are meters away. While coming down I saw images of my childhood floating around me. The days when I intentionally kept the umbrella at bag. The days when I preferred cycling through those portions of the road where there were water standing. The childish joy while pushing myself through the waterlogged roads. Sometimes ice-stones fell during nor' westers. I remembered how I ran in the rooftop of my house to pick them up. I used to put some of them in my mouth when my mom was not watching.

Tuesday, April 20, 2010

ভোর

এখানে আসার পর থেকে ভোর হতে খুব কম-ই দেখেছি। ঘুমোতে যাওয়ার সময় ক্রমঃশঃ গভীর থেকে গভীরতর রাতের দিকে সরতে থাকে আর সেই সঙ্গে পিছোতে থাকে ঘুম ভাঙার সময়। এইভাবে পিছোতে পিছোতে যখন ঘুমোতে যাওয়ার সময় ৬:৩০ পার করল, আমি এখানে ভোর হওয়া দেখলাম।

নেশাতুর রাত আড়ামোড়া ভেঙে জেগে উঠল। প্রত্যেক জায়গার ভোরের নিজস্ব একটা গন্ধ থাকে, সেই গন্ধ নাকে এল। মনে পড়ে গেল, দেশগাঁয়ে যখন বেড়াতে যেতুম, তখন ঘুম ভাঙার পর কতকটা এমনই গন্ধ নাকে আসত। মশারি ফাঁক করে, পা-টা নামিয়ে হাওয়াই চটি খুঁজতাম আর ক্রমশঃ স্পষ্ট হয়ে জেগে ওঠা লোকজনদের কলতান।

আমাদের হস্টেল-এর ছাদে এসে দাঁড়ালে এমনিতেই মনটা ভালো হয়ে যায়। একদিকে সারি সারি ধোঁয়া ঘেরা পাহাড়; অন্যদিকে বিশাল একটা লেক। লেকের অন্যপাড়ে সদাজাগ্রত শহরের রাস্তায় গাড়ীগুলো বিন্দুর মত সরে সরে যায়। তার-ও পেছনে দেখা যায় বিমানের ওঠানামা। সামনের দিকে আছে লেক এর চড়া আর তার-ও পেছনে জনপদ। ঝাঁ-চকচকে শহরের সাথে তার পার্থক্য চোখে পড়ার মত। সেই পার্থক্য কেন জানি না, বারবার আমার পাড়াগাঁ-এর কথা মনে পড়িয়ে দেয়।

পাখির আনাগোনা শুরু হয় আস্তে আস্তে। হস্টেলের ঘুলঘুলি থেকে পায়রাগুলো বেরিয়ে পড়ে। কোকিল আর কাক ডাকতে শুরু করে এক-ই সাথে। মাটিতে শালিখ চরে বেড়ায়। টিভির তারে বসে ফিঙে লেজ দোলায়। দোয়েলরা গল্প করে। দূরে লেকের চরে বসে থাকা বকগুলিকে মনে হয় ছড়িয়ে থাকা সাদা পালক। লেকের উলটোদিকে আছে একটি পাঁচতারা হোটেল।তার সবকটা ঘরেই নীল পর্দা। সেগুলি একইরকম থাকে। কতকগুলি গরু চরতে আসে লেকের চরে। বকগুলি ঘিরে ধরে তাদের। কুকুরগুলো খামোখা মস্করা করে গরুগুলিকে তাড়িয়ে বেড়ায়।সামনে আমার প্রিয় জনপদে শুরু হয় মানুষের আনাগোনা।

ক্রমশঃ রোদ বাড়ে, আমি ফিরে এসে ঘুমোতে যাই।

Sunday, April 11, 2010

Retrograde and Anterograde Amnesia

Retrograde and Anterograde Amnesia happened to me at the same time when I (supposedly) fell down from my bicycle last Sunday. The names sound really fearsome but for me the period involved is really small (5-6 seconds of Retrograde and ~30 minutes of Anterograde).

In retrograde amnesia, the subject (that's me) is unable to recall events that occurred before the development of amnesia. The reason in my case was a mild head injury and shock. And I forgot the event of falling down altogether. According to Ribot's Law, there is a time-gradient in retrograde amnesia. Recent memories are more likely to be lost than the more remote memories. So, I lost the last 5-6 seconds before the head injure completely although I was able to remember the events before that gradually within a short time. For the first few hours it seemed that the time (2-3 hours) was a dream. But as people informed me the events that happened in that period, I gradually recollected some of the events (except for the 5 seconds period).

In anterograde amnesia, the subject loses the ability to create memory. There are two types of memory in human brain. One is short-term memory which is used for immediate processing and one is long-term memory which is used as a permanent storage for later retrieval. In anterograde amnesia, the process of writing from short term memory to long term memory is affected. I don't remember what happened during the 30 minute period after the injury. People said, I handed over my bi-cycle to Omair, came back to my room walking, asked my friend for Dettol, called my girlfriend once, took the bicycle keys back from Omair etc. But I don't remember these things at all. In most cases (including mine) subjects loss declarative memory (recollection of facts) and not procedural memory (how to do things).

References
  1. http://en.wikipedia.org/wiki/Retrograde_amnesia
  2. http://en.wikipedia.org/wiki/Ribot%27s_Law
  3. http://en.wikipedia.org/wiki/Anterograde_amnesia

Tuesday, April 06, 2010

Sealdah Episode

Sealdah
Do you still remember that guy standing in the entrance of Sealdah-north and weeping? Yeah, he was one of the boys who among the rare breed of men who cry. To make the matter worse he cried before his girlfriend. He was not weak (nobody admits himself weak). The thing was that his girlfriend was only person before whom who could cry, speak his heart out, and talk freely. He rarely shared anything with people. His girlfriend was the only person before whom he could be free.

He was tense. He was going to give one of the most important exams of his life in two days. It’s the exam for which he abandoned everything else. It’s the exam for which he sacrificed everything. He doomed in the other areas any way… or the IT scenario during recession was like that, everybody was dooming. Doing something in that exam was his only chance. Every other hope was already gone.

He didn’t know then that the exam would change his life so much and will take him thousands of kilometers away from where he used to be, from where he used to meet her, from the very Sealdah station where they said good bye to each other. It was most of the times the boy first said that they should leave. The boy was like this only. Always confused and prioritizing stuffs and never putting importance on what he actually wanted to do. The girl became sad and then became used to it.

That day the boy was not leaving. He was weeping and weeping. He was venting his heart out… he could not take the pressure any more. He needed to do something decisive in those three hours of exam. The girl was consoling and trying to make him understand like a mother talks with her child. Slowly the boy got back power. The exam was not that bad. He was prepared enough to face it. He prepared the best way he could and that was the best he could do. The girl could not give him a hug as they were standing in one of the busiest station in the world. But her eyes told everything. It talked about how deeply she loved the boy and how surely she believed in the love of the boy for her.

Thursday, February 18, 2010

I have Just Completed Alchemist


What an awesome book it was. Wait... I am seeing an omen... it instructs me to dig just beside KReSIT!

OMG!!! People have got omens much earlier than me. They have already started digging. I should have read the book earlier.

Friday, January 29, 2010

Gloomy Evening Sets In

From your window you can see how an evening slowly sets. You again start thinking what could be better or in what way you should have been behaved, how you should have taken decisions...

You should have done this, done that...

Sunday, January 24, 2010

John Denver -- Leaving On a Jet Plane



All my bags are packed I'm ready to go
I'm standin' here outside your door
I hate to wake you up to say goodbye
But the dawn is breakin' it's early morn
The taxi's waitin' he's blowin' his horn
Already I'm so lonesome I could die

So kiss me and smile for me
Tell me that you'll wait for me
Hold me like you'll never let me go
Cause I'm leavin' on a jet plane
Don't know when I'll be back again
Oh babe, I hate to go

There's so many times I've let you down
So many times I've played around
I tell you now, they don't mean a thing
Every place I go, I'll think of you
Every song I sing, I'll sing for you
When I come back, I'll bring your wedding ring

So kiss me and smile for me
Tell me that you'll wait for me
Hold me like you'll never let me go
Cause I'm leavin' on a jet plane
Don't know when I'll be back again
Oh babe, I hate to go

Guitar Solo

Now the time has come to leave you
One more time let me kiss you
Close your eyes I'll be on my way
Dream about the days to come
When I won't have to leave alone
About the times, I won't have to say

So kiss me and smile for me
Tell me that you'll wait for me
Hold me like you'll never let me go
Cause I'm leavin' on a jet plane
Don't know when I'll be back again
Oh baby, I hate to go

Cause I'm leavin' on a jet plane
Don't know when I'll be back again
Oh babe, I hate to go

Monday, January 18, 2010

শ্রীজাতের লেখা

মুখে যত মিষ্টি বলে, মনে তত খিস্তি করে লোক
আমার যা গেছে গেছে, বাকিদের আরও ক্ষতি হোক।
হাত মেলাতে এসে তারা অভিশাপ খেলে যায় টাচ-এ
রোগ তো, ছোঁয়াচে।
আমার আর কী ক্ষতি হবে, ঘরে নাই হিরে-জহরত
কানে তুলো, চোখে ঠুলি, হাতে-পায়ে বেড়ি, নাকে খত
সবই তো কমপ্লিট হল। ক্ষতি বলতে লাভে হারব গেম
একটা প্রেম ছেড়ে দিয়ে জংশনে দাঁড়িয়ে আছি। লেট করছে পরবর্তী প্রেম।
দুঃসময় বন্ধু ছিল, তাই আমার ভাল না সময়
উপায় থাকে না কোনও। ভালবাসলে ভালবাসতে হয়।
- শ্রীজাত

Thursday, January 07, 2010

Yet Another Fiction - issue 2


- 2 -

Shreyasee and Rahul were two students of same college. Even they shared the same department. But they didn’t quite know each other as they had different friend circles and Rahul, being an introvert, didn’t often talk with people other than his close friends. But some complex circumstances brought them together as Rahul changed his friend-group and joined the group in which Shreya belonged. Quickly than expected they became very good friends.

On the very day when Shreya was crying in the corner of the college roof and Rahul was consoling her, Rahul also shared some of his deepest secrets that nobody knew about. The secret that Rahul always feared of getting leaked, the secret which tells why Rahul changed the friend-circle, the one and only secret of Rahul’s life, he shared with Shreya. This way by sharing secrets and crying their heart out, they became really good friends, possibly the best friends of each other. They chatted until evening that day. And when they came out from the college, street lamps at the roads were lit.

From now they could be seen in different places in different times sitting together and chatting with each other. As expected, rumours started spreading. Rahul never thought he could be the topic of discussion anywhere. He never imagined that anybody could actually talk about him in his absence. He had a habit of underestimating himself. So, he was quite enjoying the new situation.

“Do you know, people are talking about us?” – said Shreya as they just got out of the college in one afternoon.

“Are they?” said Rahul as if he didn’t know anything.

“Yes, they are.” Shreya continued, “Do you think we should break their misunderstanding?”

Is this an indication that at last love is coming to Rahul formally? Whatever Shreya said just now seemed like an acceptance guarantee to Rahul. Otherwise Shreya wouldn’t have asked Rahul, she would have told her to just break the misunderstanding. Now, this is a grab-it-or-lose-it situation for Rahul. Rahul must react now... else, he’d lose again. What Rahul needed to do now was just propose her. But being an introvert, this was never easy for him. Rahul got nervous and quickly took an auto and left.