Skip to main content

Posts

Showing posts with the label node.js

require()"ing a CoffeeScript file from a JavaScript file or REPL

I'm using Node.js and wanting to incorporate CoffeeScript into my workflow. I have two use-cases: I want to be able to write JavaScript files which require() CoffeeScript modules I want to be able to load CoffeeScript modules from within the node REPL For case #1 I can just compile from .coffee to .js and require() the .js module, as a workaround. For case #2 right now I'm eval()'ing the output of coffee-script.compile(). Is there a better, more unified way to do this? Source: Tips4all

Differences between node.js and Tornado

Besides the fact that node.js is written in JS and Tornado in Python, what are some of the differences between the two? They're both non-blocking asynchronous web servers, right? Why choose one over the other besides the language? Source: Tips4all

Why does JSON.stringify screw up my datetime object?

{ id: 1533, story_type_id: 1, content_id: 470, created_at: Sun, 05 Feb 2012 07:02:43 GMT, updated_at: Sun, 05 Feb 2012 07:02:43 GMT, type_name: 'post' } I have a JSON object with the "datetime" field like above. It's perfect. But when I stringify it (I want to store it in cache), I get this format: "created_at":"2012-02-05T07:02:43.000Z" This causes problems, because when I want to JSON.parse this, suddenly it's no longer datetime format and it's incompatible with my other format. What can I do to solve this problem? I have 'created_at' littered everywhere throughout my application. I don't want to manually change each one.

why is that object declaration works in node.js and how to declare static variable?

i have seen this code : var myNet = require ("net"); and in some function: function foo (x,y) { var myNewNet = new myNet(); myNewNet.createServer(x,y); } why does the code above create a new object? what is the mechanism stands behind that? one more question, how do i create a static var in node.js, for example a id number that has to be unique. i came with this option for static variable: var id =0; and put it on the global scope, is it ok?

Syncing dnode and Express authentication - How?

I'm building a web app with Express and dnode and I'm trying to synchronize authentication between the two. I found the following example, but the 'sessionCheck' event doesn't appear to be firing on the connection object: http://repos.io/project/github/tblobaum/dnode-session/ Anybody have input for how to correctly synchronize auth between Express and dnode using sessions? Thanks, Matt