VIVAHATE

March 2011

A Simple Chat Room in Node.js

In this post, we’ll be building a simple chat room using node.js. Here’s how it’ll look:

Getting Started

Install node, socket.io, and express

First, make sure you’ve installed node.js. You’ll also want to grab a copy of the socket.io library and the express framework. These can both be installed with npm via the express and socket.io packages.

Directory Structure

Before we cover each file in detail, here’s how everything fits together. Place the chat directory wherever you like, mine is in ~/projects/chat.

$ ls -R chat
chat/:
public  server.js

chat/public:
client  index.html

chat/public/client:
socket.io.js

server.js

index.html

Coming Soon…

Next time, we’ll bring canvas to the party. Here’s a preview of what we’ll be building in the next installment:

McMurdo

Lately, Cyclops and Max have been watching the McMurdo Station Webcam. They requested this script after they got sick of saving images manually and searching for ways to animate them.

Uses the excellent Beautiful Soup library, which makes HTML parsing a snap. The program saves images named 1.jpg, 2.jpg, etc. every few seconds. Because the filename on this partiular webcam changes with each new image, we have to rescrape the page each time we want a new image.

Cyclops runs Windows, but this stuff should run wherever Python and ffmpeg are available.

mcmurdo.py

encode.bat

Videos


Mesquite Smoked Turkey Leg with Barley and Spring Onions

Nyx 0.0.2

What’s New?

  • Nyx is now hosted on GitHub
  • Vertex buffer objects
  • Supports Python 3
  • OBJ model support

Example

Screenshots

304,135 triangles. The transparency is just so that we can see a little more detail.
Since there’s no support for lighting yet, without the transparency all we’d
see would be a silhouette.

Notes

The OBJ loader is implemented in 18 lines of Python. There is no error checking and it only supports vertices and triangles, but it loads models exported from Blender just fine. Neat.