Devlog: Real Time Web With Node.js

Completed the Real Time Web with Node.js course on CodeSchool

Another impeccable course, produced to the usual high standards which I have come to expect with each and every CodeSchool module. Go give these guys money and do a few courses, worth every penny.

I have completed a couple of node.js projects to date and am currently working on a biggin’, so I didn’t find this course very challenging, but I did find it fun, another great jingle and lots of great content.

The examples go a long way to show how much you can do with so little code, walking students through using socket.io and redis to build a chat client and a Q&A system.

Something I learned was how to use redis effectively, the course got me started and provided useful tips such as limiting size of a list to 10 items for example:

1
2
3
4
5
6
7
8
9
var redis = require("redis"),
    client = redis.createClient();
//... on last meeting submitted ...
var meeting = JSON.stringify(lastMeeting)

// Use LPUSH & LTRIM in tandem
client.lpush('recent_meetings', meeting, function(err, reply) {
  client.ltrim('recent_meetings', 0, 9) // 10 Items Max
})

and for good measure, using my new CoffeeScript skills, the same thing:

1
2
3
4
5
6
7
redis = require("redis")
client = redis.createClient()
#... on last meeting submitted ...
meeting = JSON.stringify lastMeeting

client.lpush 'recent_meetings', meeting, (err, reply) ->
  client.ltrim('recent_meetings', 0, 9) # 10 Items Max

P.S. This gif of Eric Allam & Gregg Pollack cracks me up no end…

Comments