Because a bit of Art must be a part :) - No 1

Rage & Joy

I’m staring at it,
Yes, it’s me, the creator...
It’s my precious,
I’ll die again for it, and I am the keeper…

Long queues every day
To worship, thousands of prayers…
And modern artists (they say!)
Bewitched, wrote books of praises…

They explain the little scratch
Behind the ear, oh so clever!
“A design trick, not a failure”
I cry with rage, roll with laughter…

I half love and half hate,
It’s charming, peerless and all laud...
Resembles the heartless king,
I served, and I've made a god!

And the scratch silently sings,
How I carved with flesh, blood & bone…
My own innocent name,
On the death note…

~ Manuri Amaya Perera

PS: Side effects of some boring lectures!

response.write(something) doesn't work inside callback function?

I was learning NodeJS as I needed to implement a server for the GSoC project.

I faced a problem. response.write(something) was not working inside a callback function I had. I tried all sorts of things but couldn't figure out the problem. Finally I found the careless mistake I had done, that is I was having a response.end() which gets executed before my callback function. Once it was removed the code worked fine.

NodeJS's execution model has only a single process. Therefore NodeJs is using the concept of event driven asynchronous callbacks. So if you are having a slow operation like a database query even though NodeJS has a single process you will not have to wait until that operation finishes. The callback function can take care of what needs to happen once that slow operation is complete and the rest of the code will be executed without waiting for this slow operation.

 In my code I was having such a slow operation and before this operation finishes the "response.end()" which I had mistakenly put, was being executed and because of that, "response.write()" inside the callback wasn't working.