Category Archives: Node.js

All post related to Node.js

Socket.IO

Socket.IO Connect   var io = require(‘socket.io’).listen(80); io.sockets.on(‘connection’, function (socket) { socket.on(‘message’, function (data) { console.log(data); }); }); on message need to parse and on send stringify. Managing Log Level   io.set(‘log level’, 1); Maintaining connection of same user with … Continue reading

Posted in Node.js | Leave a comment

Login form in node.js with session mangement

connect( connect.cookieParser() , connect.session({ secret: ‘keyboard cat’, cookie: { maxAge: 60000 }}) , connect.favicon() , function(req, res, next){ var sess = req.session; if (sess.views) { res.setHeader(‘Content-Type’, ‘text/html’); res.write(‘<p>views: ‘ + sess.views + ‘</p>’); res.write(‘<p>expires in: ‘ + (sess.cookie.maxAge / 1000) … Continue reading

Posted in Node.js | 2 Comments

advance query in mongodb

  db.collection.find({keyfieldtocheck:{ $exists : false }}) Ref : http://www.mongodb.org/display/DOCS/Advanced+Queries

Posted in lily, Node.js | Leave a comment

Installing node.js on ubuntu

Installing node.js on ubutnu https://github.com/joyent/node/wiki/Installation step 3a ) Installing on Unix (including BSD and Mac) sudo apt-get install git git clone git://github.com/joyent/node.git to install particular version we want the stable one. cd node git checkout v0.4.11 # optional.  Note that … Continue reading

Posted in Node.js | Leave a comment

Installing Monit on ubuntu

sudo emacs  /etc/monit/monitrc sudo /etc/init.d/monit start sudo monit status Ref : http://howtonode.org/deploying-node-upstart-monit http://www.ubuntugeek.com/monitoring-ubuntu-services-using-monit.html http://www.darkcoding.net/software/setting-up-monit-on-ubuntu/ http://mmonit.com/monit/documentation/monit.html#name This screenshot was really helpful : http://fosscasts.com/screencasts/6-System-Monitoring-With-Monit I got this code from above screen shot : /etc/monit/monitrc file I used: set daemon 20 set logfile /var/log/monit.log … Continue reading

Posted in Node.js, Ubuntu/Linux | Leave a comment

how to make api server and call an api from node.js

making server for api interface var sys = require(“sys”), http = require(“http”), url = require(“url”); http.createServer(function(request, responsehttp) { responsehttp.writeHead(200, {“Content-Type”: “text/html”}); console.log(request.url); var url_parts = url.parse(request.url, true); var query = url_parts.query; console.log(query); var msg={ ‘success’:true, ‘message’:’your request is sent to … Continue reading

Posted in Node.js | Leave a comment

installing nvm

  First you’ll need to make sure your system has a c++ compiler. For OSX, XCode will work, for Ubuntu, the build-essential and libssl-dev packages work. To install create a folder somewhere in your filesystem with the “nvm.sh” file inside … Continue reading

Posted in Node.js | Leave a comment

how can I install v.6.x of socket.io by NPM now?

npm ls socket.io  sudo npm install socket.io@0.6 Ref : http://foohack.com/2010/08/intro-to-npm/ http://blog.izs.me/post/1675072029/10-cool-things-you-probably-didnt-realize-npm-could-do        

Posted in Node.js | Leave a comment

implementing ineheritance in javascript and how inheritance is implemented in a language

understanding javascript with node.js   Ref : http://howtonode.org/object-graphs http://howtonode.org/object-graphs-2 http://howtonode.org/object-graphs-3

Posted in Node.js, UI Js | Leave a comment

how to handle closure in node.js

server.getchannel are closures over the i variable (well, over everything in scope, but it’s i we’re concerned with). They get an enduring reference to i, not a copy of its value as of when the function was created. That means when the function runs, it uses the current value of i, not the … Continue reading

Posted in Node.js | Leave a comment