node

JSpec no longer supported?

Coming from the Ruby community I'm looking for a BDD-testing framework for Javascript/Node.js. I was JSpec and thought it would be the right choice because I used RSpec in Ruby. But on their GitHub page http://github.com/visionmedia/jspec it says it's no longer supported. They are abandoning this project? Does this mean I shouldn't u...

how to find number of nodes in loop of linked list?

how to find the number of nodes in a loop of linked list? for e.g A ----> B ----> C -----> D -----> E Λ | | | | V H <----- G <----- F Find the number of nodes in a loop from C to H Fundamental problem is how to find poin...

In Drupal, how to set node-[content type].tpl.php to display 404 Error?

In Drupal 6, I would like to have certain Content Types display Error 404, when accessed. I don't want them indexed by search engines or being accessible to users. They are used to store data, such as photos or other attachments. I've tried setting node-[content type].tpl.php to <?php return drupal_not_found(); but it duplicates the ...

Share variables between modules in Javascript/node.js?

I have 3 node files: // run.js require('./configurations/modules'); require('./configurations/application'); // modules.js var express = module.exports.express = require('express'); var app = module.exports.app = express.createServer(); // app.js app.configure(...) Run.js requires both files, modules.js which require a module and...

Global variables between files in Node.js?

Here are 2 files: // main.js require('./modules'); console.log(name); // prints "foobar" // module.js name = "foobar"; When I don't have "var" it works. But when I have: // module.js var name = "foobar"; name will be undefined in main.js. I have heard that global variables are bad and you better use "var" before the references. B...

MongoDB console javascript can't be used in application?

At the MongoDB developer zone you can learn all the MongoDB console javascript API to use for document CRUD operations. I wonder, do all these javascript functions only work on the MongoDB console? I learn all that just to use it for administrative tasks or can I use them in my javascript application (node) as well? ...

Getting the line number and column number from a org.w3c.dom.Node

I know that you can get the line number and column number from a org.xml.sax.SAXParseException. Is it possible to get the line number and column number from a org.w3c.dom.Node? ...

Grab any Text Node within the BODY using Jquery

Hoping someone can help. I need to grab any text node inside the body. Even if it is NOT contained within any other element. I've tried: $("p, div, html, body").each(function(){ $(this).contents().filter(function() { var regExText = /(\w|\d|,|;|&)/; if (this.nodeType == 3 ...

Get offset of node in whole html document in Javascript?

I'm looking for a way to get the offset relative to the whole document for a given node with Javascript. Eg.: <html><head></head><body><div id="mainContent"><h1 id="myTitle">Title</h1><p>First paragraph</p><p>Second <b>paragraph</b></p></div></body></html> Then (using JQuery): $("#myTitle").getDocumentOffset() should return 47 beca...

In a tree data structure, is a node a sibling of itself?

I am building a tree like data structure. What is the expected behavior if I have a method public Set getSiblingNodes(Node node); Should this method return a set including or excluding itself? Thanks! ...

How to use JSON2 in Node.js

I want to use json2 as JSON.parse in node.js, (forgive the stupid question) I can't quite figure out how to use it. I have a copy of json2.js, with the first line removed in my current working directory. Then, from the node.js shell i do: > orig_func = JSON.parse [Function: parse] > require('json2') { JSON: {} } > orig_func === JSON.par...

Node.js installation: openssl not installed

I have installed libssl-dev and openssl but I get this when I install node.js: > ./configure && make && make install Checking for program g++ or c++ : /usr/bin/g++ ...

NetworkX node attribute drawing

Im using networkx for visualization. I see when I use the function draw_networkx_edge_labels I can retrieve the labels for edges. I want to print the attribute on node ( instead of the label).. try everything almost . still stuck. If i have 5 attributes per node, is there anyway I can print a specific attribute on each node ? For exam...

Low-level javascript framework that abstracts away html/css?

Honestly, now when we have so many javascript features on the frontend I really wish javascript in the browsers could replace html and css entirely. We could deal with objects (structure + design + functionality) instead of html elements and css that style these elements. But since that is never going to happen, I wonder if there is an...

How bad is to use void pointer in std::vector declaration?

I have to different classe: class text { }; class element { }; And I want to store them in the class node: template <typename T> class node { T cargo; std::vector<void*> children; node(T cargo) : cargo(cargo) { }; void add_child(T node) { this->children.push_back((void*) node); } } So I would...

Are closures different in node.js?

I have worked quite a lot with javascript but yesterday, I started using node.js. It's a little script that runs jslint on the files of a folder. For this example, I changed the command to call ls instead of jslint. var sys = require("sys"); var fs = require("fs"); var cp = require('child_process'); var path = fs.realpathSync("./src/")...

Queue appending more then one entry.

I keep getting the first entry appended 4 times instead of one time.. when I append my first entry to the Queue it appends it 4 times..I thought this might be the problem..but it looks like it isn't. I can't find where the problem is.. I also created a print function for the nodes, and it showes that there are 4 of the same entries in t...

Node.JS General Comet Inquiry

I'm trying to take up node.js for a comet-based program. Essentially I'm going to have information coming in from either an SQL database or a XML feed, but the end result needs to be the same. I'm confused upon the implementation and here's my road blocks, help would be greatly appreciated. Streaming - I've been able to build simple mo...

Restful communication between local applications is a good idea?

I wonder if it's a good idea letting local applications (in the same server) communicate with each other entirely through Restful API? I know this is not an uncommon thing, cause we already have applications like CouchDB that is using HTTP REST for communication, even with local applications. But I want to take it to a higher level by ...

dom childNodes issue

I seem to be getting different results of fromDate between Mozilla and IE. Is there a more reliable cross-browser way of doing this? [edit] I am actually getting different column values! [/edit] <tr id='id3332201010241' /> <td>20101024</td> <td>20101025</td> <td>1415</td> <td>1445</td> <td>INVDROP</td> <td>H4T1A3</td> <td><a...