[nodejs] node-mongo-native findOne 2 values

2012-03-20 Thread john.tiger
having a problem: function (param1,param2, callback) { coll.findOne({"user":param1, "phone":param2},function(err,cb){ => returns null if param1 and param2 subsituted with "john" and "999-999-" => works thus findOne wants values in quotes - should it be this way ? best way to handle

Re: [nodejs] Request for feedback: Native addon memory management

2012-03-20 Thread Ben Noordhuis
On Wed, Mar 21, 2012 at 03:21, Matt Gollob wrote: > Hello everyone - > > I'd like some feedback with regard to a sample addon I've put together for > node to demonstrate exposing a C++ library to javascript.  In particular, > I'm struggling with how to properly manage memory allocated from C++ whe

Re: [nodejs] local npm mirror not behaving

2012-03-20 Thread Martin Cooper
On Tue, Mar 20, 2012 at 2:44 PM, Troy wrote: > I don't know why npm is dropping the  /registry/_design/app/_rewrite/ > from the path.  Or what configuration I'm missing to fix this problem. If you haven't already, you might try adding a vhost config, as described under "top-of-host urls" here:

[nodejs] Request for feedback: Native addon memory management

2012-03-20 Thread Matt Gollob
Hello everyone - I'd like some feedback with regard to a sample addon I've put together for node to demonstrate exposing a C++ library to javascript. In particular, I'm struggling with how to properly manage memory allocated from C++ when its lifetime is coupled to the lifetime of a javascript

[nodejs] [ANN] reified, Binary Data API for Node + Browsers. Powerful, easy to use, and performance conscious. ES6 binary data spec inspired.

2012-03-20 Thread Brandon Benvie
*First off a disclaimer. This library is very new and not battle tested at all. Probably has bugs. However it has come together rapidly and is ready for people to start banging on it at least. * Binary data structure toolkit of awesomeness: https://github.com/Benvie/reified It's for defining

Re: [nodejs] Stream Memory Pressure causing high CPU utilization?

2012-03-20 Thread C. Mundi
Thanks. I really appreciate your insight into how node scales! On Mar 20, 2012 6:32 PM, "Ben Noordhuis" wrote: > On Wed, Mar 21, 2012 at 02:21, C. Mundi wrote: > > Aha! Thank you, Ben. Your point #2 is especially informative. > > > > Matt's code and mine both show that creating oodles of Buf

Re: [nodejs] _chmod taking large amounts of execution time

2012-03-20 Thread Patrick Quinn
Quick update: I found the problem. I was being a little clever with prototype inheritance. I had a master instance of certain objects. At the start of every game, I'd create a new class/function whose prototype pointed to said instance. I set up ~6 of these ad hoc classes per game, and I cal

Re: [nodejs] Stream Memory Pressure causing high CPU utilization?

2012-03-20 Thread Ben Noordhuis
On Wed, Mar 21, 2012 at 02:21, C. Mundi wrote: > Aha!  Thank you, Ben.  Your point #2 is especially informative. > > Matt's code and mine both show that creating oodles of Buffers (whether > explicitly or implicitly) is not a serious bottleneck compared to the queue > handling. Right, in this cas

Re: [nodejs] Stream Memory Pressure causing high CPU utilization?

2012-03-20 Thread C. Mundi
Aha! Thank you, Ben. Your point #2 is especially informative. Matt's code and mine both show that creating oodles of Buffers (whether explicitly or implicitly) is not a serious bottleneck compared to the queue handling. Processing the resulting queue of writes is the issue with impact. I did

[nodejs] Re: a good practice to handle date

2012-03-20 Thread mscdex
On Mar 20, 8:03 pm, Angelo Chen wrote: > when a json is json.stringify and parse back to json later, the date > is different: Right, because there is no special Date type in JSON, it has to convert it to a string. When parsing that string back again, the JSON parser can't assume any strings are n

Re: [nodejs] Stream Memory Pressure causing high CPU utilization?

2012-03-20 Thread Ben Noordhuis
On Tue, Mar 20, 2012 at 22:44, C. Mundi wrote: > Hi Matt, > > You probably know better than me, but it's not obvious to me that these two > examples (both interesting) are especially similar.  For one thing, your > example creates a new buffer on every iteration.  My example leaves > allocation en

Re: [nodejs] Is there a way to install node.js on mac os without sudo?

2012-03-20 Thread DrBloodmoney
On Tue, Mar 20, 2012 at 8:31 AM, Alexey Petrushin wrote: > As far as I know there's currently 2 ways to install node on mac: > > 1. As `brew install node`. It doesn't require sudo, but npm sometimes > doesn't work as expected (can't find some packages). > 2. As installer from nodejs.org. It works

Re: [nodejs] Weird dependency installation behaviour with NPM ?

2012-03-20 Thread Fredrik Larsson
Thanks Matt, That makes sense. I guess this happens when the modules has a dependency on a specific version or range of versions of a modules. Now I'll take ryandesign's advice and move on. On Wednesday, March 21, 2012 1:19:18 AM UTC+1, Matt wrote: > > I believe the reason it does this is so t

Re: [nodejs] Weird dependency installation behaviour with NPM ?

2012-03-20 Thread Matt Patenaude
I believe the reason it does this is so that packages may have differently-versioned dependencies. Right now they're the same, but let's say the top-level package upgraded to a newer version of formidable that connect was not prepared to support. It would be necessary for connect to have its own

Re: [nodejs] Weird dependency installation behaviour with NPM ?

2012-03-20 Thread Ryan Schmidt
On Mar 20, 2012, at 18:29, Fredrik Larsson wrote: > I don't know if I just don't understand why and there is a really good reason > why it behaves the way it does. > I tried searching but I could not find anything relevant and the docs were > equally uninformative regarding this type of problem

[nodejs] local npm mirror not behaving

2012-03-20 Thread Troy
I have setup a local npm mirror using the instructions from the great wereHamster https://blog.caurea.org/2012/01/31/local-npm-registry-mirror.html When I try to install I get the following # npm --registry http://localhost:5984/registry/_design/app/_rewrite install mongo npm http GET http://loca

[nodejs] Everyauth and Pusher webhooks

2012-03-20 Thread EHNole
Hi, is there a trick to getting these two to play nice? Whenever I use everyauth, I get a 'webhook denied' error when I try to subscribe to a channel. I assume it has something to do with the auth middleware. The app is pretty basic: var app = express.createServer(); app.configure(function() {

[nodejs] Weird dependency installation behaviour with NPM ?

2012-03-20 Thread Fredrik Larsson
I don't know if I just don't understand why and there is a really good reason why it behaves the way it does. I tried searching but I could not find anything relevant and the docs were equally uninformative regarding this type of problem. I might be a neat-freak but I dislike the same modules be

[nodejs] Re: a good practice to handle date

2012-03-20 Thread Angelo Chen
when a json is json.stringify and parse back to json later, the date is different: var d = {"id":1, "d":new Date()} //{ id: 1, d: Tue, 20 Mar 2012 23:55:10 GMT } s = JSON.stringify(d) //'{"id":1,"d":"2012-03-20T23:55:10.352Z"}' b = JSON.parse(s) //{ id: 1, d: '2012-03-20T23:55:10.352Z' } O

Re: [nodejs] NodeConf 2012

2012-03-20 Thread Dan Shaw
Final details are still forthcoming. We talked about it a bit on NodeUp 15. http://nodeup.com/fifteen Daniel Shaw @dshaw -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscr

Re: [nodejs] NodeConf 2012

2012-03-20 Thread Isaac Schlueter
Yes. It is going to be the best tech conference that has ever been. More details coming soon. On Tue, Mar 20, 2012 at 16:20, Wes Gamble wrote: > All, > > I found out that there is apparently going to be a Node.js conference in > Portland this summer. > > Is there any other information about it

[nodejs] NodeConf 2012

2012-03-20 Thread Wes Gamble
All, I found out that there is apparently going to be a Node.js conference in Portland this summer. Is there any other information about it besides what is shown here: http://www.nodeconf.com/ ? Thanks, Wes -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyen

Re: [nodejs] nvm and npm global installs

2012-03-20 Thread Isaac Schlueter
You can work around this issue in nave using named environments. ``` nave use foo 0.6.9 # installs node v0.6.9, links it into a named env "foo" npm install -g glob npm ls -g # shows glob there. # work work work # time goes by # from the outside: nave use foo 0.6.13 # upgrades foo to use 0.6.13 i

Re: [nodejs] Stream Memory Pressure causing high CPU utilization?

2012-03-20 Thread C. Mundi
Hi Matt, You probably know better than me, but it's not obvious to me that these two examples (both interesting) are especially similar. For one thing, your example creates a new buffer on every iteration. My example leaves allocation entirely to streams to decide when to buffer and in what size

Re: [nodejs] Stream Memory Pressure causing high CPU utilization?

2012-03-20 Thread Matt
Try this test instead, I bet it gives you the same performance characteristics: var a = []; for (i=0; i wrote: > Yes. I am deliberately abusing the stream with the goal of understanding > behavior. > > I would like to understand why it drains so slowly to disk, on the order > of a few KB/sec. I

Re: [nodejs] Re: authentication scheme / model

2012-03-20 Thread shawn wilson
On Tue, Mar 20, 2012 at 12:59, shawn wilson wrote: > On Tue, Mar 20, 2012 at 06:23, Alex Young wrote: > >> >> I feel like everyauth is currently the best solution for this -- I've used >> it in a few projects and I prefer it to building my own. >> > > i guess my concern with everyauth is that i d

Re: [nodejs] Stream Memory Pressure causing high CPU utilization?

2012-03-20 Thread C. Mundi
Yes. I am deliberately abusing the stream with the goal of understanding behavior. I would like to understand why it drains so slowly to disk, on the order of a few KB/sec. I would imagine that a stream created specifically with a file as its drain would be implemented to dump the biggest chunks

Re: [nodejs] Stream Memory Pressure causing high CPU utilization?

2012-03-20 Thread Matt
You're not "streaming" data into the stream. You're pumping it full as quickly as possible and letting it drain in its own time. Obviously this is sub-optimal. On Tue, Mar 20, 2012 at 3:20 PM, C. Mundi wrote: > > Hi. I am trying to learn how to use streams properly in node. > > The attached scr

[nodejs] Stream Memory Pressure causing high CPU utilization?

2012-03-20 Thread C. Mundi
Hi. I am trying to learn how to use streams properly in node. The attached script stakes a single argv parameter N and writes 2^N bytes to a file via a stream. I expect time behavior O(2^N). But what I am seeing is scaling faster. I collected data like this in bash on Linux 3.0.0.-16 x64: for

Re: [nodejs] nvm and npm global installs

2012-03-20 Thread Mark Hahn
Thx a lot. Should I save this message or is it documented somewhere i can save a link to? On Tue, Mar 20, 2012 at 11:48 AM, Tim Caswell wrote: > > > On Tue, Mar 20, 2012 at 1:18 PM, Mark Hahn wrote: > >> Don't I have to install coffee-script globally to be able to use the >> `coffee` as a comm

Re: [nodejs] Re: working with synchronous libraries

2012-03-20 Thread Tim Caswell
As cool as streamline is, I don't think it will work for this case since it would have to transform backbone itself in order to use the transformed I/O calls. Backbone uses _ for something completely different, so I don't expect that to work out very well. The root problem is you're trying to use

Re: [nodejs] nvm and npm global installs

2012-03-20 Thread Tim Caswell
On Tue, Mar 20, 2012 at 1:18 PM, Mark Hahn wrote: > Don't I have to install coffee-script globally to be able to use the > `coffee` as a command anywhere? Same with node-dev, node-inspector, etc. Right, they have to be installed somewhere in your $PATH. This doesn't have to be the "global" pl

[nodejs] Re: working with synchronous libraries

2012-03-20 Thread Alexey Petrushin
> If you could give me a bit more detailed solution on using fibers, I would be really happy. Don't know if this helps, it's a sample of how to use fibers to make API of MongoDB driver looks like synchronous. http://alexeypetrushin.github.com/mongo-model/synchronous.html On Tuesday, March 20, 20

Re: [nodejs] nvm and npm global installs

2012-03-20 Thread Mark Hahn
Don't I have to install coffee-script globally to be able to use the `coffee` as a command anywhere? Same with node-dev, node-inspector, etc. On Tue, Mar 20, 2012 at 10:40 AM, Tim Caswell wrote: > Keep in mind that it's best to not install libraries globally. It safer > to just declare your de

Re: [nodejs] nvm and npm global installs

2012-03-20 Thread Tim Caswell
Keep in mind that it's best to not install libraries globally. It safer to just declare your dependencies in your app's package.json and install them locally using `npm install`. This prevents a world of headache with version mismatches. I only use global installs for things like `lessc` `share`

Re: [nodejs] nvm and npm global installs

2012-03-20 Thread Mark Hahn
It is not a big deal since I have only 2 or 3 global modules, but I got tripped up when releasing to another server with different nvm location. I'll take your suggestion to use a common install dir and put it in the path. I didn't know modules were searched by path. On Tue, Mar 20, 2012 at 10:3

Re: [nodejs] nvm and npm global installs

2012-03-20 Thread C. Mundi
I used to do something like this... Install global modules to a version-agnostic /use/local/share/node_modules and always export NODE_PATH (or similar). But what I found is that I ended up chasing breaking changes when updating node anyway. So I have jumped on the wagon and now the only thing I

Re: [nodejs] nvm and npm global installs

2012-03-20 Thread Tim Caswell
"global" installs install into the node directory. nvm doesn't upgrade node in-place so each new version of node is a new version. What you can do it not install npm modules "global"ly. If you must have them everywhere (like command-line scripts) install then in $HOME or something and put $HOME

Re: [nodejs] Re: how to avoid a call back in this case?

2012-03-20 Thread Oliver Leics
Strange :-) On Tue, Mar 20, 2012 at 4:02 PM, Angelo Chen wrote: > this works, here is the final version, thanks: > > exports.get_list = function (cb) { >  rclient.smembers("list", function (err, members) { >    var len = members.length >    members.forEach(function (member) { >      console.log(m

[nodejs] Re: a good practice to handle date

2012-03-20 Thread mscdex
On Mar 20, 10:20 am, Dale Tan wrote: > var date = +new Date() > // save it in redis or `Date.now()` :-) -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Goog

[nodejs] nvm and npm global installs

2012-03-20 Thread Mark Hahn
I love nvm and npm. However, whenever I switch to a new version of node with nvm I have to reinstall all my global npm modules. Apparently the global modules are stored in the node directory which is created anew. Is my setup normal? Is there a way around this problem? -- Job Board: http://j

Re: [nodejs] Re: authentication scheme / model

2012-03-20 Thread shawn wilson
On Tue, Mar 20, 2012 at 06:23, Alex Young wrote: > > I feel like everyauth is currently the best solution for this -- I've used > it in a few projects and I prefer it to building my own. > i guess my concern with everyauth is that i don't see where / how it is salting local passwords (as i indic

Re: [nodejs] Re: working with synchronous libraries

2012-03-20 Thread Axel Kittenberger
> Actually, wrt your first option. I can not go with fibers as I plan to use > nodejitsu first, and you can't install compiled code. But even if I could, I > could not figure out how to do it with a fibers alternative that we use, > async. How about streamline? Once you jump over your shadow to ac

[nodejs] Fabric Engine v1.0 released under AGPL

2012-03-20 Thread Fabric Paul
Hi everyone - just letting you know that we released v1.0 of Fabric Engine today. We've open-sourced the core under AGPL, so I hope that gives you an incentive to get started with high-performance for node :) http://www.fabricengine.com http://fabricengine.com/technology/benchmarks/ - to give you

[nodejs] Re: working with synchronous libraries

2012-03-20 Thread Bika
Yeah, these are those 3 solutions that I wanted to avoid. :) Actually, wrt your first option. I can not go with fibers as I plan to use nodejitsu first, and you can't install compiled code. But even if I could, I could not figure out how to do it with a fibers alternative that we use, async. I

[nodejs] Re: working with synchronous libraries

2012-03-20 Thread Alexey Petrushin
I believe there may be 3 possible solutions: - You may try to use fibers to make Your async code looks like a sync. I gues it may work, but I'm not sure about it. - Hack Backbone Model, it's sources are small and clear and it shouldn't be too complex. - Create Your own async model. You can use a

Re: [nodejs] Is there a way to install node.js on mac os without sudo?

2012-03-20 Thread Jorge
On Mar 20, 2012, at 1:31 PM, Alexey Petrushin wrote: > As far as I know there's currently 2 ways to install node on mac: > > 1. As `brew install node`. It doesn't require sudo, but npm sometimes doesn't > work as expected (can't find some packages). > 2. As installer from nodejs.org. It works bu

[nodejs] Re: Is there a way to install node.js on mac os without sudo?

2012-03-20 Thread Alexey Petrushin
Thanks, for answers. I installed it without 'sudo' by installing from sources via 'make install', it seems that it works ok. > Homebrew installs a version of node which does not include npm, but > you can install npm afterwards manually. And I haven't seen an issue > with using it this way - ca

Re: [nodejs] Does anyone recognize this error?

2012-03-20 Thread C. Mundi
Ok. I was looking to get as much info (if any more exists) as possible with my release build but I will make a debug build. My luck (nothing to so with node) is that I find issues which show up only in release. I will report back what I find...may be a couple days. Thanks! On Mar 20, 2012 4:17

Re: [nodejs] Re: Is there a way to install node.js on mac os without sudo?

2012-03-20 Thread Chris Rhoden
On Tue, Mar 20, 2012 at 10:58 AM, deitch wrote: > Go for the installer, but change your node dir to ~/local. That is what I > do, it works very well. TJ's amazing n also picks up on it. This is the source, not the installer. I have already addressed this. If you use homebrew, the /usr/local/ d

Re: [nodejs] Any IPC speedups planned?

2012-03-20 Thread Steven Campbell
I thought it was, but I am unable to reproduce in current Node 0.6.13 (may have been an issue in 0.6.6 - where I originally benchmarked it) It is actually working pretty well for me right now :) On Tuesday, March 20, 2012 9:08:26 AM UTC-5, Ben Noordhuis wrote: > > On Tue, Mar 20, 2012 at 15:04,

[nodejs] Re: how to avoid a call back in this case?

2012-03-20 Thread Angelo Chen
this works, here is the final version, thanks: exports.get_list = function (cb) { rclient.smembers("list", function (err, members) { var len = members.length members.forEach(function (member) { console.log(member) rclient.hgetall(member, function (err, item) { console

[nodejs] Re: Is there a way to install node.js on mac os without sudo?

2012-03-20 Thread deitch
Go for the installer, but change your node dir to ~/local. That is what I do, it works very well. TJ's amazing n also picks up on it. After you download, do ./configure --prefix=~/local make make install and it will do the right thing. It is available here https://github.com/joyent/node/wiki/I

Re: [nodejs] Re: a good practice to handle date

2012-03-20 Thread Dale Tan
You can try converting the date to epoch instead and then converting it back to a date (on my iPhone so please excuse any mistakes and psuedo code): var date = +new Date() // save it in redis // retrieve from redis var date = new Date(redis_date) I believe that should work. --- dale On Mar 2

Re: [nodejs] Re: a good practice to handle date

2012-03-20 Thread Matt
Also you can skip the .parse() part in that (although it's done internally, obviously): > var d = new Date(); undefined > d Tue, 20 Mar 2012 14:09:58 GMT > new Date(d.toISOString()); Tue, 20 Mar 2012 14:09:58 GMT On Tue, Mar 20, 2012 at 3:59 AM, mscdex wrote: > On Mar 20, 3:42 am, Angelo Che

Re: [nodejs] Any IPC speedups planned?

2012-03-20 Thread Ben Noordhuis
On Tue, Mar 20, 2012 at 15:04, Steven Campbell wrote: > I saw in 0.7 there is work going on with the clustering API.   As part of > that (or separately), are there any plans to speed up the default IPC > available with child_process.fork?  For example, possible improvements: > > * make process.sen

[nodejs] Any IPC speedups planned?

2012-03-20 Thread Steven Campbell
I saw in 0.7 there is work going on with the clustering API. As part of that (or separately), are there any plans to speed up the default IPC available with child_process.fork? For example, possible improvements: * make process.send async (https://github.com/joyent/node/issues/2598) * improve

Re: [nodejs] Is there a way to install node.js on mac os without sudo?

2012-03-20 Thread Brian Kaney
You could also try nvm (https://github.com/creationix/nvm). -- Brian On Mar 20, 2012, at 8:31 AM, Alexey Petrushin wrote: > As far as I know there's currently 2 ways to install node on mac: > > 1. As `brew install node`. It doesn't require sudo, but npm sometimes doesn't > work as expected (c

Re: [nodejs] Re: how to avoid a call back in this case?

2012-03-20 Thread Toshihiro Nakamura
Hi, you can solve the problem with gate(https://github.com/nakamura-to/gate) and parray(https://github.com/nakamura-to/parray). Thanks. var gate = require('gate'); var parray = require('parray'); exports.get_list = function ( cb) { rclient.smembers("list", function(err, members) {

Re: [nodejs] Re: how to avoid a call back in this case?

2012-03-20 Thread Oliver Leics
> since forEach is a synchronous as you pointed out, cb got called at > end of the loop, that's what I was expecting, but when every iteration > also calls an asynchronous callback, that will be different as those > asynchronous calls in fact happens after the cb(null, 'lst'), how to > deal with th

Re: [nodejs] Is there a way to install node.js on mac os without sudo?

2012-03-20 Thread Chris Rhoden
Alexey, What issues do you have with npm and homebrew? Homebrew installs a version of node which does not include npm, but you can install npm afterwards manually. And I haven't seen an issue with using it this way - can you elaborate on the issue? FWIW, the only issue is of folder permissions.

[nodejs] Is there a way to install node.js on mac os without sudo?

2012-03-20 Thread Alexey Petrushin
As far as I know there's currently 2 ways to install node on mac: 1. As `brew install node`. It doesn't require sudo, but npm sometimes doesn't work as expected (can't find some packages). 2. As installer from nodejs.org. It works but requires sudo. Maybe there's any way to install it without su

Re: [nodejs] keep alive webserver

2012-03-20 Thread HG
Hi! I was just down this same road. This is the upstart script that I ended up with on my system (RH 6.1): #!upstart description "NodeApp - node.js HTTP-server" author "Me" # One example said that it's safer to start after mounts #start on startup start on started mountall stop on shutdown

Re: [nodejs] Does anyone recognize this error?

2012-03-20 Thread Ben Noordhuis
On Tue, Mar 20, 2012 at 06:44, C. Mundi wrote: > I apologize for asking without posting code, but I have not yet finished > isolating the code which throws this. > > Here is the error.  No line numbers, no stack trace: > > terminate called after throwing an instance of 'std::bad_alloc' >   what():

[nodejs] working with synchronous libraries

2012-03-20 Thread }--) - Viktor
hi, I'm trying to use backbone for "everything" on the server side too, and got stuck with doing a proper validation. The problem is that backbone's validate method return a boolean, and the validation mechanics should be implemented inside of it, but with node these mechanics are asynchronous, th

Re: [nodejs] Re: how to avoid a call back in this case?

2012-03-20 Thread Aria Stewart
Because forEach uses a function to call back, but is not asynchronous. A function not doing I/O can choose when it calls your function. forEach takes the easy path and just calls its callback in a loop one after another. Angelo Chen wrote: >one confusing thing for newbies like me: > >expo

[nodejs] Re: how to avoid a call back in this case?

2012-03-20 Thread Angelo Chen
the all in 'hgetall' actually means getting all the properties of that member, so for every member it reads the data in, trying out your modification, the cb(null, 'lst') was called multiple times. this is quite a interesting question: members.forEach(function(member) { }) cb(null, 'lst‘) sinc

[nodejs] Re: authentication scheme / model

2012-03-20 Thread Alex Young
On Monday, March 19, 2012 5:48:30 PM UTC, shawn wilson wrote: > > what's the best locally stored authentication scheme? > > i've found a few: > http://dailyjs.com/2011/01/10/node-tutorial-9/ > https://github.com/ncb000gt/node.bcrypt.js/tree/master/examples > > https://github.com/Turbo87/locomotive-

Re: [nodejs] Re: how to avoid a call back in this case?

2012-03-20 Thread Oliver Leics
The "all" in "hgetall" makes me think it gives me a list. Maybe not what you did expect, because I assumed that rclient.hgetall gives all items to the callback, not only one item. exports.get_list = function ( cb) { rclient.smembers("list", function(err, members) { if(err) { return cb(err);

[nodejs] Re: how to avoid a call back in this case?

2012-03-20 Thread Angelo Chen
ok, i see the point, it is syncronous, then when it was mixed with asynchronous callbacks, how to deal with this? here is an example, cb should be called after all member has been console.log, but it turn out different: exports.get_list = function ( cb) { rclient.smembers("list",

Re: [nodejs] Re: how to avoid a call back in this case?

2012-03-20 Thread Oliver Leics
On Tue, Mar 20, 2012 at 10:58 AM, Angelo Chen wrote: > the function(member) for 'forEach' is callback, right? then why, > cb(null,'lst') will wait until the loop is over? .forEach on arrays is syncronous. Like Bruno sayed, dont equate "asynchronous" with "callbacks" -- Job Board: http://jobs.no

[nodejs] Re: how to avoid a call back in this case?

2012-03-20 Thread Angelo Chen
one confusing thing for newbies like me: exports.get_list = function ( cb) { rclient.smembers("list", function(err, members) { members.forEach(function(member){ console.log(member) })

Re: [nodejs] Re: how to avoid a call back in this case?

2012-03-20 Thread Oliver Leics
On Tue, Mar 20, 2012 at 8:47 AM, Bruno Jouhier wrote: > >     var next_id = rclient.incr("next_id", _); > > This code is asynchronous. And the underscore marker indicates where the > code may yield. So nothing's hidden and the execution model is the same as > with async callbacks: non blocking, si

[nodejs] Re: a good practice to handle date

2012-03-20 Thread mscdex
On Mar 20, 3:42 am, Angelo Chen wrote: > tried var d = new Date() > s = d.toISOString() > it saves as a string, but Date.parse(s) seems not converting it back > correctly, any hints? Date.parse returns a unix timestamp, so you need `new Date(s)` to get an actual Date object. This works for me wi

[nodejs] Re: how to avoid a call back in this case?

2012-03-20 Thread Bruno Jouhier
You cannot say that "there isn't a way to get rid of callbacks", because there ARE ways. Solutions like streamline.js or fibers DO EXIST and have been around for a more than a year. They allow you to write non bocking code without callbacks. Maybe you don't like these solutions but that's a di

[nodejs] a good practice to handle date

2012-03-20 Thread Angelo Chen
Hi, I use redis to store data, how to save the datetime data in redis that can be easily used later back to javascript? tried var d = new Date() s = d.toISOString() it saves as a string, but Date.parse(s) seems not converting it back correctly, any hints? Thanks, -- Job Board: http://jobs.node

Re: [nodejs] Re: deployment problem with upstart: multiple instances

2012-03-20 Thread HG
Uh, oh... yes, that's it :*) Thanks!! On Mon, Mar 19, 2012 at 10:58 PM, Steven Campbell wrote: > Possibly the ampersand at the end of the exec line? > > > On Monday, March 19, 2012 7:26:51 AM UTC-5, HG wrote: >> >> Hi! >> >> Can you tell me what I'm doing wrong. I'm trying to deploy to Redhat 6.1