Re: [nodejs] How to report errors from streams

2013-06-17 Thread Dan Milon
You can wrap `spawn` in a `setImmediate`, so that others get a chance to
attach their events.

On 06/18/2013 04:19 AM, Ryan Schmidt wrote:
> Per previous threads, I'm implementing a transform stream around a particular 
> command line program for use in a web service. How should the stream report 
> errors?
> 
> In the case of the _transform and _flush functions that I'm supposed to 
> implement, they're given a callback parameter, so I can "callback(new 
> Error(…))". That's easy, but what about in other situations, like the 
> constructor?
> 
> In the constructor of my custom transform stream, I spawn a process:
> 
>   var process = this._process = spawn(options.command, options.args, 
> options.env);
> 
> If the process closes with a non-zero exit code or crashes, I want to be able 
> to report that, not just to the server's console, but also to the web browser 
> of the user who made the request that started the process:
> 
>   process.on('close', function(code, signal) {
> if (signal !== null) {
>   …
> } else if (code !== 0) {
>   …
> }
> self.emit('close');
>   });
> 
> If a problem occurred, should I "throw new Error(…)" or "self.emit('error', 
> new Error(…)"?
> 
> I was emitting the error, but am having trouble making that work in code 
> running directly in the constructor. Let's say I want to allow only a few 
> different commands ("foo" and "bar") to be run:
> 
>   if (!~['foo', 'bar'].indexOf(options.command)) {
> this.emit('error', new Error('Invalid command: ' + options.command));
>   }
> 
> If I emit an error like that, then the node program exits saying there was no 
> listener attached to the stream listening for the error event. But I cannot 
> attach a listener to the stream until after the constructor has finished and 
> has returned the stream object to me.
> 
> Should I instead throw the error? If so, do I just use a try{}catch{} block 
> whenever I create such a stream?
> 
> 
> Passing Error objects to a callback is straightforward, but other methods of 
> error handling in node are still very confusing to me, especially try/catch. 
> Guidance would be appreciated.
> 
> 



signature.asc
Description: OpenPGP digital signature


Re: [nodejs] Superemitter - EventEmitter prototype - Really fast!

2013-06-17 Thread Dan Milon
`.on` seems a pretty heavy operation given that it crafts a new function
every time. In the real world I assume it's a pretty hot path (take data
listeners for http for example).

It would be interesting to provide a real-world test, with `.on`
benchmarked too.

On 06/18/2013 03:38 AM, Tim Smart wrote:
> For anyone to play around with and maybe develop further:
> 
> https://gist.github.com/tim-smart/5801765
> 
> Has some benchmarks at the bottom of the file, run it and see the results :)
> 
> Idea came from felixge's performance talk on the MySQL client - would love to
> see where this goes as a high-performance simple event-emitter.
> 
> Tim
> 



signature.asc
Description: OpenPGP digital signature


Re: [nodejs] stream.Transform events

2013-04-13 Thread Dan Milon
You're explicitly asking it not to emit an end event by passing end: false to 
pipe. 

On 14 Απρ 2013, at 12:01 π.μ., Ruud  wrote:

> Hey,
> 
> I'm trying to create a streaming parser/transformer for a special web proxy 
> project. The 'streams2' stream.Transform base class makes this quite easy, 
> but trying to benchmark some thing I've hit a problem: it seems no (end) 
> events are emitted.
> 
> The docs don't list any events under this class explicitly, but one would 
> imagine the events from the stream.Readable and stream.Writable are also 
> implemented in stream.Transform.
> 
> My question: Am I doing something wrong, is this by design, or could this be 
> considered a bug?
> 
> Al I could find on the subject is this Stack Overflow question + comment
> 
> Code (more or less):
>> stream = require('stream');
>> function Parser (options) {
>>  if (!(this instanceof Parser)) return new Parser(options);
>>  stream.Transform.call(this, options);
>>  this.options = options || {};
>> }
>> util.inherits(Parser, stream.Transform);
>> Parser.prototype._transform = function(chunk, encoding, done) {
>>  // magic stuff that transforms chunk
>>  this.push(chunk);
>>  done();
>> };
>> 
>> parser = new Parser();
>> parser.on('end', function () {
>>  console.log('This will never happen ???');
>> });
>> req.pipe(parser, {end: false}).pipe(res);
> 
> 
> 
> 
> -- 
> -- 
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>  
> --- 
> You received this message because you are subscribed to the Google Groups 
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to nodejs+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] Intalling an older version of Node via package manager on linux

2013-04-09 Thread Dan Milon
You don't need to uninstall the older version. It gets replaced. Read the 
pacman article on the archlinux wiki for more.

On 9 Απρ 2013, at 10:40 π.μ., NodeNinja  wrote:

> Dan, 
> Yes I'm on archlinux
> 
> does this command 
> $ pacman -U /var/cache/pacman/pkg/nodejs-0.8.12
> 
> install version 0.8.12
> 
> I already have a newer version installed (v0.10.3) how do I uninstall the 
> newer version before installing the old version?
> Thanks
> NodeNinja
> 
> On Tuesday, April 9, 2013 12:59:34 PM UTC+5:30, Dan Milon wrote:
>> 
>> I assume you're on archlinux.
>> 
>> No, the repositories hold only the latest version. If you have previously 
>> installed a previous version you can
>> 
>> $ pacman -U /var/cache/pacman/pkg/nodejs-...
>> 
>> You might wanna hold the package so it doesn't get automatically updated. Or 
>> use nvm if you find yourself changing versions frequently. 
>> 
>> On 9 Απρ 2013, at 9:50 π.μ., NodeNinja  wrote:
>> 
>>> I installed node latest version (v0.10.3) via 
>>> 
>>> pacman -S nodejs
>>> but now I want to go back to an older version
>>> like v0.8.xx
>>> 1. How do I install this version via package manager.
>>> 2. Would I need to uninstall the newer version before doing this?
>>> 
>>> -- 
>>> -- 
>>> 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 Google
>>> Groups "nodejs" group.
>>> To post to this group, send email to nod...@googlegroups.com
>>> To unsubscribe from this group, send email to
>>> nodejs+un...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>>  
>>> --- 
>>> You received this message because you are subscribed to the Google Groups 
>>> "nodejs" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to nodejs+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
> 
> -- 
> -- 
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>  
> --- 
> You received this message because you are subscribed to the Google Groups 
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to nodejs+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] Intalling an older version of Node via package manager on linux

2013-04-09 Thread Dan Milon
I assume you're on archlinux.

No, the repositories hold only the latest version. If you have previously 
installed a previous version you can

$ pacman -U /var/cache/pacman/pkg/nodejs-...

You might wanna hold the package so it doesn't get automatically updated. Or 
use nvm if you find yourself changing versions frequently. 

On 9 Απρ 2013, at 9:50 π.μ., NodeNinja  wrote:

> I installed node latest version (v0.10.3) via 
> 
> pacman -S nodejs
> but now I want to go back to an older version
> like v0.8.xx
> 1. How do I install this version via package manager.
> 2. Would I need to uninstall the newer version before doing this?
> 
> -- 
> -- 
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>  
> --- 
> You received this message because you are subscribed to the Google Groups 
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to nodejs+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] Re: Server Timestamp

2013-04-05 Thread Dan Milon
Read the documentation.

Date.now(), Date#getTime(), etc return the number of milliseconds
since epoch. Whereas php's time() returns seconds. Hence the 3 digit
difference.

Math.round(Date.now() / 1000)

That converts from ms to s.


On 05/04/2013 09:56 μμ, Tolgay Toklar wrote:
> Thanks for answers.
> 
> But there is a problem: Php time() function returns 10 digit 
> number.Javascript Date.now() function returns 13 digit number.How 
> can I resolve this problem ? I can't do process on numbers.
> 
> 5 Nisan 2013 Cuma 18:56:49 UTC+3 tarihinde Tolgay Toklar yazdı:
> 
> Hi
> 
> How can I get server timestamp in nodejs ? (Like a php time() 
> function)
> 
> -- -- 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 Google
> Groups "nodejs" group. To post to this group, send email to 
> nodejs@googlegroups.com To unsubscribe from this group, send email
>  to nodejs+unsubscr...@googlegroups.com For more options, visit 
> this group at http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> --- You received this message because you are subscribed to the 
> Google Groups "nodejs" group. To unsubscribe from this group and 
> stop receiving emails from it, send an email to 
> nodejs+unsubscr...@googlegroups.com. For more options, visit 
> https://groups.google.com/groups/opt_out.
> 
> 


-- 
-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] Server Timestamp

2013-04-05 Thread Dan Milon
If all you need is time elapsed since epoch, you dont wanna do that.
Nor `+new Date()`. They are way more expensive than a plain `Date.now()`.

https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/now


On 05/04/2013 07:02 μμ, Herman Junge wrote:
> console.log(new Date()).getTime();
> 
> On 4/5/13 12:56 PM, Tolgay Toklar wrote:
>> Hi
>> 
>> How can I get server timestamp in nodejs ? (Like a php time()
>> function) -- -- 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 Google
>> Groups "nodejs" group. To post to this group, send email to
>> nodejs@googlegroups.com To unsubscribe from this group, send
>> email to nodejs+unsubscr...@googlegroups.com For more options,
>> visit this group at 
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>> 
>> --- You received this message because you are subscribed to the
>> Google Groups "nodejs" group. To unsubscribe from this group and
>> stop receiving emails from it, send an email to
>> nodejs+unsubscr...@googlegroups.com. For more options, visit
>> https://groups.google.com/groups/opt_out.
>> 
>> 
> 

-- 
-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] Re: [ANN] GrayGelf: Fully compliant Graylog2/GELF client and server

2013-04-05 Thread Dan Milon
Yes.

I'll try to release it during the weekend if you'd like. 

On 5 Απρ 2013, at 1:03 μ.μ., Alexey Kupershtokh  
wrote:

> Have you made it able to send data to the Graylog2 in your fork?
> 
> пятница, 5 апреля 2013 г., 16:58:19 UTC+7 пользователь Dan Milon написал:
>> 
>> IMO it's too bloated and does way too much. I tried to write a patch once 
>> and it was a mess. Also it's not actively maintained. We're running an 
>> internal fork of Jog (visiomedia/jog) for now. 
>> 
>> On 5 Απρ 2013, at 12:36 μ.μ., Alexey Kupershtokh  
>> wrote:
>> 
>>> Thanks. I'll try it shortly.
>>> BTW, why do you not using winston anymore? Using anything better instead?
>>> 
>>> четверг, 4 апреля 2013 г., 19:31:48 UTC+7 пользователь Dan Milon написал:
>>>> 
>>>> See https://github.com/danmilon/winston-graylogger 
>>>> 
>>>> But I ended up moving away from winston, so I don't use it anymore. 
>>>> Anyway, it's a 50-liner. 
>>>> 
>>>> On 04/04/2013 04:48 πμ, Alexey Kupershtokh wrote: 
>>>> > Hello again Marc :) I'm investigating a possibility to use 
>>>> > https://github.com/flite/winston-graylog2 in my project. And found 
>>>> > that it has become orphan recently 
>>>> > <https://github.com/flite/winston-graylog2/commit/8836d0f80f3d464f8ebe1d46be823c7d543aa138>.
>>>> >  
>>>> > 
>>>> > 
>>>> Along with that, it seems that the project does not use any existing 
>>>> > full-featured gelf/graylog2 lower level transport but has own 
>>>> > incomplete implementation right within higher level functions and 
>>>> > therefore has limitations like this 
>>>> > <https://github.com/flite/winston-graylog2/blob/master/lib/winston-graylog2.js#L75>.
>>>> >  
>>>> > 
>>>> >  I would propose you to adopt the project. And together we could 
>>>> > make it better and more simple by rebasing onto the graygelf. What 
>>>> > do you think? 
>>>> > 
>>>> > воскресенье, 7 октября 2012 г., 6:38:27 UTC+7 пользователь wavded 
>>>> > написал: 
>>>> > 
>>>> > https://github.com/wavded/graygelf 
>>>> > <https://github.com/wavded/graygelf> 
>>>> > 
>>>> > We utilize "GELF" format pretty heavily where I work (it is pretty 
>>>> > nice) and needed a complete implementation so we could write our 
>>>> > own hooks and just do other crazy stuff. 
>>>> > 
>>>> > Includes a client/server, Node core style, streaming, chunking,  
>>>> > proxy server stuff.  Was pretty fun to work on.  Hope it helps 
>>>> > someone else out. 
>>>> > 
>>>> > Marc 
>>>> > 
>>>> > -- -- 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 Google 
>>>> > Groups "nodejs" group. To post to this group, send email to 
>>>> > nod...@googlegroups.com To unsubscribe from this group, send email 
>>>> > to nodejs+un...@googlegroups.com For more options, visit this 
>>>> > group at http://groups.google.com/group/nodejs?hl=en?hl=en 
>>>> > 
>>>> > --- You received this message because you are subscribed to the 
>>>> > Google Groups "nodejs" group. To unsubscribe from this group and 
>>>> > stop receiving emails from it, send an email to 
>>>> > nodejs+un...@googlegroups.com. For more options, visit 
>>>> > https://groups.google.com/groups/opt_out. 
>>>> > 
>>>> >
>>> 
>>> -- 
>>> -- 
>>> 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 Google
>>> Groups "nodejs" group.
>>> To post to this group, send email to nod...@googlegroups.com
>>> To unsubscribe from this group, send email to
>>> nodejs+un...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>>  
>>> --- 
>>> Yo

Re: [nodejs] Re: [ANN] GrayGelf: Fully compliant Graylog2/GELF client and server

2013-04-05 Thread Dan Milon
IMO it's too bloated and does way too much. I tried to write a patch once and 
it was a mess. Also it's not actively maintained. We're running an internal 
fork of Jog (visiomedia/jog) for now. 

On 5 Απρ 2013, at 12:36 μ.μ., Alexey Kupershtokh  
wrote:

> Thanks. I'll try it shortly.
> BTW, why do you not using winston anymore? Using anything better instead?
> 
> четверг, 4 апреля 2013 г., 19:31:48 UTC+7 пользователь Dan Milon написал:
>> 
>> See https://github.com/danmilon/winston-graylogger 
>> 
>> But I ended up moving away from winston, so I don't use it anymore. 
>> Anyway, it's a 50-liner. 
>> 
>> On 04/04/2013 04:48 πμ, Alexey Kupershtokh wrote: 
>> > Hello again Marc :) I'm investigating a possibility to use 
>> > https://github.com/flite/winston-graylog2 in my project. And found 
>> > that it has become orphan recently 
>> > <https://github.com/flite/winston-graylog2/commit/8836d0f80f3d464f8ebe1d46be823c7d543aa138>.
>> >  
>> > 
>> > 
>> Along with that, it seems that the project does not use any existing 
>> > full-featured gelf/graylog2 lower level transport but has own 
>> > incomplete implementation right within higher level functions and 
>> > therefore has limitations like this 
>> > <https://github.com/flite/winston-graylog2/blob/master/lib/winston-graylog2.js#L75>.
>> >  
>> > 
>> >  I would propose you to adopt the project. And together we could 
>> > make it better and more simple by rebasing onto the graygelf. What 
>> > do you think? 
>> > 
>> > воскресенье, 7 октября 2012 г., 6:38:27 UTC+7 пользователь wavded 
>> > написал: 
>> > 
>> > https://github.com/wavded/graygelf 
>> > <https://github.com/wavded/graygelf> 
>> > 
>> > We utilize "GELF" format pretty heavily where I work (it is pretty 
>> > nice) and needed a complete implementation so we could write our 
>> > own hooks and just do other crazy stuff. 
>> > 
>> > Includes a client/server, Node core style, streaming, chunking, 
>> > proxy server stuff.  Was pretty fun to work on.  Hope it helps 
>> > someone else out. 
>> > 
>> > Marc 
>> > 
>> > -- -- 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 Google 
>> > Groups "nodejs" group. To post to this group, send email to 
>> > nod...@googlegroups.com To unsubscribe from this group, send email 
>> > to nodejs+un...@googlegroups.com For more options, visit this 
>> > group at http://groups.google.com/group/nodejs?hl=en?hl=en 
>> > 
>> > --- You received this message because you are subscribed to the 
>> > Google Groups "nodejs" group. To unsubscribe from this group and 
>> > stop receiving emails from it, send an email to 
>> > nodejs+un...@googlegroups.com. For more options, visit 
>> > https://groups.google.com/groups/opt_out. 
>> > 
>> >
> 
> -- 
> -- 
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>  
> --- 
> You received this message because you are subscribed to the Google Groups 
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to nodejs+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] Re: [ANN] GrayGelf: Fully compliant Graylog2/GELF client and server

2013-04-04 Thread Dan Milon
See https://github.com/danmilon/winston-graylogger

But I ended up moving away from winston, so I don't use it anymore.
Anyway, it's a 50-liner.

On 04/04/2013 04:48 πμ, Alexey Kupershtokh wrote:
> Hello again Marc :) I'm investigating a possibility to use
> https://github.com/flite/winston-graylog2 in my project. And found 
> that it has become orphan recently 
> .
>
> 
Along with that, it seems that the project does not use any existing
> full-featured gelf/graylog2 lower level transport but has own
> incomplete implementation right within higher level functions and
> therefore has limitations like this 
> .
>
>  I would propose you to adopt the project. And together we could
> make it better and more simple by rebasing onto the graygelf. What
> do you think?
> 
> воскресенье, 7 октября 2012 г., 6:38:27 UTC+7 пользователь wavded
> написал:
> 
> https://github.com/wavded/graygelf
> 
> 
> We utilize "GELF" format pretty heavily where I work (it is pretty 
> nice) and needed a complete implementation so we could write our
> own hooks and just do other crazy stuff.
> 
> Includes a client/server, Node core style, streaming, chunking, 
> proxy server stuff.  Was pretty fun to work on.  Hope it helps 
> someone else out.
> 
> Marc
> 
> -- -- 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 Google
> Groups "nodejs" group. To post to this group, send email to
> nodejs@googlegroups.com To unsubscribe from this group, send email
> to nodejs+unsubscr...@googlegroups.com For more options, visit this
> group at http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> --- You received this message because you are subscribed to the
> Google Groups "nodejs" group. To unsubscribe from this group and
> stop receiving emails from it, send an email to
> nodejs+unsubscr...@googlegroups.com. For more options, visit
> https://groups.google.com/groups/opt_out.
> 
> 

-- 
-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] Re: New Streams confusion

2013-03-26 Thread Dan Milon
tate different streams are in. You can seek to different
>>> positions in the stream, read just a certain number of bytes,
>>> whatever. It's just super simple and super powerful.
>>> 
>>> -- Michael Jackson @mjackson
>>> 
>>> 
>>> On Mon, Mar 25, 2013 at 2:41 PM, Mikeal Rogers
>>>  wrote:
>>>> 
>>>> This thread is pretty huge.
>>>> 
>>>> At this point, would people say there is more confusion about
>>>> streams2 than old streams? I know that some of this is a
>>>> little hard to get our heads around but i always got the
>>>> feeling that only about 10 people really understood all of
>>>> old streams.
>>>> 
>>>> -Mikeal
>>>> 
>>>> On Mar 25, 2013, at 2:40PM, Marco Rogers
>>>>  wrote:
>>>> 
>>>> I'm more and more convinced that need to go back and read all
>>>> the available info about streams2. Answering these detail
>>>> semantics questions is pretty important.
>>>> 
>>>> :Marco
>>>> 
>>>> On Mon, Mar 25, 2013 at 2:29 PM, Michael Jackson
>>>>  wrote:
>>>>> 
>>>>> If stream.read returns null that could mean one of two
>>>>> things:
>>>>> 
>>>>> 1) the stream doesn't currently have any data, but still
>>>>> might have some in the future 2) the stream is already
>>>>> ended
>>>>> 
>>>>> AFAICT, the only way you can know which state you're in is
>>>>> by checking the stream.readable property which is marked as
>>>>> being a "legacy" property in the code, so it seems like
>>>>> it's not a good idea to rely on that property either.
>>>>> 
>>>>> -- Michael Jackson @mjackson
>>>>> 
>>>>> 
>>>>> On Mon, Mar 25, 2013 at 1:50 PM, Dan Milon
>>>>>  wrote:
>>>>>> 
>>>>>> You're right, my bad.
>>>>>> 
>>>>>> But still, data stay in the buffer until someone tries to
>>>>>> `.read()`. So, if you're being passed a stream that you
>>>>>> dont know whether the first `readable` event has fired,
>>>>>> you can try to actually read from it. If it returns null,
>>>>>> then you wait for `readable`.
>>>>>> 
>>>>>> On 03/25/13 22:42, Michael Jackson wrote:
>>>>>>> readable is emitted after you've actually started
>>>>>>> reading.
>>>>>>> 
>>>>>>> 
>>>>>>> That's not what it says in the docs 
>>>>>>> <http://nodejs.org/api/stream.html#stream_event_readable>.
>>>>>>>
>>>>>>>
>>>>>>> 
### Event: 'readable' When there is data ready to be consumed,
>>>>>>> this event will fire. When this event emits, call the
>>>>>>> read() method to consume the data. ###
>>>>>>> 
>>>>>>> Calling stream.read *before* you get the "readable"
>>>>>>> event is totally counterintuitive.
>>>>>>> 
>>>>>>> -- Michael Jackson @mjackson
>>>>>>> 
>>>>>>> In your example, you dont ever `response.read()`, so no
>>>>>>> readable event is ever emitted.
>>>>>>> 
>>>>>>> As you said, streams start in paused state and ready to
>>>>>>> be read.
>>>>>>> 
>>>>>>> On 03/25/13 22:28, Michael Jackson wrote:
>>>>>>>> Is it correct to assume that a Readable won't emit
>>>>>>>> the "readable"
>>>>>>> event
>>>>>>>> until you're registered for it?
>>>>>>>> 
>>>>>>>> Reading through the streams2 docs, I was under the
>>>>>>>> impression that all streams start out paused and
>>>>>>>> don't start emitting data until you add either a
>>>>>>>> "data" (for old streams) or a "readable" listener.
>>>>>>>> For new streams, this should mean that they don't
>>>>>>>> emit "readable" until at
>>>>>>> leas

Re: [nodejs] Re: New Streams confusion

2013-03-25 Thread Dan Milon
That's not guaranteed to work.

You're assuming that `stream.read()` will return the whole internal
buffer, which is not documented anywhere.

The right approach is to call `.read()` until it returns null.
Something like that:

function collectStream(stream, cb) {
  var bufs = []

  function read() {
var chunk

while ((chunk = stream.read()) != null) {
  bufs.push(chunk)
}
  }

  stream.on('error', cb)

  stream.on('readable', read)

  stream.on('end', function () {
cb(null, Buffer.concat(bufs))
  })

  read()
}

On 03/25/13 23:55, Michael Jackson wrote:
> Ok, that makes sense.
> 
> So the readable event is more of an advisory event. The docs
> should probably say something about how you could possibly miss the
> event entirely if you're doing some other IO before you try and
> read from the stream.
> 
> For posterity's sake, I adjusted my previous example:
> 
> var http = require('http');
> 
> http.get('http://www.google.com', function (response) { 
> console.log('got response with status ' + response.statusCode);
> 
> setTimeout(function () { bufferStream(response, function (err,
> buffer) { console.log(buffer.toString()); }); }, 1000); });
> 
> function bufferStream(stream, callback) { var chunks = [];
> 
> var chunk = stream.read(); if (chunk) { chunks.push(chunk); }
> 
> stream.on('readable', function () { chunks.push(stream.read()); 
> });
> 
> stream.on('error', function (error) { callback(error); });
> 
> stream.on('end', function () { callback(null,
> Buffer.concat(chunks)); }); }
> 
> You can use the bufferStream function to catch all data on the
> stream, no matter how far in the future you are.
> 
> -- Michael Jackson @mjackson
> 
> 
> On Mon, Mar 25, 2013 at 1:49 PM, Dean Landolt
> mailto:d...@deanlandolt.com>> wrote:
> 
> You can always call `stream.read`, at any time. This is how data
> is /pulled/ off the stream (instead of it being pushed to you,
> whether you're ready or not). Because of this you won't lose any
> data. With new streams there's no real notion of a paused state --
> it's always paused. Once you grok that it may not seem so
> counter-intuitive.
> 
> The `readable` event is like a corollary to `drain` -- there to
> tell you that it's worth bothering with a call to read. You don't
> /have/ to listen for it -- a (needlessly inefficient) stream reader
> could just as easily poll stream.read for new data periodically.
> 
> 
> On Mon, Mar 25, 2013 at 4:42 PM, Michael Jackson 
> mailto:mjijack...@gmail.com>> wrote:
> 
> readable is emitted after you've actually started reading.
> 
> 
> That's not what it says in the docs 
> .
> 
> ### Event: 'readable' When there is data ready to be consumed, this
> event will fire. When this event emits, call the read() method to
> consume the data. ###
> 
> Calling stream.read *before* you get the "readable" event is 
> totally counterintuitive.
> 
> -- Michael Jackson @mjackson
> 
> In your example, you dont ever `response.read()`, so no readable
> event is ever emitted.
> 
> As you said, streams start in paused state and ready to be read.
> 
> On 03/25/13 22:28, Michael Jackson wrote:
>> Is it correct to assume that a Readable won't emit the
> "readable" event
>> until you're registered for it?
>> 
>> Reading through the streams2 docs, I was under the
> impression that all
>> streams start out paused and don't start emitting data
> until you add
>> either a "data" (for old streams) or a "readable"
> listener. For new
>> streams, this should mean that they don't emit "readable"
> until at least
>> one listener is registered. Otherwise we still need to do
> some buffering
>> in order to capture all the data.
>> 
>> For example, this code misses the readable event on node 0.10:
>> 
>> var http = require('http');
>> 
>> http.get('http://www.google.com', function (response) { 
>> console.log('got response with status ' +
> response.statusCode);
>> 
>> setTimeout(function () { response.on('readable', function () { 
>> console.log('readable'); });
>> 
>> response.on('end', function () { console.log('end'); }); }, 5); 
>> });
>> 
>> Here's my shell session:
>> 
>> $ node -v v0.10.0 $ node http-test.js got response with status
>> 200 $
>> 
>> Is this the correct behavior?
>> 
>> -- Michael Jackson @mjackson
>> 
>> 
>> On Thu, Mar 21, 2013 at 4:27 PM, Isaac Schlueter  
>> >> wrote:
>> 
>> re old-mode
>> 
>> Yes, that's fine.  If you just want to get all the
> data asap, use
>> on('data', handler).  It'll work great, and it's still
> very fast.
>> pause()/resume(), the whole bit.  (The difference is
> that it won't
>> emit data until you're listening, and pause() will
> *actually* pause.)
>> 
>> 
>> Re read(cb)
>> 
>> It's problematic for reasons that I've discussed all
> of the places
>> where it's been brought up.  That horse is dead, let's
> stop beating
>> it.  (There were a few other proposals as well, btw.
> Reduci

Re: [nodejs] Re: New Streams confusion

2013-03-25 Thread Dan Milon
You're right, my bad.

But still, data stay in the buffer until someone tries to `.read()`.
So, if you're being passed a stream that you dont know whether the
first `readable` event has fired, you can try to actually read from
it. If it returns null, then you wait for `readable`.

On 03/25/13 22:42, Michael Jackson wrote:
> readable is emitted after you've actually started reading.
> 
> 
> That's not what it says in the docs 
> .
> 
> ### Event: 'readable' When there is data ready to be consumed,
> this event will fire. When this event emits, call the read() method
> to consume the data. ###
> 
> Calling stream.read *before* you get the "readable" event is 
> totally counterintuitive.
> 
> -- Michael Jackson @mjackson
> 
> In your example, you dont ever `response.read()`, so no readable 
> event is ever emitted.
> 
> As you said, streams start in paused state and ready to be read.
> 
> On 03/25/13 22:28, Michael Jackson wrote:
>> Is it correct to assume that a Readable won't emit the 
>> "readable"
> event
>> until you're registered for it?
>> 
>> Reading through the streams2 docs, I was under the impression 
>> that all streams start out paused and don't start emitting data 
>> until you add either a "data" (for old streams) or a "readable" 
>> listener. For new streams, this should mean that they don't emit 
>> "readable" until at
> least
>> one listener is registered. Otherwise we still need to do some
> buffering
>> in order to capture all the data.
>> 
>> For example, this code misses the readable event on node 0.10:
>> 
>> var http = require('http');
>> 
>> http.get('http://www.google.com', function (response) { 
>> console.log('got response with status ' + response.statusCode);
>> 
>> setTimeout(function () { response.on('readable', function () { 
>> console.log('readable'); });
>> 
>> response.on('end', function () { console.log('end'); }); }, 5); 
>> });
>> 
>> Here's my shell session:
>> 
>> $ node -v v0.10.0 $ node http-test.js got response with status 
>> 200 $
>> 
>> Is this the correct behavior?
>> 
>> -- Michael Jackson @mjackson
>> 
>> 
>> On Thu, Mar 21, 2013 at 4:27 PM, Isaac Schlueter  
>> >> wrote:
>> 
>> re old-mode
>> 
>> Yes, that's fine.  If you just want to get all the data asap, use
>> on('data', handler).  It'll work great, and it's still very fast.
>> pause()/resume(), the whole bit.  (The difference is that it
>> won't emit data until you're listening, and pause() will 
>> *actually*
> pause.)
>> 
>> 
>> Re read(cb)
>> 
>> It's problematic for reasons that I've discussed all of the 
>> places where it's been brought up.  That horse is dead, let's 
>> stop
> beating
>> it.  (There were a few other proposals as well, btw.
> Reducibles and
>> some other monadic approaches come to mind.)
>> 
>> 
>> Re pipe() vs looping around read() vs custom Writable vs
> on('data')
>> 
>> Whatever works for your case is fine.  It's flexible on
> purpose, and
>> allows more types of consumption than streams1, and creating
> custom
>> writables is easier than it was in streams1.
>> 
>> If you find something that the API can't do for you, or find
> yourself
>> doing a lot of backflips or overriding a lot of methods to get
> your
>> stuff working, then let's chat about it in a github issue.
> You might
>> be missing something, or you might have found a genuine
> shortcoming in
>> the API.
>> 
>> 
>> 
>> On Thu, Mar 21, 2013 at 2:01 PM, Sigurgeir Jonsson 
>>   
>  >>
>> wrote:
>>> Thanks for all the answers. I almost forgot to look back at 
>>> this
>> thread as
>>> the custom writeStreams have exceeded the high expectation I 
>>> had
>> already for
>>> Streams 2. For me, the reference manual was a little
>>> confusing, as
> there are
>> complete
>>> examples on using the read method, no mention of  "reading"
> through a
>>> writeStream endpoint.
>>> 
>>> Marco, I agree that that read has more detailed control of
> minimum
>> incoming
>>> content.  However I wonder if it would be more efficient to
> default
>>> pipe.chunkSize to a "lowWatermark" of the receiver (if 
>>> defined).
>> This
>>> lowWatermark could be adjusted dynamically and the callback
> in the
>> writable
>>> should keep sequence of events under control?
>>> 
>>> Anyway, thanks Node team, I'm very impressed!
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> On Wednesday, March 20, 2013 4:45:32 AM UTC-4, Marco Rogers
> wrote:
 
 @Nathan's response is right. Creating a writable stream is
>> preferable in
 most cases. But I wanted to add a little context to that. If
>> you're dealing
 with a base readable stream, it's just pushing chunks of
> data at
>> you off the
 wire. Your first task is to collect those chunks into
> meaningful
>> data. So
 IMO the reason creating a writable stre

Re: [nodejs] Re: New Streams confusion

2013-03-25 Thread Dan Milon
readable is emitted after you've actually started reading.
In your example, you dont ever `response.read()`, so no readable event
is ever emitted.

As you said, streams start in paused state and ready to be read.

On 03/25/13 22:28, Michael Jackson wrote:
> Is it correct to assume that a Readable won't emit the "readable" event
> until you're registered for it?
> 
> Reading through the streams2 docs, I was under the impression that all
> streams start out paused and don't start emitting data until you add
> either a "data" (for old streams) or a "readable" listener. For new
> streams, this should mean that they don't emit "readable" until at least
> one listener is registered. Otherwise we still need to do some buffering
> in order to capture all the data.
> 
> For example, this code misses the readable event on node 0.10:
> 
> var http = require('http');
> 
> http.get('http://www.google.com', function (response) {
>   console.log('got response with status ' + response.statusCode);
> 
>   setTimeout(function () {
> response.on('readable', function () {
>   console.log('readable');
> });
> 
> response.on('end', function () {
>   console.log('end');
> });
>   }, 5);
> });
> 
> Here's my shell session:
> 
> $ node -v
> v0.10.0
> $ node http-test.js 
> got response with status 200
> $
> 
> Is this the correct behavior?
> 
> --
> Michael Jackson
> @mjackson
> 
> 
> On Thu, Mar 21, 2013 at 4:27 PM, Isaac Schlueter  > wrote:
> 
> re old-mode
> 
> Yes, that's fine.  If you just want to get all the data asap, use
> on('data', handler).  It'll work great, and it's still very fast.
> pause()/resume(), the whole bit.  (The difference is that it won't
> emit data until you're listening, and pause() will *actually* pause.)
> 
> 
> Re read(cb)
> 
> It's problematic for reasons that I've discussed all of the places
> where it's been brought up.  That horse is dead, let's stop beating
> it.  (There were a few other proposals as well, btw.  Reducibles and
> some other monadic approaches come to mind.)
> 
> 
> Re pipe() vs looping around read() vs custom Writable vs on('data')
> 
> Whatever works for your case is fine.  It's flexible on purpose, and
> allows more types of consumption than streams1, and creating custom
> writables is easier than it was in streams1.
> 
> If you find something that the API can't do for you, or find yourself
> doing a lot of backflips or overriding a lot of methods to get your
> stuff working, then let's chat about it in a github issue.  You might
> be missing something, or you might have found a genuine shortcoming in
> the API.
> 
> 
> 
> On Thu, Mar 21, 2013 at 2:01 PM, Sigurgeir Jonsson
> mailto:ziggy.jonsson@gmail.com>>
> wrote:
> > Thanks for all the answers. I almost forgot to look back at this
> thread as
> > the custom writeStreams have exceeded the high expectation I had
> already for
> > Streams 2.
> > For me, the reference manual was a little confusing, as there are
> complete
> > examples on using the read method, no mention of  "reading" through a
> > writeStream endpoint.
> >
> > Marco, I agree that that read has more detailed control of minimum
> incoming
> > content.  However I wonder if it would be more efficient to default
> > pipe.chunkSize to a "lowWatermark" of the receiver (if defined).  
> This
> > lowWatermark could be adjusted dynamically and the callback in the
> writable
> > should keep sequence of events under control?
> >
> > Anyway, thanks Node team, I'm very impressed!
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Wednesday, March 20, 2013 4:45:32 AM UTC-4, Marco Rogers wrote:
> >>
> >> @Nathan's response is right. Creating a writable stream is
> preferable in
> >> most cases. But I wanted to add a little context to that. If
> you're dealing
> >> with a base readable stream, it's just pushing chunks of data at
> you off the
> >> wire. Your first task is to collect those chunks into meaningful
> data. So
> >> IMO the reason creating a writable stream is preferable is because it
> >> prompts you not just read off the stream, but to create semantics
> around
> >> what the new stream is supposed to be. The api reflects this
> opinion and
> >> that's why creating writable streams feels like the more natural
> way, and
> >> the ugliness of dealing with read() is wrapped up in the pipe()
> method. It
> >> was kind of designed that way.
> >>
> >> But the read() api was also designed for a use case. It's meant
> to handle
> >> low/high water marks effectively, as well as enable more
> optimized special
> >> parsing by reading off specific lengths of chunks. These 

Re: [nodejs] Missing execSync in NodeJS

2013-03-14 Thread Dan Milon
On 03/14/2013 11:02 PM, Mikeal Rogers wrote:
> That's a great "oppertunity?" but it's not in line with the
> structure and goals of node.js.
>
> Node has synchronous file operations. The reason it has sync file 
> operations is that there are many cases where you actually **want**
> to stop the entire server until you get back data from the
> filesystem because you can't server **any** requests until it's
> come back. In this case, not only is a sync file operation
> required, it's actually more efficient than using an async
> operation (at least in node.js).

Is there really such a real-world use case? Example? Even with
configs, you just pull up the server after you've read the files.

> Sockets and sub processes are only non-blocking in node. That is
> by design and that design decision was a choice. Doing it another
> way based on an opinion about what you want something to *look
> like* is not recommended and will eventually cause you a lot of
> pain. If you want things to look like that it would be best not do
> use node.js, because core and the entire ecosystem are built on
> doing things the others way.
> 
> -Mikeal
> 
> On Mar 14, 2013, at 1:53PM, Sebi  > wrote:
> 
>> Okay, but I think there should be an "execSync" like they do it
>> in almost every other module. My oppertunity is, that every
>> developer should have the ability to choose if he goes the async
>> or syncronously way.
>> 
>> Regards, Seb
>> 
>> Am Donnerstag, 14. März 2013 21:40:08 UTC+1 schrieb Scott
>> González:
>> 
>> There are tons of modules to help with asynchronous code.
>> https://npmjs.org/package/async 
>> is pretty popular. If you end up in callback hell, you're
>> probably not designing your code properly. Take some time to look
>> at various modules and find one with a style that you like.
>> 
>> 
>> On Thu, Mar 14, 2013 at 4:32 PM, Sebi
>> > wrote:
>> 
>> Many functions in NodeJS have a Sync pendant to the non-blocking
>> functions. Why is there no blocking pendant in the child_process
>> module?
>> 
>> I've giving up as I tried to iterate over a directory and call 
>> for every file child.exec
>> 
>> how should my app now, that every process completed his task? I'm
>> going to run in trouble, because to use a timer to check that
>> seems to be not a powerful resolution.
>> 
>> Think there should be a sync pendant in the core child
>> module
>> 
>> Sometimes you're going to the "callback" hell...
>> 
>> -- -- 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
>> Google Groups "nodejs" group. To post to this group, send email
>> to nod...@googlegroups.com  To unsubscribe from this
>> group, send email to nodejs+un...@googlegroups.com  
>> For more options, visit this group at 
>> http://groups.google.com/group/nodejs?hl=en?hl=en 
>> 
>> 
>> --- You received this message because you are subscribed to the 
>> Google Groups "nodejs" group. To unsubscribe from this group and
>> stop receiving emails from it, send an email to
>> nodejs+un...@googlegroups.com . For more options,
>> visit https://groups.google.com/groups/opt_out 
>> .
>> 
>> 
>> 
>> 
>> 
>> -- -- 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 Google
>> Groups "nodejs" group. To post to this group, send email to
>> nodejs@googlegroups.com  To
>> unsubscribe from this group, send email to 
>> nodejs+unsubscr...@googlegroups.com 
>>  For more options,
>> visit this group at 
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>> 
>> --- You received this message because you are subscribed to the
>> Google Groups "nodejs" group. To unsubscribe from this group and
>> stop receiving emails from it, send an email to
>> nodejs+unsubscr...@googlegroups.com 
>> . For more options,
>> visit https://groups.google.com/groups/opt_out.
>> 
>> 
> 
> -- -- 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 Google
> Groups "nodejs" group. To post to this group, send email to
> nodejs@googlegroups.com To unsubscribe from this group, send email
> to nodejs+unsubscr...@googlegroups.com For more options, visit this
> group at http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> --- You received this message because you are subscribed to the
> Google Groups "nodejs" group. To unsubscribe from this

Re: [nodejs] Re: Re - Reusing the schema validation both on client side and server side

2013-03-01 Thread Dan Milon
See assurance [1]. We're using it both on the server and client.

Actually we've created a shared repo exposing a function for each entity
that needs to be validated, and a make target to fetch it from the repos
that need it.

[1] https://github.com/danmilon/assurance



On 03/01/2013 02:28 PM, Sri Vidhya wrote:
> thanks for the reply. I will find the validator which has to run
> both on client and server side.
> 
> On Fri, Mar 1, 2013 at 4:38 PM, Geerten van Meel
> mailto:klova...@gmail.com>> wrote:
> 
> Since you did not get any answers so far, let me drop a few
> thoughts:
> 
> First off, while it is possible to re-use code between client and 
> server, it is not a design goal of node to make this especially
> easy or encourage this in a special way. It is possible because
> it's both JavaScript, yes, but not necessarily a good thing to do.
> 
> To achieve what you are looking for, search for any json schema 
> validator that runs both on node and can be included on the client 
> side. With a few lines of code (thus checking for the existance of 
> "module" and "module.exports", google it) you can usually wrap any 
> client side library into a node module for use on the server and 
> then use almost the exact same api to fullfill your task.
> 
> However, you would still have to somehow get the logic / schema
> into both your clients form handling and your server logic. Given
> that this would require extra http requests or file lookups on one
> end or the other, or copy&pasting the schema, you should ask
> whether there is a real benefit of doing that. In my personal
> opinion, the required extra "juice" to make that work does not
> stand against the small benefit of being able to share the same
> code base.
> 
> So long story short, find a npm module that does schema validation 
> both on the server and has a script to include on the client. Or 
> don't. (I don't like schema validation.)
> 
> 
> On Wednesday, February 27, 2013 12:59:13 PM UTC+1, Srividhya
> wrote:
> 
> Hi All, How can i use the same validation code on both client and 
> server side (for reusability of code). Am using the jsonschema.js
> validator file on client side. When i submiting the data  to the
> server i want to revalidate the data by using the same schema. If
> anyone knows means let me know.
> 
> 
> Thanks, sri
> 
> -- -- 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 Google
> Groups "nodejs" group. To post to this group, send email to
> nodejs@googlegroups.com  To
> unsubscribe from this group, send email to 
> nodejs+unsubscr...@googlegroups.com 
>  For more options,
> visit this group at 
> http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> --- You received this message because you are subscribed to the
> Google Groups "nodejs" group. To unsubscribe from this group and
> stop receiving emails from it, send an email to
> nodejs+unsubscr...@googlegroups.com 
> . For more options,
> visit https://groups.google.com/groups/opt_out.
> 
> 
> 
> 
> 
> 
> -- Thanks, N. Srividhya.
> 
> -- -- 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 Google
> Groups "nodejs" group. To post to this group, send email to
> nodejs@googlegroups.com To unsubscribe from this group, send email
> to nodejs+unsubscr...@googlegroups.com For more options, visit this
> group at http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> --- You received this message because you are subscribed to the
> Google Groups "nodejs" group. To unsubscribe from this group and
> stop receiving emails from it, send an email to
> nodejs+unsubscr...@googlegroups.com. For more options, visit
> https://groups.google.com/groups/opt_out.
> 
> 

-- 
-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] MongoDB / Mongoose - prevent field update

2013-02-22 Thread Dan Milon
It's up to you to filter and validate the input. (ok, mongoose has
some basic validation but that won't help you here).

here's what I do. Hope that helps:

```javascript
// User.UPDATE_ATTRS is an array of the permitted attributes
// for updating.
//
// filter returns an object with only those keys
var attrs = filter(req.body, User.UPDATE_ATTRS)

// the second parameter is an array of the keys I want
// to validate for. (its not User.UPDATE_ATTRS because
// I want to validate only what's present in this request)
var err = validators.user(attrs, Object.keys(attrs))
if (err) {
  return next(err)
}

User.update({ _id: ... }, attrs, ...)
```

On 02/22/2013 08:01 AM, smak wrote:
> Note:  I am new to the Node stack and am still in the learning
> stages.
> 
> Setup:  Node / Express / Mongoose / MongoDB for a web application.
> 
> 
> Issue:  How does one prevent the updating of a field in a
> document. i.e. createdAt or userName.  In theory, some values
> should be created and then be read only [under most circumstances].
> As best I can tell if a value is passed back from the UI it gets
> mapped to the schema and updated in the database.
> 
> It looks like there are some options in the schema to prevent
> values being passed back on the query side but nothing to block on
> the update side.
> 
> Can anyone point to an example or documentation that would help
> solve the issue.
> 
> Thanks,
> 
> smak
> 
> -- -- 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 Google
> Groups "nodejs" group. To post to this group, send email to
> nodejs@googlegroups.com To unsubscribe from this group, send email
> to nodejs+unsubscr...@googlegroups.com For more options, visit this
> group at http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> --- You received this message because you are subscribed to the
> Google Groups "nodejs" group. To unsubscribe from this group and
> stop receiving emails from it, send an email to
> nodejs+unsubscr...@googlegroups.com. For more options, visit
> https://groups.google.com/groups/opt_out.
> 
> 

-- 
-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] 0.9x: writeable stream: objectMode

2013-02-15 Thread Dan Milon
Judging from the code Aaron linked, neither does v0.8 know how to
convert the object into a buffer. It relies on #toString().


On 02/16/2013 12:45 AM, Nathan Rajlich wrote:
> Aaron, I'm a little confused at exactly what you're trying to do,
> but if you have a Readable stream outputting "objects" of some kind
> (since it's in objectMode), and you pipe() to a writable stream
> that is *not* in objectMode (i.e. it's expecting strings and/or
> buffers), then what would you expect the Writable stream to do? How
> would it know how to convert your Object from the readable stream
> into a Buffer?
> 
> On Fri, Feb 15, 2013 at 12:14 PM, Aaron Heckmann 
> mailto:aaron.heckm...@gmail.com>>
> wrote:
> 
> In node < 0.9, WriteStreams converted non-Buffers to Buffers 
> transparently.
> 
> https://github.com/joyent/node/blob/v0.8.20-release/lib/fs.js#L1557-L1561
>
>  In 0.9, this is not the case, which leaves me a bit confused with 
> the ReadableStreams objectMode option. I'd like to pipe a 
> ReadableStream in objectMode to a writable stream and rely on 
> conversion to Buffers without needing to create a transform
> stream, the way I could in 0.8x. Is this by design?
> 
> http://nodejs.org/docs/v0.9.8/api/stream.html#stream_new_stream_readable_options
>
> 
> 
> 
> -- Aaron @aaronheckmann 
> 
> 
> -- -- 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 Google
> Groups "nodejs" group. To post to this group, send email to
> nodejs@googlegroups.com  To
> unsubscribe from this group, send email to 
> nodejs+unsubscr...@googlegroups.com 
>  For more options,
> visit this group at 
> http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> --- You received this message because you are subscribed to the
> Google Groups "nodejs" group. To unsubscribe from this group and
> stop receiving emails from it, send an email to
> nodejs+unsubscr...@googlegroups.com 
> . For more options,
> visit https://groups.google.com/groups/opt_out.
> 
> 
> 
> 
> -- -- 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 Google
> Groups "nodejs" group. To post to this group, send email to
> nodejs@googlegroups.com To unsubscribe from this group, send email
> to nodejs+unsubscr...@googlegroups.com For more options, visit this
> group at http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> --- You received this message because you are subscribed to the
> Google Groups "nodejs" group. To unsubscribe from this group and
> stop receiving emails from it, send an email to
> nodejs+unsubscr...@googlegroups.com. For more options, visit
> https://groups.google.com/groups/opt_out.
> 
> 

-- 
-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] Re: nodeconf videos?

2013-02-08 Thread Dan Milon

Well, almost.

I can go to the doctor for free, but I've paid taxes in order to do so.
I get 1000 free minutes from my carrier, but I'm paying for a
subscription.

etc.

My point is, many times what we get for free now, is the result of us
paying in the past.

This has nothing to do with nodeconf, just wanted to say this because
I feel sad when people don't demand high quality for stuff they've
paid for (even implicitly) without realizing it.

danmilon.


On 02/08/2013 11:08 PM, Sara Chipps wrote:
> Love when people get mad about the quality and availability of
> free things.  I can't handle this mailing list ever.
> 
> Sara J Chipps 862.201.3065
> 
> CTO http://levoleague.com #levolove
> 
> Other projects: http://SaraJChipps.com  
> http://GirlDevelopIt.com  
> http://ElizabethandClarke.com 
> 
> --- No trees were
> killed in sending this message but a large number of electrons were
> terribly inconvenienced.
> 
> 
> On Fri, Feb 8, 2013 at 3:44 PM, Jorge Chamorro
> mailto:jo...@jorgechamorro.com>> wrote:
> 
> On 08/02/2013, at 17:41, Mikeal Rogers wrote:
> 
>> (...) NodeConf was higher than almost anything we'd seen. (...)
> NodeConf isn't like other conferences (...)
> 
> O rly? like, super-mega-high?
> 
>> You can view the videos we have done here: 
>> http://2012.nodeconf.com/theatre/rick_waldron.html 
>> http://2012.nodeconf.com/theatre/ryan_dahl.html 
>> http://2012.nodeconf.com/theatre/elijah_insua.html
> 
> Can't play in FireFox: "No video with supported format and MIME
> type found".
> 
>> It may seem strange for us to record all the talks but not
>> release
> them (...)
> 
> @ JSConf they record and release all the talks: 
> 
> 
> Cheers, -- Jorge.
> 
> -- -- 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 Google
> Groups "nodejs" group. To post to this group, send email to
> nodejs@googlegroups.com  To
> unsubscribe from this group, send email to 
> nodejs+unsubscr...@googlegroups.com 
>  For more options,
> visit this group at 
> http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> --- You received this message because you are subscribed to the
> Google Groups "nodejs" group. To unsubscribe from this group and
> stop receiving emails from it, send an email to
> nodejs+unsubscr...@googlegroups.com 
> . For more options,
> visit https://groups.google.com/groups/opt_out.
> 
> 
> 
> -- -- 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 Google
> Groups "nodejs" group. To post to this group, send email to
> nodejs@googlegroups.com To unsubscribe from this group, send email
> to nodejs+unsubscr...@googlegroups.com For more options, visit this
> group at http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> --- You received this message because you are subscribed to the
> Google Groups "nodejs" group. To unsubscribe from this group and
> stop receiving emails from it, send an email to
> nodejs+unsubscr...@googlegroups.com. For more options, visit
> https://groups.google.com/groups/opt_out.
> 
> 

-- 
-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] Process mongodb records

2013-02-08 Thread Dan Milon
In case you're using just mongodb-native:

http://mongodb.github.com/node-mongodb-native/api-generated/cursorstream.html

On 02/08/2013 05:47 AM, Benjamin Clos wrote:
> Mongoose.js allows for streaming of records as it finds them and is
> useful for iterating over large populations.
> 

-- 
-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] Re: abuse notification due to "make test"

2013-02-07 Thread Dan Milon
Verify the hash of whatever you downloaded.

http://nodejs.org/dist/v0.8.19/SHASUMS.txt

On 02/07/2013 06:30 PM, Sven Knuth wrote:
> another try before giving up:
> 
> I started the nodes.js self test with "make test". ( I think it is
> an self test, because I didn't found a description of the test)
> 
> And what happens then? It is testing and everything is fine. At
> one point, the python script *tools/test.py* (the script started by
> "make test") is sending request on port 1 (TCPMUX) to more than 500
> different IPs in less than 3 seconds. That were IPs of the DOD, a
> japanese bank, IBM, universities, ...
> 
> I am still not able to find out why this happens. I tested it more
> than 5 times with the code found here
> https://github.com/joyent/node.git
> 
> I think it is a strange behaviour and I can't imagine that this is
> wanted.
> 
> Maybe someone else like to test, what I done, and sniff the
> network traffic with wireshark:
> 
> ### git clone https://github.com/joyent/node.git cd node 
> ./configure --openssl-libpath=/usr/lib/ssl make make test 
> 
> 
> Testing just needs a few minutes and maybe I did just a big mistake
> :/
> 
> 
> Greetings Sven
> 
> 
> Am Montag, 4. Februar 2013 16:14:12 UTC+1 schrieb Sven Knuth:
> 
> hi,
> 
> yeasterday I got an abuse notification for making a lot of
> netscans. I was really surprised and checked, what happened.
> 
> This is what I did:
> 
> I cloned the last node.js code from github. Started the configure 
> script, typed make and then, when it finished, I started "make
> test" And node.js was tested ... but something else happend. My
> absolut clean virtual debian started to scan a lot ip adresses,
> more precisely, he was knocking on port 1. And this happend to my
> server and was the reason for the abuse notification.
> 
> I made a capture with wireshark (to find as an attachment)
> 
> Is there somebody else who like to check this? I was able to 
> reproduce this 4 times with my virtual machine. Maybe I did just a
> big mistake :/
> 
> greetings
> 
> Sven
> 
> -- -- 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 Google
> Groups "nodejs" group. To post to this group, send email to
> nodejs@googlegroups.com To unsubscribe from this group, send email
> to nodejs+unsubscr...@googlegroups.com For more options, visit this
> group at http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> --- You received this message because you are subscribed to the
> Google Groups "nodejs" group. To unsubscribe from this group and
> stop receiving emails from it, send an email to
> nodejs+unsubscr...@googlegroups.com. For more options, visit
> https://groups.google.com/groups/opt_out.
> 
> 

-- 
-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] Re: What happens to hook.io?

2013-02-06 Thread Dan Milon
«No. Even if I did, you wouldn't understand.»

Obviously the guy is not in a mood for explanations. Let's all move on.

On 02/06/2013 07:40 PM, Mark Hahn wrote:
> I can't tell from the docs what this is used for.  Can you
> explain?
> 
> 
> On Wed, Feb 6, 2013 at 2:07 AM, Marak Squires
> mailto:marak.squi...@gmail.com>> wrote:
> 
> Featuring the all new resource engine!
> 
> https://github.com/bigcompany/resource
> 
> And no one is allowed to use it, especially Stan and Kyle.
> 
> On Wed, Feb 6, 2013 at 7:58 AM, Eric Muyser  > wrote:
> 
> Reverse psychology
> 
> 
> On Tue, Feb 5, 2013 at 9:29 PM, Harald Hanche-Olsen 
> mailto:han...@math.ntnu.no>> wrote:
> 
> [Angel Java Lopez  > (2013-02-05 11:31:00 UTC)]
> 
>> Ummm... Marak, can you elaborate?
> 
> It's becoming quite clear that he won't. So let's stop badgering
> him about it and move on.
> 
> - Harald
> 
> -- -- 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
> Google Groups "nodejs" group. To post to this group, send email to
> nodejs@googlegroups.com  To
> unsubscribe from this group, send email to 
> nodejs+unsubscr...@googlegroups.com 
>  For more options,
> visit this group at 
> http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> --- You received this message because you are subscribed to the 
> Google Groups "nodejs" group. To unsubscribe from this group and
> stop receiving emails from it, send an email to 
> nodejs+unsubscr...@googlegroups.com 
> . For more options,
> visit https://groups.google.com/groups/opt_out.
> 
> 
> 
> -- -- 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 Google
> Groups "nodejs" group. To post to this group, send email to
> nodejs@googlegroups.com  To
> unsubscribe from this group, send email to 
> nodejs+unsubscr...@googlegroups.com 
>  For more options,
> visit this group at 
> http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> --- You received this message because you are subscribed to the 
> Google Groups "nodejs" group. To unsubscribe from this group and
> stop receiving emails from it, send an email to
> nodejs+unsubscr...@googlegroups.com 
> . For more options,
> visit https://groups.google.com/groups/opt_out.
> 
> 
> 
> 
> -- -- 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 Google
> Groups "nodejs" group. To post to this group, send email to
> nodejs@googlegroups.com  To
> unsubscribe from this group, send email to 
> nodejs+unsubscr...@googlegroups.com 
>  For more options,
> visit this group at 
> http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> --- You received this message because you are subscribed to the
> Google Groups "nodejs" group. To unsubscribe from this group and
> stop receiving emails from it, send an email to
> nodejs+unsubscr...@googlegroups.com 
> . For more options,
> visit https://groups.google.com/groups/opt_out.
> 
> 
> 
> 
> -- -- 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 Google
> Groups "nodejs" group. To post to this group, send email to
> nodejs@googlegroups.com To unsubscribe from this group, send email
> to nodejs+unsubscr...@googlegroups.com For more options, visit this
> group at http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> --- You received this message because you are subscribed to the
> Google Groups "nodejs" group. To unsubscribe from this group and
> stop receiving emails from it, send an email to
> nodejs+unsubscr...@googlegroups.com. For more options, visit
> https://groups.google.com/groups/opt_out.
> 
> 

-- 
-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe

Re: [nodejs] Node.js webserver hangs

2013-02-05 Thread Dan Milon
Many.

Take a look at https://github.com/lloyd/node-toobusy

danmilon.

On 02/05/2013 06:53 PM, Gustavo Machado wrote:
> Hello, a rather theoretical question.
> 
> What are the possible causes for a server to stop responding to the
> most simple requests? How can one troubleshoot this kind of problem
> if it's not trivial to reproduce?
> 
> Thanks, Gustavo Machado
> 
> -- -- 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 Google
> Groups "nodejs" group. To post to this group, send email to
> nodejs@googlegroups.com To unsubscribe from this group, send email
> to nodejs+unsubscr...@googlegroups.com For more options, visit this
> group at http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> --- You received this message because you are subscribed to the
> Google Groups "nodejs" group. To unsubscribe from this group and
> stop receiving emails from it, send an email to
> nodejs+unsubscr...@googlegroups.com. For more options, visit
> https://groups.google.com/groups/opt_out.
> 
> 

-- 
-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] Valid character encodings for source code

2013-02-04 Thread Dan Milon
The OP meant the actual file encoding.

eg, if you have a source file containing Greek characters and save it
in iso-8859-7 format (which should display just right if read with the
same encoding), node will try to read it in utf and fail. (ie "�"
characters in strings, etc)

danmilon.

On 02/04/2013 11:13 PM, Harald Hanche-Olsen wrote:
> [Andrew Bradley  (2013-02-04 20:42:24 UTC)]
> 
>> On Monday, February 4, 2013 3:01:22 PM UTC-5, Ben Noordhuis
>> wrote:
>> 
>>> They're ASCII and UTF-8.
>>> 
>> 
>> Thanks for the quick reply.  Do you know this from experience, or
>> did I miss where it's documented?
> 
> I'm pretty sure it's part of the javascript language definition.
> 
> In fact, you can use any unicode letter, such as Ω, as part of a 
> variable name.
> 
> - Harald
> 

-- 
-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] core dump analysis & debugging

2013-02-01 Thread Dan Milon
Indeed, systemd does some sneaky tricks.

$ sysctl kernel.core_pattern

kernel.core_pattern = |/usr/lib/systemd/systemd-coredump %p %u %g %s %t %e

$ sudo sysctl kernel.core_pattern='core'

$ node -e 'process.abort()'
Aborted

$ ls -a
./  ../  core


Thanks!


On 02/01/2013 07:08 PM, Ben Noordhuis wrote:
> On Fri, Feb 1, 2013 at 5:27 PM, Dan Milon 
> wrote:
>> $ ulimit -c unlimited
>> 
>> $ node -e 'process.abort()' Aborted (core dumped)
>> 
>> $ ls -a ./  ../
>> 
>> Any idea?
>> 
>> BTW, could you point me to the actual code of process.abort in
>> the source?
>> 
>> danmilon.
> 
> Check what the kernel.core_pattern sysctl is set to.  Some
> security frameworks change it so core dumps get stored elsewhere.
> 
> Also, don't run as root.  Some of the aforementioned frameworks
> block root core dumps as a security precaution (think symlink
> attacks.)
> 
> process.abort() is implemented in src/node.cc (grep for 'Abort').
> It doesn't do anything special: it just calls abort() which in turn
> sends a SIGABRT to the process.
> 

-- 
-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] core dump analysis & debugging

2013-02-01 Thread Dan Milon
$ ulimit -c unlimited

$ node -e 'process.abort()'
Aborted (core dumped)

$ ls -a
./  ../

Any idea?

BTW, could you point me to the actual code of process.abort in the source?

danmilon.


On 02/01/2013 05:52 PM, Ben Noordhuis wrote:
> On Fri, Feb 1, 2013 at 4:38 PM, Dan Milon 
> wrote:
>> Thanks, I'll give it a try.
>> 
>> Now, about getting an actual core dump, docs [1] say
>> process.abort will generate one.
>> 
>> $ node -e 'process.abort()' Aborted (core dumped)
>> 
>> $ ls -a ./  ../
>> 
>> Should I file this as a bug?
>> 
>> [1] http://nodejs.org/api/process.html#process_process_abort
>> 
>> danmilon.
> 
> You have to set `ulimit -c unlimited` first.
> 

-- 
-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] core dump analysis & debugging

2013-02-01 Thread Dan Milon
Thanks, I'll give it a try.

Now, about getting an actual core dump, docs [1] say process.abort
will generate one.

$ node -e 'process.abort()'
Aborted (core dumped)

$ ls -a
./  ../

Should I file this as a bug?

[1] http://nodejs.org/api/process.html#process_process_abort

danmilon.

On 02/01/2013 01:21 PM, Ben Noordhuis wrote:
> On Fri, Feb 1, 2013 at 12:39 AM, Dan Milon 
> wrote:
>> 
>> I was wondering if it is possible to use a core dump from a node 
>> process running on linux as a post mortem debugging mechanism.
>> 
>> Would smartos' MDB understand a core dump coming from a linux
>> machine?
>> 
>> Thanks, danmilon.
> 
> The people at Joyent added V8 smarts to mdb as a plugin but I
> don't know if it still works.
> 
> It's possible that mdb understands Linux core dumps but I expect
> it doesn't.  A core dump is an ELF file in disguise and about as 
> portable.
> 
> On a tangential note, there's built-in gdbjit support.  It's not 
> perfect but it's functional enough to print JS function names in
> stack traces.
> 
> $ ./configure --debug --gdb $ make  $ gdb --args
> out/Debug/node --gdbjit tmp/net-connect.js (gdb) break
> uv_tcp_connect Breakpoint 1 at 0xb92ca0: file
> ../../deps/uv/src/uv-common.c, line 245. (gdb) run Starting
> program: /home/bnoordhuis/src/nodejs/master/out/Debug/node --gdbjit
> tmp/net-connect.js Breakpoint 1, uv_tcp_connect (req=0x13870c0,
> handle=0x137a690, address=..., cb=0x72efa6
> ) at
> ../../deps/uv/src/uv-common.c:245 245   if (handle->type !=
> UV_TCP || address.sin_family != AF_INET) { (gdb) bt #0
> uv_tcp_connect (req=0x13870c0, handle=0x137a690, address=..., 
> cb=0x72efa6 ) at 
> ../../deps/uv/src/uv-common.c:245 #1  0x0072f3d4 in
> node::TCPWrap::Connect (args=...) at ../../src/tcp_wrap.cc:379 #2
> 0x007c1cea in v8::internal::HandleApiCallHelper 
> (args=..., isolate=0x1300070) at
> ../../deps/v8/src/builtins.cc:1372 #3  0x007bc634 in
> v8::internal::Builtin_Impl_HandleApiCall (args=...,
> isolate=0x1300070) at ../../deps/v8/src/builtins.cc:1390 #4
> 0x007bc605 in v8::internal::Builtin_HandleApiCall 
> (args=..., isolate=0x1300070) at
> ../../deps/v8/src/builtins.cc:1389 #5  0x02a75ec0654e in ?? () 
> #6  0x02a75ec150b8 in ?? () #7  0x02a75ec064a1 in ?? () #8
> 0x7fffd3d0 in ?? () #9  0x7fffd438 in ?? () #10
> 0x02a75ec6f9b8 in connect (self=..., address=..., port=..., 
> addressType=..., localAddress=...) at net.js:703 Backtrace stopped:
> previous frame inner to this frame (corrupt stack?)
> 

-- 
-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[nodejs] core dump analysis & debugging

2013-01-31 Thread Dan Milon

I was wondering if it is possible to use a core dump from a node
process running on linux as a post mortem debugging mechanism.

Would smartos' MDB understand a core dump coming from a linux machine?

Thanks,
danmilon.

-- 
-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] How to future proof password hashes?

2013-01-31 Thread Dan Milon
Yes, the buffers will be identical.

danmilon.

On 02/01/2013 12:41 AM, Harald Hanche-Olsen wrote:
> I'd like to store user password hashes in a database.
> 
> When a new password is created, I get some bytes from
> crypto.randombytes to use as salt, then feed the salt and password to
> crypto.pbkdf2 (along with an iteration count and size).
> 
> I convert the salt with salt.toString('base64') in order to save it in
> the password database.
> 
> I have noticed that the resulting key from pbkdf2 is essentially a
> binary coded string; so convert it using
> new Buffer(derivedKey,'binary').toString('base64')
> before saving it to the database.
> 
> However, I see that the crypto API is going to change to using buffers
> rather than binary encoded strings. Also, the 'binary' encoding is
> going away.
> 
> That is fine and well, but what do I need to do to ensure that the
> password hashes will be the same after the crypto API changes?
> 
> I understand I will have to rewrite the code, of course, but I want to
> be able to use the same old hashes so that the password database can
> still be used.
> 
> Can I expect the future crypto.pbkdf2 to produce a buffer identical to
> today's new Buffer(derivedKey,'binary')?
> 
> Also, what is most future proof – to feed the binary salt as a buffer
> to pbkdf2, or the stringified version thereof?
> 
> - Harald
> 

-- 
-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] Re: Javascript Class Specification for the next generation of JS class system, hope to discuss with you.

2013-01-31 Thread Dan Milon
Kinda offtopic:

I see a lot of people here mention OOP and classes are flawed.
Does anyone have some reading to suggest about OOP and its issues? Maybe
some comparison with functional programming.

danmilon.

On 01/31/2013 10:10 PM, Diogo Resende wrote:
> +1. Java people should really read and learn about OOP before
> associating it to just classes..
> 
> -- 
> Diogo Resende
> 
> On Thursday, January 31, 2013 at 19:48 , Geerten van Meel wrote:
> 
>> In case you are wondering why you don't recieve a lot of love in this
>> topic, let me elaborate: You are trying to fix something which is not
>> broken, at least in the eyes of many that are reading this. You are
>> trying to make JavaScript more like Java by turning everything into
>> classes.  
>>
>> Things are not broken though. The CommonJS (~npm) and AMD (browser)
>> approaches are actually quite elegant in their respective environments
>> and allow to encapsule simple functionality into a module without
>> considerable overhead. While it is good that you gave something like
>> this a decent amount of thought, you may be barking up the wrong tree
>> here by turning JavaScript into Java.
>>
>> On Wednesday, January 30, 2013 12:15:20 PM UTC+1, fengchu...@gmail.com
>>  wrote:
>>> Hi, Senior JS fans
>>>
>>> I am a senior Java/JS developer about 12 year+. I recently wrote a
>>> specification named JCS. The goal of this specification is replace
>>> the currently popular of CommonJS or RequireJS for building the next
>>> generation of full object-oriented class system. The first
>>> implementation of the specification is JSDK1.0:
>>> https://github.com/fch415/jtdk
>>>
>>>
>>> The specification is still evolving, welcome yousuggest improvements!
>>>
>>> JCS 1.0 document:
>>> https://github.com/fch415/jss/blob/master/%231/jss%231_jcs_en.md
>>> 
>>>
>>> Sincerely,
>>> FengChun
>>
>> -- 
>> -- 
>> 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 Google
>> Groups "nodejs" group.
>> To post to this group, send email to nodejs@googlegroups.com
>> 
>> To unsubscribe from this group, send email to
>> nodejs+unsubscr...@googlegroups.com
>> 
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>  
>> ---
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To unsubscribe from this group and stop receiving emails from it, send
>> an email to nodejs+unsubscr...@googlegroups.com
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
> 
> -- 
> -- 
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>  
> ---
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to nodejs+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] Graceful exit on SIGINT/SIGTERM

2013-01-30 Thread Dan Milon
You can easily override the default signal handlers.
See http://nodejs.org/docs/latest/api/process.html#process_signal_events

you could do:

```
function gracefulExit() {
  db.close(process.exit)
}

process.on('SIGINT' gracefulExit).on('SIGTERM', gracefulExit)
```

Obviously it can be more sophisticated, with timeouts, etc.

danmilon.

On 01/31/2013 02:59 AM, Michael Jackson wrote:
> It would be really nice to be able to exit a process gracefully on 
> SIGINT/SIGTERM. Right now both signals are hardwired to exit with
> a status of 1 (see the SignalExit function in node.cc) without
> emitting the "exit" event on the process object, but I don't see
> why that needs to be the case.
> 
> Ideally these signals would be handled just like any other signal.
> The default may be to exit with a 1 status, but it would be nice to
> be able to override this in userland.
> 
> A couple of real world use cases:
> 
> - Using Ctrl+C in a terminal that is attached to a running process 
> - Heroku's dyno manifold issues SIGTERM to processes to let them
> know they are going to be restarted (see
> https://devcenter.heroku.com/articles/ps#graceful-shutdown-with-sigterm).
>
> 
As it stands now there is no way to ensure that a running server doesn't
> drop open connections during a deploy on Heroku.
> 
> What is the reason for the current behavior? Is there any way
> around it for the use cases I've described?
> 
> Thanks in advance.
> 
> -- Michael Jackson @mjackson
> 
> -- -- 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 Google
> Groups "nodejs" group. To post to this group, send email to
> nodejs@googlegroups.com To unsubscribe from this group, send email
> to nodejs+unsubscr...@googlegroups.com For more options, visit this
> group at http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> --- You received this message because you are subscribed to the
> Google Groups "nodejs" group. To unsubscribe from this group and
> stop receiving emails from it, send an email to
> nodejs+unsubscr...@googlegroups.com. For more options, visit
> https://groups.google.com/groups/opt_out.
> 
> 

-- 
-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[nodejs] [ANN] assurance - validation & sanitization library

2013-01-28 Thread Dan Milon
I'd like to announce _assurance_, a library for input validation &
sanitization. It's been built with network APIs in mind, but it can be
used for CLI programs too.

## Features

  * Provides a **clean** & **pretty** API
  * Returns meaningful error **objects**, not error messages
  * **Accumulates** errors, doesn't bail straight away
  * Loves nested objects
  * Is general purpose - ish
  * Is resource conservative
  * Doesn't use schemas
  * Doesn't throw

Available in npm as `assurance`
Source on github: https://github.com/danmilon/assurance

Here's some of it's magicness:

var assurance = require('assurance')

var input = {
  name:'Eve',
  hobbies: ['skating', 'coding', 666]
}

var assure = assurance(input)

assure.me('name').is('string').len(3, 40)
assure.me('hobbies', function (hobby) {
  hobby.is('string').len(3, 40)
})

console.log(assure.end())

// [ { type: 'InvalidType',
// expected: 'string',
// is: 'number',
// message: 'value is of type number but string was expected',
// param: 'hobbies[2]' } ]

Hope you find it useful.
As always, issues & pull requests are more than welcome.

danmilon.

ps: Bonus cookie to whoever sends a PR for browser building

-- 
-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] ANN: node-pcre

2013-01-26 Thread Dan Milon
Not really relevant, but this reminded me of Mads Ager's talk [1], from
the V8 team, when V8 was a new thing. He talks about how they started
with pcre internally, but then decided to write their own regex engine.
Anyway, I found it interesting, you might wanna check it out.

[1] http://www.youtube.com/watch?v=FrufJFBSoQY#at=35m50s


On 01/26/2013 11:40 PM, mscdex wrote:
> Hello all,
> 
> For those who need/want more regexp functionality, I've created a
> binding to pcre. I already had a gypified pcre for my mmmagic addon,
> so it wasn't too bad putting pcre into its own separate addon.
> 
> Currently it builds on Windows, Linux, and OSX. BSD and *Solaris users
> can send me a proper config.h (see the node-pcre readme for ./
> configure flags) that I can include to allow it to build on those
> platforms as well.
> 
> As far as performance goes, it really depends on the pattern. However
> from what I've seen thus far, this binding is at a bit of a speed
> disadvantage due to the crossing of the JS->C++ boundary and other
> differences. But if you want more power than what the JS regexp engine
> gives you, then I would say give this binding a try.
> 
> github: https://github.com/mscdex/node-pcre
> npm: `npm install pcre`
> 

-- 
-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en





Re: [nodejs] Re: Data validation

2013-01-22 Thread Dan Milon
It is not about performance, it is about forcefully trying to merge two
completely different things. I might be wrong, but I can't think of a
pretty and useful API for a validation library that would transparently
issue async operations, and then let you get those results if validation
passed. Application logic gets in the way and doesn't allow for much
flexibility IMO.

I'd be interested to see what you come up with.

danmilon.

On 01/22/2013 02:29 PM, Alan Hoffmeister wrote:
> Dan I see the point, but would it be any performance issue accessing
> external data from inside the validation process instead of prefetching it?
> 
> --
> Att,
> Alan Hoffmeister
> 
> 
> 2013/1/22 Dan Milon mailto:danmi...@gmail.com>>
> 
> comments inline.
> 
> On 01/22/2013 01:56 PM, Alan Hoffmeister wrote:
> > Well, generaly I don't wait for the db to throw a duplication error to
> > warn the user that he needs to pick up another username. But of
> course,
> > if the form is 100% valid I still need to take care about his username
> > at the db layer.
> >
> 
> Then you're doing register wrong.
> 
> > Another example: I need to check if a file exists, send a request to a
> > rest server to check the file metadata and convert a markdown field to
> > HTML using the GitHub's API, that would be a hell of a process that I
> > can't encapsulate inside all those validation modules mentioned here
> > without spliting the process a couple of times.
> >
> 
> Be more specific, what do you want to validate against?
> 
> If validation depends on external data then pre-fetch them yourself.
> 
> eg: When you're handling a sign in request, you query the db for a user
> with that username, hash the provided password, and compare with the
> hashed password in the user record from the db. And you want to validate
> that they are equal. If you were to validate this using a validation
> library, you'd fetch the user record from the db, and then use the
> validation library. You wouldn't ask the validation library to fetch the
> user record from the db.
> 
> danmilon.
> 
> > That's the main idea about the validation/sanitization module that I'm
> > building: async from ground up.
> >
> >
> > --
> > Att,
> > Alan Hoffmeister
> >
> >
> > 2013/1/22 Pedro Teixeira  <mailto:pedro.teixe...@gmail.com>
> > <mailto:pedro.teixe...@gmail.com <mailto:pedro.teixe...@gmail.com>>>
> >
> > Duplicate validation should be handled at the persistence
> layer, not
> > in Node, since you have a concurrency issue there (think of 2
> > simultaneous requests).
> >
> > --
> > Pedro
> >
> > On Tuesday, January 22, 2013 at 11:06 AM, Alan Hoffmeister wrote:
> >
> >> So how do you validate duplicated username, e-mail, etc..? As far
> >> as I could see I need to split the validation process for this,
> >> and I think that this is fucking up with the validation.
> >>
> >> --
> >> Att,
> >> Alan Hoffmeister
> >>
> >>
> >> 2013/1/22 Jake Verbaten  <mailto:rayn...@gmail.com> <mailto:rayn...@gmail.com
> <mailto:rayn...@gmail.com>>>
> >>> Your validating logic is only async if it does IO.
> >>>
> >>> If your validation does IO you fucked up. You don't need async
> >>> support.
> >>>
> >>>
> >>> On Mon, Jan 21, 2013 at 10:11 AM, Alan Hoffmeister
> >>>  <mailto:alanhoffmeis...@gmail.com> <mailto:alanhoffmeis...@gmail.com
> <mailto:alanhoffmeis...@gmail.com>>> wrote:
> >>>> Katsumoto, thats a nice well known package, but I think that
> >>>> lacks async support.
> >>>>
> >>>> --
> >>>> Att,
> >>>> Alan Hoffmeister
> >>>>
> >>>>
> >>>> 2013/1/21 Katsumoto  <mailto:shogun...@gmail.com>
> >>>> <mailto:shogun...@gmail.com <mailto:shogun...@gmail.com>>>
> >>>>> take a look at https://github.com/chriso/node-validator
> >>>>>
> >>>>>   

Re: [nodejs] Re: Data validation

2013-01-22 Thread Dan Milon
comments inline.

On 01/22/2013 01:56 PM, Alan Hoffmeister wrote:
> Well, generaly I don't wait for the db to throw a duplication error to
> warn the user that he needs to pick up another username. But of course,
> if the form is 100% valid I still need to take care about his username
> at the db layer.
> 

Then you're doing register wrong.

> Another example: I need to check if a file exists, send a request to a
> rest server to check the file metadata and convert a markdown field to
> HTML using the GitHub's API, that would be a hell of a process that I
> can't encapsulate inside all those validation modules mentioned here
> without spliting the process a couple of times.
> 

Be more specific, what do you want to validate against?

If validation depends on external data then pre-fetch them yourself.

eg: When you're handling a sign in request, you query the db for a user
with that username, hash the provided password, and compare with the
hashed password in the user record from the db. And you want to validate
that they are equal. If you were to validate this using a validation
library, you'd fetch the user record from the db, and then use the
validation library. You wouldn't ask the validation library to fetch the
user record from the db.

danmilon.

> That's the main idea about the validation/sanitization module that I'm
> building: async from ground up.
> 
> 
> --
> Att,
> Alan Hoffmeister
> 
> 
> 2013/1/22 Pedro Teixeira  >
> 
> Duplicate validation should be handled at the persistence layer, not
> in Node, since you have a concurrency issue there (think of 2
> simultaneous requests).
> 
> -- 
> Pedro
> 
> On Tuesday, January 22, 2013 at 11:06 AM, Alan Hoffmeister wrote:
> 
>> So how do you validate duplicated username, e-mail, etc..? As far
>> as I could see I need to split the validation process for this,
>> and I think that this is fucking up with the validation.
>>
>> --
>> Att,
>> Alan Hoffmeister
>>
>>
>> 2013/1/22 Jake Verbaten mailto:rayn...@gmail.com>>
>>> Your validating logic is only async if it does IO. 
>>>
>>> If your validation does IO you fucked up. You don't need async
>>> support.
>>>
>>>
>>> On Mon, Jan 21, 2013 at 10:11 AM, Alan Hoffmeister
>>> mailto:alanhoffmeis...@gmail.com>> wrote:
 Katsumoto, thats a nice well known package, but I think that
 lacks async support.

 --
 Att,
 Alan Hoffmeister


 2013/1/21 Katsumoto >>> >
> take a look at https://github.com/chriso/node-validator
>
> пятница, 18 января 2013 г., 13:07:13 UTC+2 пользователь Alan
> Hoffmeister написал:
>> Hello fellows!
>>
>> How are you doing data validation like forms and other user
>> inputs? I know that there is some modules to do that but my
>> intention is to do a brainstorm to gather ideas for a new
>> module that I'm developing.
>>
>> Thanks.
>>
>> --
>> Att,
>> Alan Hoffmeister
>
> -- 
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> 
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> 
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

 -- 
 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 Google
 Groups "nodejs" group.
 To post to this group, send email to nodejs@googlegroups.com
 
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 
 For more options, visit this group at
 http://groups.google.com/group/nodejs?hl=en?hl=en
>>>
>>> -- 
>>> 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 Google
>>> Groups "nodejs" group.
>>> To post to this group, send email to nodejs@googlegroups.com
>>> 
>>> To unsubscribe from this group, send email to
>>> nodejs+unsubscr...@googlegroups.com
>>> 
>>> For mor

[nodejs] get failing host from getaddrinfo ENOTFOUND

2013-01-17 Thread Dan Milon
When you get a `getaddrinfo ENOTFOUND` error, is there a way to get
the host that failed? It's coming from node-stripe, for whatever
reason my dns fails and I'm catching it on uncaughtException. I could
wrap the stripe calls, but thats a mediocre solution.

Thanks,
danmilon.

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] basic dependency question

2013-01-14 Thread Dan Milon
Right. I was referring to modules of the same package.


On 01/14/2013 11:02 PM, Angel Java Lopez wrote:
> Well, it could be that B uses C-0.0.1 (declared in its
> package.json), and A uses C-0.0.2
> 
> So
> 
> A --> B --> C-0.0.1 A --> C-0.0.2
> 
> node_modules/A/node_modules/B/node_modules/C <-- C-0.0.1 here 
> node_modules/A/node_modules/C <-- C-0.0.2 here
> 
> 
> On Mon, Jan 14, 2013 at 5:49 PM, Dan Milon  <mailto:danmi...@gmail.com>> wrote:
> 
> Dependencies (aka `require`s) are resolved synchronously.
> 
> So the flow is: A --> B --> C A --> C
> 
> Also modules are cached. [1] ie, they are not loaded twice. A and
> B "see" the same version of C.
> 
> [1] http://nodejs.org/docs/latest/api/modules.html#modules_caching
> 
> Hope this helps, danmilon.
> 
> On 01/14/2013 09:45 PM, Thiago Souza wrote:
>> Hello all,
>> 
>> I've got a basic dependency question. Consider the following 
>> dependencies:
>> 
>> (module A) --> (module B) (module A) --> (module C) (module B)
>> --> (module C)
>> 
>> So, C is a shared dependency between A and B, but A also depends
>> on B. My question is, will A and B share the same C module
>> instance? If so, what code base will be used?
>> 
>> Cheers, Thiago Souza
>> 
>> 
>> 
>> 
>> -- 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 Google
>> Groups "nodejs" group. To post to this group, send email to 
>> nodejs@googlegroups.com <mailto:nodejs@googlegroups.com> To
> unsubscribe from this group, send email
>> to nodejs+unsubscr...@googlegroups.com
> <mailto:nodejs%2bunsubscr...@googlegroups.com> For more options, 
> visit this
>> group at http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> -- 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 Google
> Groups "nodejs" group. To post to this group, send email to
> nodejs@googlegroups.com <mailto:nodejs@googlegroups.com> To
> unsubscribe from this group, send email to 
> nodejs+unsubscr...@googlegroups.com 
> <mailto:nodejs%2bunsubscr...@googlegroups.com> For more options,
> visit this group at 
> http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> 
> -- 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 Google
> Groups "nodejs" group. To post to this group, send email to
> nodejs@googlegroups.com To unsubscribe from this group, send email
> to nodejs+unsubscr...@googlegroups.com For more options, visit this
> group at http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] basic dependency question

2013-01-14 Thread Dan Milon
Dependencies (aka `require`s) are resolved synchronously.

So the flow is:
A --> B --> C
A --> C

Also modules are cached. [1] ie, they are not loaded twice. A and B
"see" the same version of C.

[1] http://nodejs.org/docs/latest/api/modules.html#modules_caching

Hope this helps,
danmilon.

On 01/14/2013 09:45 PM, Thiago Souza wrote:
> Hello all,
> 
> I've got a basic dependency question. Consider the following 
> dependencies:
> 
> (module A) --> (module B) (module A) --> (module C) (module B) -->
> (module C)
> 
> So, C is a shared dependency between A and B, but A also depends on
> B. My question is, will A and B share the same C module instance?
> If so, what code base will be used?
> 
> Cheers, Thiago Souza
> 
> 
> 
> 
> -- 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 Google
> Groups "nodejs" group. To post to this group, send email to
> nodejs@googlegroups.com To unsubscribe from this group, send email
> to nodejs+unsubscr...@googlegroups.com For more options, visit this
> group at http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] node + raspi + Internet of Things (IoT)

2013-01-11 Thread Dan Milon
There was a similar thread some months ago, and a separate list [1] was
created for further discussion. There hasn't been any activity lately,
but you might wanna check with these guys also.

[1] https://groups.google.com/forum/?fromgroups#!forum/iofthings

danmilon.

On 01/11/2013 11:47 AM, Paul Tanner wrote:
> Hi,
> 
> If you have no interest in IoT then this will not be relevant, sorry.
> 
> Now that we have all these cheap and low-power linux platforms I want to
> use those for controlling custom hardware in the way we have used
> Arduino up to now.
> 
> I recently tested node on Raspberry Pi and it seems to work great.  I
> also tried the Mosquitto MQTT broker and its node module and also some
> hardware interfacing (written in C).
> 
> The next step is to explore node "Addons" to make the hardware
> interfacing accessible to node. I have in mind to create some open
> source examples to take to the OSHUG meetup in March.
> 
> While pondering that I wondered if any of you node folks have done this
> or are thinking about it.  If so we should tallk.
> 
> Thx. Paul
> 

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Does events gets executed sync'd or async'd?

2013-01-11 Thread Dan Milon
sync.
https://github.com/joyent/node/blob/master/lib/events.js#L123

danmilon

On 01/11/2013 06:21 PM, Eric wrote:
> Hi guys,
> 
> Newbie question here: when a code calls emitter.emit(event), does the
> listeners get executed synchronously or asynchrounsly?
> 
> Thanks for the help,
> 
> Eric.
> 
> -- 
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Xcode and Node.js

2012-12-20 Thread Dan Milon
Offtopic:

On 12/21/2012 01:06 AM, Ryan Schmidt wrote:
> JavaScript is interpreted, not compiled.

That's not true.

The language by itself does not require the VM to either interpret or
compile the code.

V8 in fact does compile the code into an intermediate format called
Hydrogen. (not assembly). It will even update this intermediate code
on the fly, so you cant really categorize it as interpreted.

danmilon.

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] What's the default value of a buffer

2012-12-07 Thread Dan Milon
Its just allocated space, there's no default. It defaults to whatever
the previous process which owned that chunk of memory wrote there.

danmilon.

On 12/08/2012 04:14 AM, Goddy Zhao wrote:
> var buf = new Buffer(1); console.log(buf[0]);
> 
> The above code will print a random value of buf[0], anyone know why
> the default value of a buffer element is not 0 but a random one,
> and what's the rule of the value?
> 
> -- 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 Google
> Groups "nodejs" group. To post to this group, send email to
> nodejs@googlegroups.com To unsubscribe from this group, send email
> to nodejs+unsubscr...@googlegroups.com For more options, visit this
> group at http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Do ZLib stops the js main loop?

2012-12-05 Thread Dan Milon
It doesnt look like they wait for the previous ones to complete.
Its just more load, so the threads queue up, hence the high latencies.

danmilon.

On 12/05/2012 12:24 PM, 長島徹 wrote:
> Hello.
> 
> I found a strange behavior. I want to get the method to avoid the
> behavior.
> 
> I compress a data (around 1.8MB) with ZLib. result:
> 
> ok(84ms): 0_data.json.gz
> 
> 
> OK, the process finished on around 100ms. I tried to compress the
> data in parallel 50. Having done that, all processes were slow
> similarly. result:
> 
> ok(987ms): 3_data.json.gz ok(1002ms): 4_data.json.gz ok(1002ms):
> 8_data.json.gz ok(1004ms): 0_data.json.gz ok(1004ms):
> 2_data.json.gz ok(1003ms): 5_data.json.gz ok(1002ms):
> 10_data.json.gz ok(1003ms): 6_data.json.gz ok(1004ms):
> 1_data.json.gz ok(1002ms): 13_data.json.gz ok(1003ms):
> 7_data.json.gz ok(1002ms): 9_data.json.gz ok(1002ms):
> 11_data.json.gz ok(998ms): 21_data.json.gz ok(1001ms):
> 16_data.json.gz ok(1003ms): 12_data.json.gz ok(1002ms):
> 17_data.json.gz ok(1003ms): 14_data.json.gz ok(999ms):
> 20_data.json.gz ok(999ms): 24_data.json.gz ok(1002ms):
> 18_data.json.gz ok(999ms): 19_data.json.gz ok(998ms):
> 26_data.json.gz ok(999ms): 23_data.json.gz ok(1002ms):
> 15_data.json.gz ok(999ms): 25_data.json.gz ok(999ms):
> 28_data.json.gz ok(999ms): 29_data.json.gz ok(999ms):
> 30_data.json.gz ok(1000ms): 22_data.json.gz ok(998ms):
> 33_data.json.gz ok(998ms): 32_data.json.gz ok(998ms):
> 35_data.json.gz ok(998ms): 38_data.json.gz ok(999ms):
> 31_data.json.gz ok(998ms): 36_data.json.gz ok(997ms):
> 44_data.json.gz ok(997ms): 42_data.json.gz ok(997ms):
> 39_data.json.gz ok(998ms): 34_data.json.gz ok(997ms):
> 40_data.json.gz ok(998ms): 37_data.json.gz ok(997ms):
> 41_data.json.gz ok(997ms): 43_data.json.gz ok(999ms):
> 27_data.json.gz ok(996ms): 48_data.json.gz ok(996ms):
> 45_data.json.gz ok(997ms): 46_data.json.gz ok(997ms):
> 47_data.json.gz ok(996ms): 49_data.json.gz
> 
> 
> Each process returned after done all processes. Why is this? And
> what do I do to avoid this behavior?
> 
> I had expected that the finished process returns immediately in
> turn. eg:
> 
> ok(100ms): 3_data.json.gz ok(100ms): 4_data.json.gz ok(100ms):
> 8_data.json.gz ok(100ms): 0_data.json.gz ok(100ms): 2_data.json.gz 
> ok(200ms): 5_data.json.gz ok(200ms): 10_data.json.gz ok(200ms):
> 6_data.json.gz ok(200ms): 1_data.json.gz ok(200ms):
> 13_data.json.gz ok(300ms): 7_data.json.gz ok(300ms):
> 9_data.json.gz ok(300ms): 11_data.json.gz  
> 
> 
> 
> Sorry my poor English. Thanks.
> 
> P.S. test program
> 
> 
> 'use strict';
> 
> var Fs = require('fs'); var Z  = require('zlib');
> 
> var target = 'data.json'; var times  = 50;
> 
> var dumpEnd = function (name, begin) { return function () { 
> console.log('ok(' + (Date.now() - begin) + 'ms): ' + name); }; };
> 
> for (var i = 0; i < times; ++i) { var zipName = i + '_' + target +
> '.gz'; var begin   = Date.now();
> 
> Fs.createReadStream(target) .pipe(Z.createGzip()) 
> .pipe(Fs.createWriteStream(zipName)) .on('close', dumpEnd(zipName,
> begin)); }
> 
> -- 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 Google
> Groups "nodejs" group. To post to this group, send email to
> nodejs@googlegroups.com To unsubscribe from this group, send email
> to nodejs+unsubscr...@googlegroups.com For more options, visit this
> group at http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: HTTP client request headers (lowercase) issue

2012-12-01 Thread Dan Milon
I just tested this, and it seems it wont touch them. [1]
I recall having this issue with S3 not recognizing lowercased
content-length header. And explicitly setting the header key as
Content-Length fixed it.

[1] https://gist.github.com/4186458

danmilon.

On Sun, Dec 2, 2012 at 3:07 AM, Mikeal Rogers  wrote:
> by default node.js sends headers in lowercase. by spec, HTTP headers are 
> caseless. if someone does not treat them that way you email them and ask them 
> why they suck at HTTP.
>
> On Dec 1, 2012, at December 1, 20124:50 PM, Dan Milon  
> wrote:
>
>> AFAIK outgoing headers are not lowercased. Do you have a test case?
>>
>> danmilon.
>>
>> On Sat, Dec 1, 2012 at 10:01 PM, Cristian Bullokles
>>  wrote:
>>> Looks like this change stills in v0.8.15 of node.js, I'm trying to
>>> authenticate to an OAuth provider and I've the same problem. My provider is
>>> not able to recognize the authorization header.
>>> Do we have a fix for that issue?
>>>
>>>
>>>
>>> On Tuesday, March 8, 2011 9:43:56 PM UTC-3, Eran Hammer-Lahav wrote:
>>>>
>>>> A recent update changed how client request headers are sent to force all
>>>> headers to lowercase. This is causing problems with some well-established
>>>> (and non-compliant) servers which look for specific case-sensitive
>>>> formatting. My application is now failing on both the 'Authorization' and
>>>> 'Cookie' headers with some large providers.
>>>>
>>>> I see the value in changing incoming headers to lowercase, but it would be
>>>> better to leave outbound headers alone and allow applications to set the
>>>> headers to the exact format expected by the server in case of a misbehaving
>>>> provider.
>>>>
>>>> Can this be changed back?
>>>>
>>>> EHL
>>>
>>> --
>>> 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 Google
>>> Groups "nodejs" group.
>>> To post to this group, send email to nodejs@googlegroups.com
>>> To unsubscribe from this group, send email to
>>> nodejs+unsubscr...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>> --
>> 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 Google
>> Groups "nodejs" group.
>> To post to this group, send email to nodejs@googlegroups.com
>> To unsubscribe from this group, send email to
>> nodejs+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>
> --
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: HTTP client request headers (lowercase) issue

2012-12-01 Thread Dan Milon
AFAIK outgoing headers are not lowercased. Do you have a test case?

danmilon.

On Sat, Dec 1, 2012 at 10:01 PM, Cristian Bullokles
 wrote:
> Looks like this change stills in v0.8.15 of node.js, I'm trying to
> authenticate to an OAuth provider and I've the same problem. My provider is
> not able to recognize the authorization header.
> Do we have a fix for that issue?
>
>
>
> On Tuesday, March 8, 2011 9:43:56 PM UTC-3, Eran Hammer-Lahav wrote:
>>
>> A recent update changed how client request headers are sent to force all
>> headers to lowercase. This is causing problems with some well-established
>> (and non-compliant) servers which look for specific case-sensitive
>> formatting. My application is now failing on both the 'Authorization' and
>> 'Cookie' headers with some large providers.
>>
>> I see the value in changing incoming headers to lowercase, but it would be
>> better to leave outbound headers alone and allow applications to set the
>> headers to the exact format expected by the server in case of a misbehaving
>> provider.
>>
>> Can this be changed back?
>>
>> EHL
>
> --
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: Should stream.pipe forward errors?

2012-11-28 Thread Dan Milon
Technically you could explicitly add each stream to its own domain.

danmilon.

On 11/29/2012 02:47 AM, Mikeal Rogers wrote:
> with domains, these will all get trapped in the same domain because
> they are all event emitters, if they throw.
> 
> i tried forwarding errors through pipe chains but it ended up
> being problematic and i've since backed off.
> 
> On Nov 28, 2012, at November 28, 20121:24 PM, Marco Rogers 
> mailto:marco.rog...@gmail.com>> wrote:
> 
>> Yeah I wish there was a better story for this. It's easy to
>> forward errors. It could become difficult to determine in what
>> context the error was thrown.
>> 
>> :Marco
>> 
>> On Wednesday, November 28, 2012 9:10:51 AM UTC-8, Jeff Barczewski
>> wrote:
>> 
>> I was recently testing some stream piping like
>> 
>> rstream .pipe(foo) .pipe(bar) .on('error', function (err) { //
>> handle the error });
>> 
>> and I found out that currently stream.pipe does not forward the
>> 'error' events, so if you wanted to handle the errors you would
>> need to do something like
>> 
>> rstream .on('error', handleError) .pipe(foo) .on('error',
>> handleError) .pipe(bar) .on('error', handleError);
>> 
>> or possibly rely on domains to deal with the error, but I would
>> prefer to leave domains for other more catastrophic errors and
>> just deal with errors at the end of the pipe chain.
>> 
>> The current node.js code checks to see if the source has any
>> error listeners and if there are none then it throws an Error. If
>> there was an error listener on the source then it will be given
>> the error to deal with.
>> 
>> 
>> So to all the experienced streams users out there,
>> 
>> 1. How do you believe it should work? (or is there a better way) 
>> 2. Is there any edge cases that we need to consider if we were
>> to implement as I described above?
>> 
>> 
>> Thanks in advance for your input!
>> 
>> Jeff
>> 
>> 
>> -- 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 Google
>> Groups "nodejs" group. To post to this group, send email to
>> nodejs@googlegroups.com  To
>> unsubscribe from this group, send email to 
>> nodejs+unsubscr...@googlegroups.com 
>>  For more options,
>> visit this group at 
>> http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> -- 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 Google
> Groups "nodejs" group. To post to this group, send email to
> nodejs@googlegroups.com To unsubscribe from this group, send email
> to nodejs+unsubscr...@googlegroups.com For more options, visit this
> group at http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Problem with using socket.io

2012-11-01 Thread Dan Milon
Probably the browser (for some reason) did not fetch the socket.io.js
file, so the global variable "io" does not exist.

Make sure the server returns the file, and the client can talk to the
server.

danmilon.

On 11/01/2012 11:12 PM, _Kili_ wrote:
> Hi,
> I am beginner with node.js and just trying to make socket.io work with
> this guide http://socket.io/#how-to-use (the first example).
> I am just getting "Uncaught ReferenceError: io is not defined" in the
> java script console of the Chrome.
> Could someone help me?
> 
> -- 
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: process.env - documentation?

2012-11-01 Thread Dan Milon
I totally agree with Tim & SL here.

I think the argument: "If you google'ed you'd find out" is invalid. The
same argument could be used for almost every question in this mailing list.

To keep away from over-documenting I agree with Tim, at least there
should be a link to an online man page.
But I also find the "user variables" term misleading. I dont know whats
the official term, but i always refer to them as "environmental variables".

danmilon.

On 11/01/2012 07:02 PM, Chad Engler wrote:
> Ill repeat myself for the third time now: If you see something and are
> confused on what it means, Google is a great starting point. Had you
> attempting to figure it out on your own, you would have seen the first
> link, felt silly, and moved on.
> 
>  
> 
> -Chad
> 
>  
> 
> *From:*nodejs@googlegroups.com [mailto:nodejs@googlegroups.com] *On
> Behalf Of *SL
> *Sent:* Thursday, November 01, 2012 1:01 PM
> *To:* nodejs@googlegroups.com
> *Subject:* Re: [nodejs] Re: process.env - documentation?
> 
>  
> 
> Ok, last post as the vibe here is a distinctly unfriendly... It's quite
> simple: When I read 'see environ(7)' I assumed that was a reference to
> another part of the node docs.  When a reference is made to another
> source, I'm used to seeing the source named.  If it had said 'see:
> man-pages environ(7)' there probably would have been no misunderstanding.
> 
>  
> 
>  
> 
> On 1 November 2012 17:58, Chad Engler  > wrote:
> 
> I really think all of this could have been avoided, and new knowledge
> consumed using this simple process that has guided me for years:
> 
>  
> 
> 1.   Encounter unknown term, phrase, or idea
> 
> 2.   Copy unknown term, phrase, or idea to clipboard
> 
> 3.   Paste unknown term, phrase, or idea into a search engine search
> bar (I tend to use Google)
> 
> 4.   Select “Search”
> 
> 5.   View results, which 98% of the time will clear up confusion.
> 
>  
> 
> If this process fails, then repeat using similar terms. If that /also/
> fails, then I usually head to StackOverflow/mailing lists.
> 
>  
> 
> My point was there was no attempt to solve this besides “tell me what I
> need to know” and “We should fix the docs so people who have never
> developed before can use them.”
> 
>  
> 
> -Chad
> 
>  
> 
> *From:*nodejs@googlegroups.com 
> [mailto:nodejs@googlegroups.com ] *On
> Behalf Of *SL
> *Sent:* Thursday, November 01, 2012 12:49 PM
> 
> 
> *To:* nodejs@googlegroups.com 
> *Subject:* Re: [nodejs] Re: process.env - documentation?
> 
>  
> 
> As you guessed, I'm developing on Windows.  Thanks for the
> understanding!  Yes a link would have avoided all confusion.
> 
> On 1 November 2012 17:42, Tim Caswell  > wrote:
> 
> I've been using since before it was popular.  Back in the early days,
> the docs for node were full of references to linux man pages like
> this.  My background was scripting languages and I had never done any
> C programming so I had no clue what readdir(3) meant.   To open a file
> back then you had to manually bitwise OR the various unix flags
> together yourself. (Using "r", "w", "a", etc was an addition I made)
> 
> Things now are much easier for people without a C background and there
> are many fewer parts left in the docs that assume knowledge of man
> pages.
> 
> That said, I did eventually figure out it was referencing man pages.
> I was a linux user after all, I had just never used man to lookup C
> APis.
> 
> How about we just link to one of the man mirrors in the API docs?  I
> was an experienced linux user and I still didn't know what the docs
> were talking about, I can only imagine how confused windows users
> would be.
> 
> 
> On Thu, Nov 1, 2012 at 11:34 AM, Chad Engler  > wrote:
>> It wasn’t condescending; “topic(page#)” like “environ(7)” is a very common
>> way to express man pages, and if you aren’t aware of what the user
>> environment is you should probably do more research. Had you typed
>> “environ(7)” into google before getting butthurt at the docs, you probably
>> would have found out exactly what it was with no help from anyone.
> There is
>> no reason to repost the manual page since there is already a manual
> page for
>> it, the docs are fine the way they are; you just need to try to look a
>> little harder, or be grateful when people help.
>>
>>
>>
>> -Chad
>>
>>
>>
>> From: nodejs@googlegroups.com 
> [mailto:nodejs@googlegroups.com ] On
> Behalf Of
>> SL
>> Sent: Thursday, November 01, 2012 12:16 PM
>> To: nodejs@googlegroups.com 
>> Subject: Re: [nodejs] Re: process.env - documentation?
>>
>>
>>
>> Wow, thanks for the condescending and arrogant comment!  I'm not
> suggesting
>> there should be a 'tutorial' about any of those things you mentioned.

Re: [nodejs] Creating a stateful server using node.js

2012-11-01 Thread Dan Milon
Sounds like you need a database, not?
Is there a particular reason you wont use a regular generic external
database? You could even use embedded levelDB
https://github.com/rvagg/node-levelup

danmilon.

On 11/01/2012 12:02 PM, Arindam Mukherjee wrote:
> I am trying to write a distributed monitoring and replication framework
> for files using node.js. I want to keep track of the last modified time,
> chksum, size, etc of files in a directory and bump up a version if
> something changes. For this I need to be able to compare older stored
> values of these (timestamp, size, md5sum, etc) with newly discovered
> changed values. I am unable to figure out how to define the data
> structures for this node.js and also how to update them without
> concurrency issues due to, say, multiple callbacks trying to update the
> data.
> 
> Thanks,
> Arindam
> 
> -- 
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Socket.io, answer WELL, don't lock.

2012-10-31 Thread Dan Milon
You could look into the code and figure out the problem yourself.

danmilon.

On 10/31/2012 08:47 PM, Andreas Backx wrote:
> Well I've been waiting on there for a couple of days and I don't have
> the time to wait: https://github.com/einaros/ws/issues/127
> 
> Op woensdag 31 oktober 2012 16:27:45 UTC+1 schreef Martin Cooper het
> volgende:
> 
> 
> On the Node.js home page, the Community link says "Mailing lists,
> blogs, and more". Clicking on it takes you to a page with a section
> named "Mailing List".
> 
> That said, the original error log you posted contains this:
> 
> ERR! Failed at the ws@0.4.22 install script.
> ERR! This is most likely a problem with the ws package,
> ERR! not with npm itself.
> ERR! Tell the author that this fails on your system:
> ERR! node install.js
> ERR! You can get their info via:
> ERR! npm owner ls ws
> 
> which should have sent you to the 'ws' issue tracker right away.
> 
> -- 
> Martin Cooper
> 
> 
> > and I also didn't know much about
> > the path variable.
> >
> > Op woensdag 31 oktober 2012 15:22:29 UTC+1 schreef Dan Milon het
> volgende:
> >>
> >> You didnt post any issues, but posted a "plz help me" question on
> node's
> >> issue tracker. Issues are bugs/unexpected behaviour/new
> >> features/proposals, not questions.
> >>
> >> That's why there's this mailing list for questions/discussions,
> but this
> >> attitude wont get you a long way.
> >>
> >> danmilon.
> >>
> >> On 10/31/2012 04:11 PM, Andreas Backx wrote:
> >> > I have been posting 2 issues on the nodejs GitHub page and both
> of them
> >> > people reply to like do this, do this without explanation and
> lock the
> >> > thread. Really?
> >> > https://github.com/joyent/node/issues/4222
> <https://github.com/joyent/node/issues/4222>
> >> >
> >> > Answer the question and don't be like oh no this doesn't belong
> here or
> >> > whatever, I try Google and every other single coding website to
> solve
> >> > the issue, none of them help.
> >> >
> >> > --
> >> > Job Board: http://jobs.nodejs.org/
> >> > Posting guidelines:
> >> >
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> <https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines>
> >> > You received this message because you are subscribed to the Google
> >> > Groups "nodejs" group.
> >> > To post to this group, send email to nod...@googlegroups.com
> >> > To unsubscribe from this group, send email to
> >> > nodejs+un...@googlegroups.com
> >> > For more options, visit this group at
> >> > http://groups.google.com/group/nodejs?hl=en?hl=en
> <http://groups.google.com/group/nodejs?hl=en?hl=en>
> >>
> > --
> > Job Board: http://jobs.nodejs.org/
> > Posting guidelines:
> >
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> <https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines>
> > You received this message because you are subscribed to the Google
> > Groups "nodejs" group.
> > To post to this group, send email to nod...@googlegroups.com
> 
> > To unsubscribe from this group, send email to
> > nodejs+un...@googlegroups.com 
> > For more options, visit this group at
> > http://groups.google.com/group/nodejs?hl=en?hl=en
> <http://groups.google.com/group/nodejs?hl=en?hl=en>
> 
> -- 
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: Socket.io, answer WELL, don't lock.

2012-10-31 Thread Dan Milon
Personally I can't help you with that issue, but you might be luckier if
you post this on the socket.io mailing list.

https://groups.google.com/forum/?fromgroups#!forum/socket_io

On 10/31/2012 04:32 PM, Andreas Backx wrote:
> Also, why isn't it a bug then? I've never seen someone else have it. I
> can install it fine on another machine.
> 
> -- 
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Socket.io, answer WELL, don't lock.

2012-10-31 Thread Dan Milon
You didnt post any issues, but posted a "plz help me" question on node's
issue tracker. Issues are bugs/unexpected behaviour/new
features/proposals, not questions.

That's why there's this mailing list for questions/discussions, but this
attitude wont get you a long way.

danmilon.

On 10/31/2012 04:11 PM, Andreas Backx wrote:
> I have been posting 2 issues on the nodejs GitHub page and both of them
> people reply to like do this, do this without explanation and lock the
> thread. Really?
> https://github.com/joyent/node/issues/4222
> 
> Answer the question and don't be like oh no this doesn't belong here or
> whatever, I try Google and every other single coding website to solve
> the issue, none of them help. 
> 
> -- 
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] [ANN] passbookster: An iOS passbook generation library

2012-10-29 Thread Dan Milon

I'd like to announce Passbookster.

Passbookster allows you to create iOS passbook passes. It provides both
a stream and callback API. Great care has been taken on performance.
Node crypto module does not currently support PKCS#7 signing, so openssl
is spawned internally, but a PR to add this functionality is underway.

Shortly it will be used in a production system, so we've got you covered.

Github repo: https://github.com/danmilon/passbookster
Available as `passbookster` in npm.

As usual:
Code is thoroughly documented.
Feedback / Issues / Pull requests are more than welcome!

Thanks,
danmilon.

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: Sample code to add basic authentication to node http server

2012-10-29 Thread Dan Milon
Express middlewares are called in the order you define them.
The static middleware will call the next middleware only if it failed
serving the static resource.

You need basicAuth before static.

danmilon.

On 10/29/2012 12:41 AM, gng wrote:
> Hi all,
> 
> Sorry to appear dumb about this, but no amount of tweaking (private
> browsing, clearing cookies, restarting browser etc) seems to fix this.
> My simple server code is as follows:-
> 
> var express = require('express');
> var server = express.createServer();
> 
> server.use(express.basicAuth('test','testpass'));
> 
> io = require('socket.io').listen(server);
> 
> server.use(express.static(__dirname + '/public'));
> server.use(express.basicAuth(function(user,pass){
> return 'test'==user & 'testpass' == pass;
> }));
> 
> 
> server.listen(80);
> 
> So I'd expect every new user that trys to browse a resource in the
> server to be presented with a login/password challenge. The browser
> could cache this detail (based on the user permission) for the duration
> of the browser session (but this is immaterial) - the point is every
> unique user would get challenged. I'm not seeing this at all - any new
> client can access a resource without a challenge.
> 
> Again, any help much appreciated !
> 
> Thanks.
> 
> 
> 
> On Thursday, 25 October 2012 14:36:19 UTC+1, Dan Milon wrote:
> 
> Basic Auth does not use cookies. After you provide the credentials, its
> up to the browser to stop sending the Authentication header. Usually
> that happens after a browser restart. Try private browsing.
> 
> danmilon.
> 
> On 10/25/2012 04:16 PM, gng wrote:
> > Sorry, I should have been more specific: I have removed cookies (even
> > restarted the browser) but I do not get challenged again.
> >
> > Is there anything that I'm missing ? The way I understand things
> is that
> > on clearing any set cookies, you should be challenged each time
> the page
> > is next visited.
> >
> > On Thursday, 25 October 2012 14:07:28 UTC+1, greelgorke wrote:
> >
> > check your cookies. flushing cache has no effect on cookies.
> >
> > Am Donnerstag, 25. Oktober 2012 14:31:53 UTC+2 schrieb gng:
> >
> > Thanks. I added that so my code now looks like :-
> >
> > var express = require('express');
> >
> > var server = express.createServer();
> >
> > server.use(express.basicAuth('test','testpass'));
> >
> > io = require('socket.io <http://socket.io>
> <http://socket.io>').listen(server);
> > io.set('log level', 1); // reduce logging
> >
> > server.use(express.static(__dirname + '/public'));
> > server.use(express.basicAuth(function(user,pass){
> > return 'test'==user & 'testpass' == pass;
> > }));
> >
> >
> > server.listen(80);
> >
> >
> > On starting the server and first accessing a page, there is
> > indeed a prompt for a username and password. If that's
> supplied,
> > the page is then rendered. However, on restarting and
> visiting
> > the page, no prompt is made (browser cache is flushed etc)
> - is
> > there a way to overcome that ?
> >
> > On Thursday, 25 October 2012 12:44:49 UTC+1, greelgorke
> wrote:
> >
> > http://expressjs.com/api.html#basicAuth
> <http://expressjs.com/api.html#basicAuth>
> > <http://expressjs.com/api.html#basicAuth
> <http://expressjs.com/api.html#basicAuth>>
> >
> > Am Donnerstag, 25. Oktober 2012 11:23:08 UTC+2 schrieb
> gng:
> >
> > Hi,
> >
> > Can anyone provide some sample code to show how a
> node
> > http server can be secured using basic
> username/password
> > authentication. Here's my sample server :-
> >
> > var express = require('express');
> > var server = express.createServer();
> >
> > server.use(express.static(__dirname + '/public'));
>

Re: [nodejs] Re: Server-to-Server Communication

2012-10-27 Thread Dan Milon
IMO socket.io/engine.io aim for server-client communication.
But it would be interesting to see some numbers.

danmilon.

On 10/28/2012 12:49 AM, Marak Squires wrote:
> Use https://github.com/learnboost/engine.io
> 
> On Sat, Oct 27, 2012 at 2:31 PM, Jacob Groundwater  > wrote:
> 
> It looks like ZeroMQ does not play well with the asynchronous nature
> of Node. Take a look at the following gist:
> 
> https://gist.github.com/3966362
> 
> I would expect to see three replies from the server, except there is
> only one. This occurs when the server tries to reply out of order.
> Changing the send order to the following works:
> 
> sockit('thr').send( JSON.stringify({timeout:0,name:'thr'}) )
> sockit('two').send( JSON.stringify({timeout:1000,name:'two'}) )
> sockit('one').send( JSON.stringify({timeout:5000,name:'one'}) )
> 
> 
> 
> On Sat, Oct 27, 2012 at 11:46 AM, Alexey Kupershtokh
> mailto:alexey.kupersht...@gmail.com>>
> wrote:
> 
> I'm also interested in this theme.
> 
> AFAIR, dnode 6 months ago was good in features but terribly slow
> comparing to socket.io/axon .
> 
> https://github.com/visionmedia/axon looks interesting, but
> unstable yet - I have already found an issue
> ( https://github.com/visionmedia/axon/pull/62 ). Also I don't
> like it's feature to open a new socket/port for each
> communication type.
> 
> Also I don't like Socket.io's feature that it doesn't free ACK
> callbacks (probably already does) which is a leak for long &
> intensive s2s sockets.
> 
> воскресенье, 28 октября 2012 г., 1:32:19 UTC+7 пользователь
> Jacob написал:
> 
> I was wondering what others are using for communication
> between back-end servers. Since I control all involved
> servers, I would rather not include authentication at the
> application layer. Forwarding SSH ports is perfectly acceptable.
> 
> On that note, my own research has lead me to three options,
> in order of personal preference:
> 
>  1. a message queue (ZeroMQ)
>  2. websockets (socket.io )
>  3. synchronize against the database (MySQL or Redis)
> 
> ZeroMQ seems pretty awesome, but I am curious if anyone has
> tried it, and what there experience was. For example, I
> stumbled across an article discussing how their REQ/REP
> model can lock up easily.
>  
> The
> workaround is fairly simple, but I am interested in
> soliciting more experience in the area.
> 
> Websockets seem like a "native" way, but I see them as
> living in the client-server domain. For example, I would
> have to setup express and a basic restful service on each
> back-end server. Websockets are also 1-to-1, where as ZeroMQ
> supports N-to-N connections.
> 
> Synchronizing against the database would involve polling to
> achieve real-time like events. I know Redis supports a
> pub/sub system, but does not seem to have any RPC-like
> mechanisms.
> 
> In the end, I will make the decision best suited to our
> needs, but I am sure I can gain from some discussion on the
> matter.
> 
> Thanks everyone,
> 
> - Jacob Groundwater
> 
> -- 
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> 
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> 
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> 
> -- 
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> 
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> 
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> 
> -- 
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
>

Re: [nodejs] nodejs zlib performance

2012-10-25 Thread Dan Milon
Thats out of node's scope.
If you've got too much work to do, and too few cores, well, shit get
scheduled. Plus, there are a lot of processes already fighting for some
CPU juice.

Essentially what you're talking here is CPU scheduling.

danmilon.

On 10/26/2012 02:49 AM, Jimb Esser wrote:
> That is exactly what node seems to do with the zlib API.  Though there
> are times where this is great, this API definitely bothers me, and
> causes some problems.  In theory, if I have a 4 core machine, and have 4
> busy node processes, and each of them try to use the zlib API, suddenly
> I've got 8 cores worth of threads all fighting for the CPU (or, possibly
> many more if multiple zlib requests are made and each process has a
> thread pool equal to the number of cores?).  Since zlib stuff is
> CPU-intensive, not I/O intensive, it would be great if there was a
> synchronous API so that we can ensure the handling of a single task
> (whether it be expensive JS code, or zlib operations) is consuming only
> a core.  The async API on Zlib stuff seems odd when compared to the
> Crypto APIs, which are all synchronous, despite being, I think, quite
> more CPU-intensive (per-byte) than Zlib.
> 
> Admittedly, there are OS-level CPU affinity masks which could be used
> here, but in general that's not particularly good for overall performance.
> 
> On Thursday, October 25, 2012 2:39:10 PM UTC-7, Mark Hahn wrote:
> 
> > Are you saying that node, internally, delegates CPU intensive work
> to background threads?
> 
> What the heck are you talking about?  There is no such feature and
> there shouldn't be.
> 
> -- 
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: Use of Node / Express / MongoDB for a e-commerce website?

2012-10-25 Thread Dan Milon
Still, postgres foreign tables do not support SQL transactions, which
you'd need for an e-commerce product.

But its definitely interesting.

On 10/25/2012 06:58 PM, Stephen Handley wrote:
> re: the idea of using sql for some transactions and mongo for an object
> store 
> 
> http://www.citusdata.com/blog/51-run-sql-on-mongodb
> http://www.craigkerstiens.com/2012/10/18/connecting_to_redis_from_postgres/
> http://wiki.postgresql.org/wiki/Foreign_data_wrappers
> 
> -- 
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: Sample code to add basic authentication to node http server

2012-10-25 Thread Dan Milon
Basic Auth does not use cookies. After you provide the credentials, its
up to the browser to stop sending the Authentication header. Usually
that happens after a browser restart. Try private browsing.

danmilon.

On 10/25/2012 04:16 PM, gng wrote:
> Sorry, I should have been more specific: I have removed cookies (even
> restarted the browser) but I do not get challenged again.
> 
> Is there anything that I'm missing ? The way I understand things is that
> on clearing any set cookies, you should be challenged each time the page
> is next visited.
> 
> On Thursday, 25 October 2012 14:07:28 UTC+1, greelgorke wrote:
> 
> check your cookies. flushing cache has no effect on cookies.
> 
> Am Donnerstag, 25. Oktober 2012 14:31:53 UTC+2 schrieb gng:
> 
> Thanks. I added that so my code now looks like :-
> 
> var express = require('express');
> 
> var server = express.createServer();
> 
> server.use(express.basicAuth('test','testpass'));
> 
> io = require('socket.io ').listen(server);
> io.set('log level', 1); // reduce logging
> 
> server.use(express.static(__dirname + '/public'));
> server.use(express.basicAuth(function(user,pass){
> return 'test'==user & 'testpass' == pass;
> }));
> 
> 
> server.listen(80);
> 
> 
> On starting the server and first accessing a page, there is
> indeed a prompt for a username and password. If that's supplied,
> the page is then rendered. However, on restarting and visiting
> the page, no prompt is made (browser cache is flushed etc) - is
> there a way to overcome that ?
> 
> On Thursday, 25 October 2012 12:44:49 UTC+1, greelgorke wrote:
> 
> http://expressjs.com/api.html#basicAuth
> 
> 
> Am Donnerstag, 25. Oktober 2012 11:23:08 UTC+2 schrieb gng:
> 
> Hi,
> 
> Can anyone provide some sample code to show how a node
> http server can be secured using basic username/password
> authentication. Here's my sample server :-
> 
> var express = require('express');
> var server = express.createServer();
> 
> server.use(express.static(__dirname + '/public'));
> server.listen(80);
> 
> I've seen packages such as http-auth etc ...
> 
> Thanks in advance !
> 
> -- 
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] npm registry down

2012-10-22 Thread Dan Milon
Thanks for the info!
Pitty npm isnt deployed in many areas.

On Mon, Oct 22, 2012 at 9:58 PM, Forrest L Norvell  wrote:
> On Monday, October 22, 2012 at 11:55 AM, Dan Milon wrote:
>
> curl -v https://registry.npmjs.org
> * About to connect() to registry.npmjs.org port 443 (#0)
> * Trying 23.23.147.24... Connection refused
> * couldn't connect to host
> * Closing connection #0
> curl: (7) couldn't connect to host
>
> Anyone got a mirror?
>
> This is tied to the AWS us-east-1 EBS downtime. Will come back with
> us-east-1.
>
> F
>
> --
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] npm registry down

2012-10-22 Thread Dan Milon
curl -v https://registry.npmjs.org
* About to connect() to registry.npmjs.org port 443 (#0)
*   Trying 23.23.147.24... Connection refused
* couldn't connect to host
* Closing connection #0
curl: (7) couldn't connect to host

Anyone got a mirror?

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: How to properly coordinate a sole task between multiple processes on many servers

2012-10-05 Thread Dan Milon
Mongo is definitely NOT always consistent.

On Fri, Oct 5, 2012 at 10:14 PM, Evan  wrote:

> You are basically proposing the schema for DelayedJobs (Ruby) [
> https://github.com/collectiveidea/delayed_job ].  This kind of thing gets
> really weird in eventually consistant databases, but Mongo (like mySQL) is
> always consistant so you should be OK.  However, a lot of folks have been
> finding some locking problems with this approach (multiple job execution or
> really aggressive table locking is needed), so most folks tend to use a
> store which can support atomic "push" and "pop" operations  so you can
> ensure that one and only one worker gets the job.  Redis is the most
> popular of these types of stores these day.  I make use of that property in
> http://actionherojs.com/ for exactly this purpose, as does the very
> popular https://github.com/defunkt/resque and some other projects.
>
>
> On Friday, October 5, 2012 12:32:39 PM UTC-7, Mark Hahn wrote:
>
>> I may be crazy but I'm implementing a scheme where processes get the
>> tasks from a db record and then stores their process number in that record.
>>  Then while they are running they periodically check to make sure that
>> their server number is still the one in the record.  If another process has
>> 'stolen' the task then the process aborts and looks for another one to do.
>>
>> This is the only way I could figure out how to do task assignment when
>> faced with a db that only has "eventual consistency".  The CouchDB i'm
>> using offers no atomic operations so this was the only reliable way to do
>> it.
>>
>> It works quite well.  In the usual case it just grabs the task, does it,
>> and moves on.  Collisions are rare, but they may be more frequent as the
>> cluster grows in size.
>>
>>
>> On Fri, Oct 5, 2012 at 9:21 AM, Dan Milon  wrote:
>>
>>> greelkorke ment using a job queue where jobs are put, and handed to
>>> workers.
>>>
>>> If you want to do it only with mongo, you'll need to use some "lock"
>>> document, that is set and unset by the first process which tries to
>>> initiate a task. All other processes which try to grab the lock while its
>>> held by another process should assume that the job is being worked by
>>> another process. But thats really ugly & has problems because jobs cant be
>>> acknowledged, so if a process crashes while its performing some task,
>>> you're fucked.
>>>
>>> On Fri, Oct 5, 2012 at 5:07 PM, Tom  wrote:
>>>
>>>> Unfortunately I'm afraid that I don't see how a scheduler can avoid the
>>>> concurrency problems. Note that the advantages (e.g. in availability) of
>>>> having a cluster should be maintained here, and so you cannot run a
>>>> scheduler in a separate process on a single server. If every server would
>>>> be running the scheduler, the same concurrency problems would arise. What
>>>> were you proposing?
>>>>
>>>> About the initialization, I guess that would work. It is not the way I
>>>> would prefer to do it, as I would like the application to be
>>>> self-controlled and usable without running special tools, but I reckon it
>>>> is an acceptable approach.
>>>>
>>>> Tom
>>>>
>>>> Op vrijdag 5 oktober 2012 19:59:33 UTC+7 schreef greelgorke het
>>>> volgende:
>>>>
>>>>> i wouldn't do it that way. when deploying your app just do a pre-start
>>>>> script, that ensures the existence of your desired data.
>>>>> If you have periodical tasks, it's best to use a lib for it, that
>>>>> triggers jobs appart of your main application. i.E
>>>>> http://stackoverflow.com/**q**uestions/3785736/is-there-a-**jo**
>>>>> b-scheduler-library-for-**node-**js<http://stackoverflow.com/questions/3785736/is-there-a-job-scheduler-library-for-node-js>,
>>>>>  so you just avoid the concurrency problems.
>>>>>
>>>>> Am Freitag, 5. Oktober 2012 14:04:58 UTC+2 schrieb Tom:
>>>>>>
>>>>>> I've setup a cluster of physical servers. Each server runs exactly
>>>>>> the same code. Moreover, each server runs multiple node processes using
>>>>>> the build in cluster functionality.
>>>>>>
>>>>>> I use MongoDB (native) to share information between processes and
>>>>>> servers. However, I am having some difficulty with run

Re: [nodejs] Re: How to properly coordinate a sole task between multiple processes on many servers

2012-10-05 Thread Dan Milon
greelkorke ment using a job queue where jobs are put, and handed to workers.

If you want to do it only with mongo, you'll need to use some "lock"
document, that is set and unset by the first process which tries to
initiate a task. All other processes which try to grab the lock while its
held by another process should assume that the job is being worked by
another process. But thats really ugly & has problems because jobs cant be
acknowledged, so if a process crashes while its performing some task,
you're fucked.

On Fri, Oct 5, 2012 at 5:07 PM, Tom  wrote:

> Unfortunately I'm afraid that I don't see how a scheduler can avoid the
> concurrency problems. Note that the advantages (e.g. in availability) of
> having a cluster should be maintained here, and so you cannot run a
> scheduler in a separate process on a single server. If every server would
> be running the scheduler, the same concurrency problems would arise. What
> were you proposing?
>
> About the initialization, I guess that would work. It is not the way I
> would prefer to do it, as I would like the application to be
> self-controlled and usable without running special tools, but I reckon it
> is an acceptable approach.
>
> Tom
>
> Op vrijdag 5 oktober 2012 19:59:33 UTC+7 schreef greelgorke het volgende:
>
>> i wouldn't do it that way. when deploying your app just do a pre-start
>> script, that ensures the existence of your desired data.
>> If you have periodical tasks, it's best to use a lib for it, that
>> triggers jobs appart of your main application. i.E
>> http://stackoverflow.com/**questions/3785736/is-there-a-**
>> job-scheduler-library-for-**node-js,
>>  so you just avoid the concurrency problems.
>>
>> Am Freitag, 5. Oktober 2012 14:04:58 UTC+2 schrieb Tom:
>>>
>>> I've setup a cluster of physical servers. Each server runs exactly the
>>> same code. Moreover, each server runs multiple node processes using
>>> the build in cluster functionality.
>>>
>>> I use MongoDB (native) to share information between processes and
>>> servers. However, I am having some difficulty with running a special task
>>> that needs to be executed only once during initialization:
>>> > if a special `admin` account does not yet exist in the database, it
>>> should be created
>>>
>>> Originally I figured that I could read from the MongoDB master server on
>>> each node and check if the admin account already exists. If it does not
>>> then another node has not yet created it, so this node should do so.
>>> However this is problematic because creating an admin password hash is
>>> asynchronous and takes time. Therefore there is a delay between when a node
>>> decides to create the account and when the account is being found by other
>>> nodes when querying the database.
>>>
>>> The code snippet that reads from the Mongo master only and creates the
>>> account is available here: 
>>> https://gist.github.com/**3839429
>>>
>>> In the future I would also like a special task to be executed every 5
>>> minutes. This task must then only be executed by a running server, and not
>>> by all servers.
>>>
>>> In short: when running a cluster of servers, how do you coordinate
>>> between these servers which of them is going to execute a sole task such as
>>> the one described above?
>>>
>>> Tom
>>>
>>  --
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Array reads faster than Buffer reads ???

2012-10-04 Thread Dan Milon
Curious, shouldn't V8 be able to inline the readUInt8 function call, or
there's more than that?

On Thu, Oct 4, 2012 at 1:43 AM, Ben Noordhuis  wrote:

> On Thu, Oct 4, 2012 at 1:37 AM, NodeNinja  wrote:
> > Doing some tests on windows with node v0.8.11
> > 
> > var buf = new Buffer(1000);
> > buf.fill(0xFF);
> >
> > var len = buf.length;
> > var a;
> > var start = new Date();
> > for(var b = 0 ; b < len; b++){
> > a = buf.readUInt8(b);
> > }
> > var end = new Date();
> >
> > console.log('Buffer reads ' + (end - start) + ' ms'); // Prints 81ms
> >
> > 
> >
> > var arr = [];
> > var len = 1000;
> > for(b = 0 ; b < len; b++){
> > arr[b] = 0xFF;
> > }
> > var len = arr.length;
> > console.log(len);
> > start = new Date();
> > for(b = 0 ; b < len; b++){
> > a = arr[b];
> > }
> > end = new Date();
> >
> > console.log('Array reads ' + (end - start) + ' ms'); // Prints 29ms
> >
> > And I always thought that buffers would be faster than arrays in node.js
> ?
> > :(
> > Am I doing something wrong ??
>
> Don't use buf.readUInt8(), it's only there for the sake of parity with
> the other .readUInt*() functions. Replace it with `a = buf[b]` and
> you'll see a 4-5x speed-up.
>
> --
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: Game hiscores: flat files or database?

2012-10-01 Thread Dan Milon
Then you should read again about Mongo.

danmilon.

On Mon, Oct 1, 2012 at 3:56 PM, Felix E. Klee  wrote:

> On Mon, Oct 1, 2012 at 1:50 PM, Pedro Teixeira
>  wrote:
> > http://redis.io/topics/persistence
>
> Too complicated and/or not reliable enough.
>
> At *any* point in time, I want to have the database mirrored to disk, in
> its entirety. Mongo seems perfect. I wonder why people recommend Redis.
>
> --
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Validating input in express handlers

2012-09-25 Thread Dan Milon
Hello Jonny,

It is a public API, nothing to do with forms or rendering pages.
Do you have any other suggestion?

Thanks,
danmilon.

On 09/25/2012 10:31 PM, Jonathan Buchanan wrote:
> On 25 September 2012 14:33, Dan Milon  <mailto:danmi...@gmail.com>> wrote:
> 
> Hello,
> 
> I question myself how I should validate input all the time, but
> still i haven't found the right way.
> 
> Using an orm's validation tools feels wrong. Eg mongoose. It ties
> validation with the underlying database.
> 
> node-validator is quite limiting. The way it throws errors is hard
> to deal with lots of validations.
> 
> How do you guys validate your input and deliver meaningful responses?
> 
> 
> Thanks,
> danmilon.
> 
> 
> Are forms [1] or newforms [2] the sort of thing you're looking for? If
> you're willing to live with their default markup options, you get form
> rendering, redisplay and validation error message display for free.
> 
> Newforms is my own port of django.forms to JavaScript. It does most of
> what django.forms does, but is still in the process of being dogfooded
> and doesn't yet support any sort of validation which needs async I/O,
> such as file uploads or pinging URLs.
> 
> It seems to work decently with Jade thanks to its lovely mixins, though
> - these are the ones I'm using for layout and error display in a current
> Bootstrap project [3]
> 
> Jonny.
> 
> [1] https://github.com/caolan/forms
> [2] https://github.com/insin/newforms
> [3] https://github.com/insin/successcrm/blob/master/views/mixins/forms.jade
> 
> -- 
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Validating input in express handlers

2012-09-25 Thread Dan Milon
Hello, 

I question myself how I should validate input all the time, but still i haven't 
found the right way. 

Using an orm's validation tools feels wrong. Eg mongoose. It ties validation 
with the underlying database. 

node-validator is quite limiting. The way it throws errors is hard to deal with 
lots of validations. 

How do you guys validate your input and deliver meaningful responses?


Thanks,
danmilon. 

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] repl with async ops

2012-09-19 Thread Dan Milon
Hello,

I am trying to create a repl, that will mostly call async ops.
How can i pause it until the async operation is over?

Something like the mongo repl.

Thanks,
danmilon.

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] How the browser should communicate with our API

2012-09-17 Thread Dan Milon
Hello Community,

Sorry for going off topic, but I'm sure there are people here who could
help me. Although most of the stuff described below are build in node,
my question is more of an architectural one.

I'm developing a public HTTP backend API for a service. On top of that,
there is a web app that has users log in, and should use the backend API
to fulfill user requests. The API supports OAuth2, and the web app is a
single page app, with loads of javascript.

My concern is how the browser and the web app should talk with the API.
I found two possible ways.

## Browser directly uses the API

When the user enters his credentials to log in, the web app passes them
to the API and is given an OAuth access_token, which is directly passed
to the browser and stored in some cookie. Then every request to the API
is made directly from the browser through JSONP. When the user logs out,
the web app destroys the session.

## Browser talks to web app, which talks to the API

When the user enters his credentials to log in, the web app passes them
to the API and is given an OAuth access_token. A session is created with
the User and the access_token is stored in the session. When the browser
needs to talk to the API, it goes through the web app. The web app uses
the access token in the session, calls the API, and delivers the
response to the browser.

Both ways have pros and cons with performance and security trade offs.
What do you think?

Thanks a lot,
danmilon.

PS: from what I've seen, twitter uses it's public API directly from the
browser, but passes session cookies for authentication. That means their
API also supports cookie sessions?

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Parsing multipart/mixed

2012-09-04 Thread Dan Milon

Hello,

I am issuing HTTP requests to a third party API, through node, and the 
response has content-type multipart/mixed.


Do you know if there is a parser module for this, or how i could use the 
multipart parser of node-formidable to achieve this?


Thanks,
danmilon.

--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] [Ann] UglifyJS 2.0

2012-08-30 Thread Dan Milon

Out of topic, but you gave me the clues.
Do you know where i can read up about AST trees for javascript?

Thanks a ton,
danmilon.

On 08/30/2012 12:27 AM, Marcel Laverdet wrote:
Just curious why you need the comments in the AST at all? If you've 
got the start position & length of every token in the AST (much easier 
to do) you implicitly have the comments as well. The "fiber" engine in 
Streamline 
(https://github.com/Sage/streamlinejs/blob/master/lib/fibers/transform.js) 
does this with really good results.


On Wed, Aug 29, 2012 at 8:37 AM, Mihai Călin Bazon 
mailto:mihai.ba...@gmail.com>> wrote:


Well, the code generator doesn't yet have an option to keep comments,
but I can add it easily; the harder part was having them in the AST,
and that's done.

What exactly are you trying to achieve?  My understanding is that you
compile Lisp to JS (cool!), do you want to be able to do the reverse
transform?  If so, perhaps a better idea is to generate a source map.
(not sure what you need to do though, just guessing)

Cheers,
-Mihai

On Wed, Aug 29, 2012 at 1:52 PM, Scott Taylor
mailto:sc...@railsnewbie.com>> wrote:
> Wonderful!  I've been working on a project that is sort of like
parenscript
> - but much more of a straight javascript in lisp/scheme clothes
with a
> define-syntax macro system.
>
> https://github.com/smtlaissezfaire/loop
>
> I've been hacking on the 1x source of uglify to translate
javascript into a
> lispy type system (and back) - but inline comments have been a
cause of
> concern.  Where is the 2.x source at this point?
>
> Cheers,
>
> Scott
>
> On Aug 28, 2012, at 12:56 PM, Mihai Călin Bazon wrote:
>
> On Tue, Aug 28, 2012 at 5:33 AM, Scott Taylor
mailto:sc...@railsnewbie.com>> wrote:
>
> Very cool.  What comments in the AST are you going to preserve?
>
>
> The new AST is able to store all comments, and the compressor
and code
> generator will be able to keep most of them.  However, I suspect
that
> in general people will only need to store copyright notices, and
those
> usually start with some special marker like "/*!".  It'll be easy to
> add a configuration option to keep such comments, as long as they're
> not in code that's going to be dropped (for example dead code, like,
> code that follows a return, throw, break or continue statement).
>
> Cheers,
> --
> Mihai Bazon,
> http://mihai.bazon.net/blog
>
> --
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com

> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com

> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
>
> --
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com

> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com

> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en



--
Mihai Bazon,
http://mihai.bazon.net/blog

--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com

To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com

For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


--
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Gu

Re: [nodejs] Nodejs Restify and Express

2012-08-30 Thread Dan Milon

File does not matter. Port matters.

On 08/30/2012 10:33 AM, almarjin wrote:

Hi Dan,

Thanks for the reply.

This means if I will use them both required in the same file will not 
work right? only when they are in separate file and using different port.



On Monday, August 27, 2012 9:09:45 PM UTC+8, Dan Milon wrote:

You mean both on the same process? Yeah as long as its a different
port.

If you are asking which one to choose, for an (rest) API server,
its not
an easy answer.
I first tried restify, but it didnt compute etags out of the box
which i
found strange for a rest API server. Plus i did not make use of
all the
extra headers it enforces.

I did not make a performance comparison, but found express to work
better out of the box for my needs. But you will have to write
your own
error catcher middleware.

danmilon.

On 08/27/2012 03:53 PM, almarjin wrote:
> Hi,
>
> I'd like to know if Restify and Express will both work on Nodejs.
>
> Thanks,
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
>
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines 
<https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines>

> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com

> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com 
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
<http://groups.google.com/group/nodejs?hl=en?hl=en>

--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Nodejs Restify and Express

2012-08-27 Thread Dan Milon

You mean both on the same process? Yeah as long as its a different port.

If you are asking which one to choose, for an (rest) API server, its not 
an easy answer.
I first tried restify, but it didnt compute etags out of the box which i 
found strange for a rest API server. Plus i did not make use of all the 
extra headers it enforces.


I did not make a performance comparison, but found express to work 
better out of the box for my needs. But you will have to write your own 
error catcher middleware.


danmilon.

On 08/27/2012 03:53 PM, almarjin wrote:

Hi,

I'd like to know if Restify and Express will both work on Nodejs.

Thanks,
--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Windows - USB Install - Modules

2012-08-24 Thread Dan Milon
Since this is an application, and you are going to ship it to customers, 
why not have node_modules pre installed on the usb drive?


On 08/24/2012 05:20 PM, MikeB_2012 wrote:
I am trying to create a small app nodejs-based app that runs on a USB 
drive (that will be inserted in to various Windows OS machines).   I 
have successfully installed nodejs and couchdb on the drive and have 
tested some basic database scripts. I am now trying to make more 
advanced scripts and so I have tried to make use of the various 
modules available for node.


The installation of modules seems to work seamlessly; npm install 
hasn't failed at all.  My problem is, some modules seem to work and 
others throw an error eg. 'Error: Cannot find module 'express''.  So, 
'npm' and 'cradle' work but 'coffee-script' and 'express' throw an 
error despite error free installations.  Note that none of the 
installations is global (-g) because that seems to default to an 
installation on a hard drive directory.  Also, my initial scripts were 
in a subdirectory of the node directory, whereas the more advanced 
scripts are not.  If the latter makes a difference, why?  Do I have 
to, and is there a way to, make nodejs and its modules 'global' on the 
USB drive?


TIA for any advice/guidance.
--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] shrouding the javascript source via encryption

2012-08-23 Thread Dan Milon
As you probably understand, there will always be a step between 
decrypting and parsing that your code will be plaintext. At the end of 
the day, it is your code but running on some other dudes computer who 
has full control over it.


So as it concerns javascript and particularly v8, you will never get 
your code invisible. v8 is using the source again and again in order to 
generate better intermediate code, make use of its cache etc.


My opinion is you should invest time into making this application 
better, or finding other ways to monetize.


danmilon.

On 08/23/2012 05:11 AM, Marty Leisner wrote:

I'm new to nodejs (and javascript).

I want to be able to shroud the javascript source running into node.

I figured if the javascript is read in as a memory image before its 
parsed/interpreted, I could

decrypt it in between reading and parsing (is it parsed as its read?)

The decryption algorithm is within the binary (along with the keys).   
The binary is distributed with

the application, so this approach could work.

I've looked at node running in gdb and I can't see where this is 
cleanly defined.  Help/advice would be

appreciated.

Marty --
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Why `fs.exists` has signature `(exists)` instead of `(err, exists)` ?

2012-08-22 Thread Dan Milon

Isaac, i am curious why you believe fs.exists should stay as is.
I found your previous mail kind of "autarchic". Some 
communication/reasoning will surely make each side understand better the 
pros/cons.


danmilon.

On 08/23/2012 12:32 AM, Isaac Schlueter wrote:

Yeah, Jimb, I'm not sure I know what you mean by "undocumented error
code values".  Node does assume some familiarity with Posix error code
values, but that's a very long and well-documented tradition.

Actually, your gist is a perfect example of why fs.exists is a)
unnecessary, and b) almost always the wrong idea.  In the first case,
if the file exists, but is not readable, then the fs.exists() will
return false, and your program will act as if the file is *missing*,
which is incorrect.


On Wed, Aug 22, 2012 at 2:10 PM, Nathan Rajlich  wrote:

Checking "err.code" for "ENOENT" is the most cross-platform and
backwards compatible way to check for the existence of the file.

On Wed, Aug 22, 2012 at 1:29 PM, Jimb Esser  wrote:

Yeah, there are a lot of cases where "does not exists" as an "error" needs
to be treated differently.  I tried making a "read from this file, return a
default value if it does not exist" function without using fs.exists, and
was unable to do so efficiently without relying on undocumented error code
values [1].  It's very unclear if that code will work on different versions
of node let alone different operating systems.  It's vitally important in
cases like "rename this file to a backup before overwriting" that an "error"
in the process is treated differently than "file does not exists", so
fs.exists does serve a purpose, even if its signature could have been
designed in a more conformant manner.

[1] https://gist.github.com/3429037

--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] How would you solve this: how many minutes connected

2012-08-20 Thread Dan Milon
What about socket.io .on('connect'), .on('disconnect').
You can get the time range user is logged, and then sum up these in db.

On Tue, Aug 21, 2012 at 3:09 AM, Filipe  wrote:

> Hi everyone!
>
> I have this scenario: Express, Socket.io and MongoDB.
>
> The problem: reward points to the user on how many seconds (or time in
> general) he keeps logged in (with the Socket opened).
>
> This is for a chat site I'm building and I want to build a ranking
> based on how many minutes users stay connected. I've already built all
> the register/login/messages but now I'm in a dead end with this
> problem.
>
> How would you solve this?
>
> --
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Why `fs.exists` has signature `(exists)` instead of `(err, exists)` ?

2012-08-20 Thread Dan Milon
Thats what PHP thought about deprecation also. See where this got them.

On Mon, Aug 20, 2012 at 6:59 PM, Arnout Kazemier  wrote:

> I really dont get why people want to depricate functions just because they
> dont agree with the api signature.
>
> This is a useful function, it doesnt hurt anyone if we keep it, but it
> does hurt when its removed.
>
> On 20 aug. 2012, at 17:53, Tim Caswell  wrote:
>
> > How about removing it from the docs and making it non-enumerable in
> > the fs module.  Then any new developers won't know it's there unless
> > they are reading someone else's code.  Or maybe in the docs simply say
> > that it shouldn't be used and is only left there so as to not break
> > old code.  Also, how is this different from deprecation?
> >
> > On Sun, Aug 19, 2012 at 4:02 PM, Bert Belder 
> wrote:
> >> On Sunday, August 19, 2012 8:23:53 PM UTC+2, Nuno Job wrote:
> >>>
> > Maybe a note in the docs tell people that fs.stat is a better choice?
> >>>
> >>> Good idea Mikeal. Deprecation console.error && pointing people to
> >>> fs.stat in the docs should do the trick.
> >>
> >>
> >> I don't see enough compelling reasons to deprecate it. I think a doc
> >> addition that warns people about the funky signature and the
> anti-pattern
> >> would suffice.
> >>
> >> - Bert
> >>
> >>
> >> --
> >> 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 Google
> >> Groups "nodejs" group.
> >> To post to this group, send email to nodejs@googlegroups.com
> >> To unsubscribe from this group, send email to
> >> nodejs+unsubscr...@googlegroups.com
> >> For more options, visit this group at
> >> http://groups.google.com/group/nodejs?hl=en?hl=en
> >
> > --
> > 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 Google
> > Groups "nodejs" group.
> > To post to this group, send email to nodejs@googlegroups.com
> > To unsubscribe from this group, send email to
> > nodejs+unsubscr...@googlegroups.com
> > For more options, visit this group at
> > http://groups.google.com/group/nodejs?hl=en?hl=en
>
> --
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: Can't install socket.io or run now.js on windows 7 x64

2012-08-16 Thread Dan Milon
node-redis can either use a javascript parser, or the one from hiredis. The
latter is a little faster, but if it does not compile under windows, ignore
the dependency and go for the native parser. (which is the default).

danmilon.

On Thu, Aug 16, 2012 at 4:54 PM, Bert Belder  wrote:

> On Thursday, August 16, 2012 3:44:50 PM UTC+2, Bert Belder wrote:
>
>> Apparently node-redis (a dependency of socket.io) has come to depend on
>> hiredis, but hiredis doesn't compile on windows. You might want to complain
>> to the node-redis or the hiredis maintainer.
>> You can also install a slightly older version of socket.io; try `npm
>> install socket.io@0.9.6`
>>
>
> Never mind this - node-redis has "hiredis" as an optional dependency, but
> if compiling fails it will just work anyway.
>
> Isaac, NPM should be more clear about this. "Installing {packagename}
> failed, but don't worry about it" would be a good one :-)
>
>
>  --
> 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 Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] a pakage that exports few modules

2012-08-13 Thread Dan Milon
I believe there is no performance drop if you require a huge library and 
only use a small part of it. I mean, code memory is a small part of the 
total memory you use.


danmilon.

On 08/13/2012 01:02 PM, Osher E wrote:

Hi all

most modules have an entry point, which is by default index.js.

But what if my module does not have one entry point?
What if it is a colleciton of many small cross-project core utility 
modules that i would not always want to load them all to use one of them?

I mean, by doing

var core = require('core').logger
we require  whatever is exported on the entry-point of core, and use 
only logger.
and there could be twenty of them, where in this project I just need 
the logger here.


Please avoid the discussion of wither to wrap each utility as it's own 
package...
Just assume that they do not justify that, but do need a package to 
live in...


I saw somewhere that I should be able to
var core = require('core/logger')
and should be able to direct in my package.json that 'core/logger' is 
actually available at ./lib/logger

only that now i cant find that place that sais how to do it...

Was I dreaming? Can anybody point it out for me? :)

Thanks

O.
--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Domain for every worker?

2012-08-10 Thread Dan Milon

Almost correct.

But you have to add the 'error' listener before the .run call.
.run will immediately call the provided function, so if an error happens 
immediately, you wont catch it.


source:
Domain.prototype.run = function(fn) {
  return this.bind(fn)();
};

bind here refers to the documented domain#bind method.

Good luck.
danmilon.

On 08/10/2012 05:16 PM, Honigbaum wrote:

Ah, you're right.

You mean like this https://gist.github.com/3313918

Am Freitag, 10. August 2012 15:40:04 UTC+2 schrieb Dan Milon:

That is wrong.

The domain creation should be at the code of the slave.
the slaves are the actual servers that share the port. Thats where
the
errors occur.
master is a mere coordinator.

Slave code is at the else part of cluster.isMaster.

Also you create the server without regard of weather the process is
master / slave. Functionally its the same (since you only listen
for the
slave) but i consider it bad practice.

So the server creation code should go at the else part also.

danmilon.

On 08/10/2012 03:38 PM, Honigbaum wrote:
> Hello,
>
> I tried it like this https://gist.github.com/3313918
<https://gist.github.com/3313918>
>
> Or is it a problem that I assign ever domain to the same var?
>
>
> Torben
>
> Am Freitag, 10. August 2012 14:32:03 UTC+2 schrieb Dan Milon:
>
> How did you implement this exactly? (gist?)
> You should be able to create a domain inside the slave code
that will
> fire whenever this specific slave throws.
>
> danmilon.
>
> On 08/10/2012 03:01 PM, Honigbaum wrote:
> > Hello,
> >
> > my node.js application uses the cluster module for forking
> workers and
> > I want to use the new domain module to catch all uncaught
> exceptions.
> >
> > Is there a way to fork each worker in an own domain? I
tried to
> wrap
> > the whole application in an domain, but then the error
handler is
> > called for each worker.
> >
> >
> > Thank you
> > Torben
> > --
> > Job Board: http://jobs.nodejs.org/
> > Posting guidelines:
> >
>
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines 
<https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines>
<https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
<https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines>>

>
> > You received this message because you are subscribed to
the Google
> > Groups "nodejs" group.
> > To post to this group, send email to nod...@googlegroups.com
> 
> > To unsubscribe from this group, send email to
> > nodejs+un...@googlegroups.com 
> > For more options, visit this group at
> > http://groups.google.com/group/nodejs?hl=en?hl=en
<http://groups.google.com/group/nodejs?hl=en?hl=en>
> <http://groups.google.com/group/nodejs?hl=en?hl=en
<http://groups.google.com/group/nodejs?hl=en?hl=en>>
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
>
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines 
<https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines>

> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com

> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com 
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
<http://groups.google.com/group/nodejs?hl=en?hl=en>

--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Domain for every worker?

2012-08-10 Thread Dan Milon

That is wrong.

The domain creation should be at the code of the slave.
the slaves are the actual servers that share the port. Thats where the 
errors occur.

master is a mere coordinator.

Slave code is at the else part of cluster.isMaster.

Also you create the server without regard of weather the process is 
master / slave. Functionally its the same (since you only listen for the 
slave) but i consider it bad practice.


So the server creation code should go at the else part also.

danmilon.

On 08/10/2012 03:38 PM, Honigbaum wrote:

Hello,

I tried it like this https://gist.github.com/3313918

Or is it a problem that I assign ever domain to the same var?


Torben

Am Freitag, 10. August 2012 14:32:03 UTC+2 schrieb Dan Milon:

How did you implement this exactly? (gist?)
You should be able to create a domain inside the slave code that will
fire whenever this specific slave throws.

danmilon.

On 08/10/2012 03:01 PM, Honigbaum wrote:
> Hello,
>
> my node.js application uses the cluster module for forking
workers and
> I want to use the new domain module to catch all uncaught
exceptions.
>
> Is there a way to fork each worker in an own domain? I tried to
wrap
> the whole application in an domain, but then the error handler is
> called for each worker.
>
>
> Thank you
> Torben
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
>
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines 
<https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines>

> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com

> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com 
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
<http://groups.google.com/group/nodejs?hl=en?hl=en>

--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Domain for every worker?

2012-08-10 Thread Dan Milon

How did you implement this exactly? (gist?)
You should be able to create a domain inside the slave code that will 
fire whenever this specific slave throws.


danmilon.

On 08/10/2012 03:01 PM, Honigbaum wrote:

Hello,

my node.js application uses the cluster module for forking workers and 
I want to use the new domain module to catch all uncaught exceptions.


Is there a way to fork each worker in an own domain? I tried to wrap 
the whole application in an domain, but then the error handler is 
called for each worker.



Thank you
Torben
--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: [ANN] New release of node-webkit - run node.js apps on desktop

2012-08-10 Thread Dan Milon
since the latest version of appjs there is a shared context between 
node/webkit so you can use node calls inside the "client side" code. 
Example here https://gist.github.com/3312818


danmilon.

On 08/10/2012 03:57 AM, Zhao Cheng wrote:

On Thu, Aug 9, 2012 at 11:16 PM, Tim Caswell  wrote:

I don't know it this was mentioned before, but could you summarize how
this project differs in goals and maturity to other similar projects
like appjs?

I'm not trying to discourage you, this work is fantastic!  I just know
that it's not obvious to everyone what the differences are.

You're right, a compare table is necessary, I'll add one in the Wiki page.

In summary, node-webkit is different to appjs in following ways:
1. appjs is a module for node but node-webkit is a standalone runtime.
2. it's hard to distribute app written with appjs, but node-webkit has
a working out of box package system.
3. the webview created by appjs is just a normal webview, it's very
hard to use along with nodejs. But webview created by node-webkit has
integrated nodejs into it, that means you can directly use 'require',
'process' and others in the 

Re: [nodejs] How do you handle if/else with async inside

2012-08-08 Thread Dan Milon

Thats your post that i was referring to ;) I liked the CPS style.

Do you know if harmony is bringing any goodness for these situations?

On 08/08/2012 08:18 PM, José F. Romaniello wrote:

I wrote a blogpost about this specific topic:

http://joseoncode.com/2012/06/24/messing-with-cps-in-js/

for me there are two ideal situations:

  * a language with an specific syntax for asynchronous flows like
streamlinejs, icedcoffeescript, f#
  * or make a Continuation Passing Style version of the  javascript
constructs (if, for, while, try/catch) (similar to lisp family
languages)

there are also a lot of async libraries I know.

2012/8/7 Dan Milon mailto:danmi...@gmail.com>>

I am wondering which are the different patterns to handle cases like


var results
if (cond) {
  async1(function (err, res) {
results = res
  })
}
else {
  async2(function (err, res) {
results = res
  })
}
// here need to do something with results.

The problem is obvious, but i cannot see any good way to overcome it.

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
<mailto:nodejs@googlegroups.com>
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
<mailto:nodejs%2bunsubscr...@googlegroups.com>
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: How do you handle if/else with async inside

2012-08-08 Thread Dan Milon

Indeed, you cannot get anything less than +1 indentation.

Thanks for your input!
danmilon.

On 08/08/2012 04:54 PM, Tim Caswell wrote:

On Wed, Aug 8, 2012 at 4:13 AM, Dan Milon  wrote:

That will work, indeed, but it annoys me that indentation and code
readability gets fucked up. You have to follow code traces in order to
understand the ordering of execution.

Dan, you're not going to get any less indentation than my simple
example.  There has to be at least one level of indentation after your
callback no matter what unless you extend the language.

If it makes you feel better you can indent your conditional in one
level as well so that they are both one level deep.

What I was showing is that function statements hoist their value, so
you can call them before the line that defines them is executed.  This
means your program can execute in a top-down linear fashion without
ever nesting any more than one level deep for callbacks.

As far as what the async library provides, I have no idea, I've never
used it.  It will require at least one function block with a level
of indentation though.

I find using named functions and other clever uses of the language
itself provides just as clear code most the time and with a lot less
abstraction.


I already use async for other cases. Do you find any of its control flow
functions helpful for the if/else problem?

Thanks,
danmilon.



On 08/08/2012 05:56 AM, Tim Caswell wrote:

If there really are only two functions that have the same callback
signature, then it's super easy taking advantage of named function
value hoisting.

  if (cond) async1(onDone);
  else async2(onDone);

  function onDone(err, result) {
// the function finished
  }

But I suspect the question involves more complicated cases in practice.

On Tue, Aug 7, 2012 at 9:44 PM, Andy  wrote:

I would personally go with using promises.

var q = require('q');
q.ncall(function() {
 if(cond) {
 return async1(); // this is a promise
 }
 return async2(); // so is this
}).then(function(res) {
 // hooray! one of them finished
}).error(function(res) {
  // something went wrong!
});

--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: How do you handle if/else with async inside

2012-08-08 Thread Dan Milon
That will work, indeed, but it annoys me that indentation and code 
readability gets fucked up. You have to follow code traces in order to 
understand the ordering of execution.


I already use async for other cases. Do you find any of its control flow 
functions helpful for the if/else problem?


Thanks,
danmilon.


On 08/08/2012 05:56 AM, Tim Caswell wrote:

If there really are only two functions that have the same callback
signature, then it's super easy taking advantage of named function
value hoisting.

 if (cond) async1(onDone);
 else async2(onDone);

 function onDone(err, result) {
   // the function finished
 }

But I suspect the question involves more complicated cases in practice.

On Tue, Aug 7, 2012 at 9:44 PM, Andy  wrote:

I would personally go with using promises.

var q = require('q');
q.ncall(function() {
if(cond) {
return async1(); // this is a promise
}
return async2(); // so is this
}).then(function(res) {
// hooray! one of them finished
}).error(function(res) {
 // something went wrong!
});

--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: loading static files named 'server.js'

2012-08-08 Thread Dan Milon

Why use IIS with node?
You sacrifice everything, for what?

On 08/08/2012 11:38 AM, yishayw wrote:
I figure it out, the solution was in my IIS configuration. I changed 
web.config so that all occurrences of 'server.js' were replaced with 
'nodejs_server.js'. I then renamed all my node.js server files to 
nodejs_server.js. Now my statically served library namespace doesn't 
conflict with the node.js namespace.


On Tuesday, August 7, 2012 10:39:28 PM UTC+3, yishayw wrote:

Hi,

I have a site which uses a library with a static file named
server.js. Node.js seems to be treating this as a file which needs
to be interpreted on the server side rather than a static file.
Hence, I get an error: 'Uncaught SyntaxError: Unexpected token <'

Is there any way around this?

I created a small example of the problem with code snippets below.

Thanks in advance,
Yishay

Here's my server code:



/**
  * Module dependencies.
  */
  
var  express=  require('express')

   ,  routes=  require('./routes');
  
var  app=  module.exports  =  express.createServer();
  
// Configuration
  
app.configure(function(){

   app.set('views',  __dirname+  '/views');
   app.set('view engine',  'jade');
   app.use(express.bodyParser());
   app.use(express.methodOverride());
   app.use(app.router);
   app.use(express.static(__dirname+  '/public'));
});
  
app.configure('development',  function(){

   app.use(express.errorHandler({  dumpExceptions:  true,  showStack:  true 
 }));
});
  
app.configure('production',  function(){

   app.use(express.errorHandler());
});
  
// Routes
  
app.get('/',  routes.index);
  
app.listen(process.env.port||  3000);

console.log("Express server listening on port %d in %s mode",  
app.address().port,  app.settings.env);




My index.html (under public/index.html)

==


  


 
 
 
 
 
 
 hello
 



===


And Server.js which is under the same dir


===


alert('serving');


===



--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: mongodb client

2012-08-08 Thread Dan Milon
Well, mongo-node-native is the de facto implementation of the protocol, 
but there are lots of wrappers arround it (without schemas or ORM) that 
just make the API easier to handle.


On 08/07/2012 10:15 PM, john.tiger wrote:

On 08/07/2012 01:48 AM, Martin Wawrusch wrote:
We use mongoose and mongoskin for testing. It really depends on your 
scenario. In general though mongoose is a good choice.


it is if you want to specify schema or use ORM - otherwise 
mongo-node-native is the defacto node mongo driver and works pretty 
well - it requires you to write a lot of callbacks, but that's life in 
the async world.






On Tue, Aug 7, 2012 at 12:44 AM, Angelo Chen > wrote:



looking at mongojs and mongode, too many options for mongdb.

On Aug 7, 2:42 pm, Luca Morettoni mailto:l...@morettoni.net>> wrote:
> On Tue, Aug 7, 2012 at 8:30 AM, Angelo Chen
mailto:angelochen...@gmail.com>> wrote:
> > Hi,
>
> > looking for for  a mongdb client, any suggestions? not so
particular
> > about ORM. thanks,
>
>

https://github.com/christkv/node-mongodb-nativehttp://mongodb.github.com/node-mongodb-native/api-articles/nodekoarti...
>
> --
> Luca Morettoni http://morettoni.net>>
|http://www.morettoni.net
> gtalk/msn: luca(AT)morettoni.net 
|http://twitter.com/morettoni
> Google+ profile:http://bit.ly/morettoni_plus
> Member of Python User Group Perugia:http://www.pypg.org/

--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com

To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com

For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en






--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] How do you handle if/else with async inside

2012-08-07 Thread Dan Milon
True, that works on this simplified case, but there is more logic, 
depending on the cond, etc.


I recall reading a blog post about having async if.
like
if (cond, trueFn, falseFn, doneFn)

That was interesting.

On 08/07/2012 07:47 PM, Mark Volkmann wrote:
On Tue, Aug 7, 2012 at 11:35 AM, Dan Milon <mailto:danmi...@gmail.com>> wrote:


I am wondering which are the different patterns to handle cases like

var results
if (cond) {
  async1(function (err, res) {
results = res
  })
}
else {
  async2(function (err, res) {
results = res
  })
}
// here need to do something with results.

The problem is obvious, but i cannot see any good way to overcome it.


How about this?

var results;
var fn = cond ? async1 : async2;
fn(function (err, res) {
  results = res;
  // Do something with results here.
});
--
R. Mark Volkmann
Object Computing, Inc.
--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] How do you handle if/else with async inside

2012-08-07 Thread Dan Milon

I am wondering which are the different patterns to handle cases like


var results
if (cond) {
  async1(function (err, res) {
results = res
  })
}
else {
  async2(function (err, res) {
results = res
  })
}
// here need to do something with results.

The problem is obvious, but i cannot see any good way to overcome it.

--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] [ANN]: node-nat-pmp: A Node.js implementation of the NAT Port Mapping Protocol

2012-08-05 Thread Dan Milon

Unfortunately my router does not support it, but the module seems very neat.

Although, security-wise it doesn't seem very nice allowing any app to 
open any ports. There should be some approval.


On 08/06/2012 01:39 AM, Nathan Rajlich wrote:
If you've wanted to forward your ports programmatically before, and 
have a NAT-PMP compatible route (basically an Apple router), then this 
module is for you. You can get what the router believes is the 
external IP address, as well as open and close UDP and TCP ports to 
the computer sending the commands.


I recently ran into the need to forward a port on my home router 
without having access to the Airport Utility running at my home. This 
was the solution, to run a quick node script to open the SSH port for 
an hour while I did my thing. And no router configuration or rebooting 
was required, so it served my need perfectly. Hopefully you may enjoy 
it as well. Cheers!


npm: https://npmjs.org/package/nat-pmp
GitHub: https://github.com/TooTallNate/node-nat-pmp
--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] string encoding

2012-08-02 Thread Dan Milon

for me, text is "exit\n"
I guess you are on windows, so text is "exit\r\n"

The readline module might help you.

On 08/02/2012 04:15 PM, Danil Gazizov wrote:

I'm confused of how to compare string const with variable.
Look at this simple example where keyboard input compares with const 
string.
I suggest this is encoding problem. Please, tell me what should be 
done to exit process ?

File encoding is utf8

process.stdin.setEncoding();//default is utf-8
process.stdin.resume();
process.stdin.on("data", function(text) {

//shows entered length=*6*
console.log('entered length=' + text.length);

//shows compare length=*4*
console.log('compare length=' + 'exit'.length);

if (text == 'exit'){
 //never works
console.log('matched!');
}
});

--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] node-mongodb-native problems with sort

2012-07-14 Thread Dan Milon
Actually first parameter is query, second is fields to fetch (optional, 
and 3rd is options.

For sorting you can either do:

coll.find({ username: username }, { sort: { date: -1 } })
or
coll.find({ username: username }).sort({ date: -1 })
and variants with arrays, but havent tested any of this.

Dan Milon.

On 07/13/2012 11:20 PM, Jeremy Darling wrote:

try:

col.find({username:username}, {}, {sort: {date: -1}}, function(err, 
records){

  console.log(records);
});

1st param is the query, 2nd param is options object, sort is an object 
under the options object as entered in the Mongo CLI.  In your 
examples your using arrays instead of objects.


 - Jeremy

On Fri, Jul 13, 2012 at 3:03 PM, john.tiger 
mailto:john.tigernas...@gmail.com>> wrote:


have tried various syntax but nothing seems to be working - and
which is right docs vs examples vs tests (I would think tests -
some show "desc" some show "-1"

here's an example:

coll.find({"username":username}, {"sort":['date','desc']},
function(err,cursor) {

also tried as per test:
coll.find({"username":username}, {"sort":[['date', -1]]},
function(err,cursor) {

thks for any help on this

-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
<mailto:nodejs@googlegroups.com>
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
<mailto:nodejs%2bunsubscr...@googlegroups.com>
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en



--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] how to display the value of a variable in the deugger?

2012-07-12 Thread Dan Milon

http://nodejs.org/api/debugger.html

> repl
> i


On 07/12/2012 10:47 AM, josh wrote:

// test.js
var i=0;
debugger;



// node debug test.js
// n(next)
// backtrace=> #0 test.js:2:1
// i   => i not defined


how to display the value of i?
--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en



--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] CGI example needed

2012-07-08 Thread Dan Milon

Yeah, You should read up nodejs.org & tutorials / blogs to learn more ;)

danmilon.

On 07/09/2012 12:54 AM, Tim Johnson wrote:

* Dan Milon  [120708 10:27]:

You wouldn't use node as a cgi script (at least for the web part).
Technically you can, but you would lose all the benefits
(async/nonblocking io) since you let apache or any http server for the
matter enforce the concurrency model. Afaik, the cgi server will pull up
node processes for each request, which is overkill (startup times) or
pool them but things will get complex.

As it concerns network/http related scripts, its a big no no, unless you
cant replace the http server in your stack, and really need to use node
(which is a silly case)
If you have to use cgi, i suggest you keep using php/python.

   :) python is not PHP ... and my question was pretty much
   rhetorical. I don't know much about the origin of node, I ended up
   with it in the process of getting csslint installed - so it is all
   new to me.

Why dont you use node as the server also? (not only processing requests)

   Ah! So node was developed to as a 'serving' tool as opposed to a
   'scripting' tool?

   thanks for the reply




--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] CGI example needed

2012-07-08 Thread Dan Milon

You wouldn't use node as a cgi script (at least for the web part).
Technically you can, but you would lose all the benefits 
(async/nonblocking io) since you let apache or any http server for the 
matter enforce the concurrency model. Afaik, the cgi server will pull up 
node processes for each request, which is overkill (startup times) or 
pool them but things will get complex.


As it concerns network/http related scripts, its a big no no, unless you 
cant replace the http server in your stack, and really need to use node 
(which is a silly case)

If you have to use cgi, i suggest you keep using php/python.

Why dont you use node as the server also? (not only processing requests)

On 07/08/2012 08:01 PM, Tim Johnson wrote:

I've been a CGI programmer for 16 years. I have used python for the
last 9. I currently use javascript for client-side programming. I am
interested in using node.js for server-side programming.

I've done a little googling on CGI interfaces for node, but I am
finding *too* much information.

I am including an untested pseudo-code based on python. With that as
a reference, I would welcome some javascript code which would work
similarly:
code follows
##
#!/usr/bin/python
import cgilib   ## my cgi module
import mvcLoader as load  ## handles importing controller modules
## script loader.py (the executable 'parent' module)
## is the post action for a form which
## accepts an email address and a password as input fields named
## "email" and "password".
## loader.py has a virtual document path that has as path part 0
## a key for the controller that will be `import'ed by the parent module.
## the post action might look like this:
## "http://localhost/cgi-bin/loader.py/auth";
if __name__=="__main__":
 ## instantiate the cgi object and in doing so,
 ## process the CGI environment
 cgi = cgilib.Cgi()
 ## print the mime-type header
 cgi.header('text')
 ## Retrieve the values POSTed for 'email' and 'password'
 user = cgi["email"]
 pwd = cgi["password"]
 ## Retrieve the key for the controller module which will then be imported
 ## by the load.controller() method
 controller_key = cgi[0]
 controller = load.controller(cgi[0])
 ## And the rest of the work happens below
 ## in the imported controller module
 controller.process(user,pwd)
##
The intent and mechanics of my mvcLoad module should not be relevant
to this dicussion. What is relevant is allegories to
cgi[keyname]
and
cgi[virtual_document_path_index]

I hope that the example makes my question clear. I don't expect
anyone to "roll their own" tutorial, but URLs to discussions
on similar node interfaces would be most helpful.

TIA



--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] stream.pause with tcp

2012-07-06 Thread Dan Milon

Hello,

I have a node tcp service that accepts json messages (custom protocol) 
and does some async operations with these data (db queries)


My problem is that the clients may send in messages too fast, that i 
cant consume them at that rate. Ideally, i should be able to ask the 
clients to lower their sending rate, but implementing this at the 
protocol should be a bit complicated, but also feels like reinventing 
the wheel.


I was thinking of using stream.pause on the connections, but i am not 
sure how this works internally. Does it just buffer the data in memory, 
or using some tcp protocol pause?


Thank you,
Dan Milon.

--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Parallel Async Calls and Parallel Errors

2012-07-05 Thread Dan Milon
I believe a streaming API would be more appropriate for such a task. 
Something like:


var deleter = new Deleter('~');

deleter.on('error', function (err) {
  console.error(err)
})

deleter.on('file', function (fileName) {
  console.log('deleted ' + fileName)
})

deleter.on('end', function () {
  console.log('done!');
})

On 07/05/2012 06:44 PM, Alan Gutierrez wrote:

Let's say that somewhere within your library, you delete the contents of a
directory in parallel. Let's say all the files in a  directory are read-only so
all your parallel requests return an error.

If you've exposed a Node.js style asynchronous function with an `(error, result,
result...)` callback, how do you report multiple errors to person who called
your library? Do you wrap the multiple errors in a single error, maybe having an
array of `causes`? Do you note that multiple errors may be returned?

Are the functions in the Node.js API that might return more than one error that
I could study? Do any of the event emitters in the Node.js API emit a series of
errors, or is it just one error prior to entering an error state?

--
Alan Gutierrez - http://twitter.com/bigeasy - http://github.com/bigeasy




--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: MMO game node balancing multi servers

2012-07-05 Thread Dan Milon
Your requirement to be able and spin up more servers of the same "game" 
requires a lot of sharing between each of these servers, because they 
need (eventually) to be in the same state. The only advantage of this 
over having a single server for each "game" is that you load balance 
incoming traffic and concurrent connections, but introduce 
connections/traffic between the servers. Then even more problems arise 
when a 3rd server comes in, and every action means notifying also the 
other two servers.


Even if you implement this, i dont think it will be sustainable, as you 
can imagine.
Maybe we have to redesign how we think about MMO servers. Just a quick 
idea: Only one server handles a specific area/city (literally) of the 
game. So you limit the shared state, and can still scale to many machines.


You also have to classify your data.
Eg in-game messaging system can be in some db that each server asks when 
player visits mailbox. (no need to IPC since it is not a "realtime" message.
But player location has to be the same on all servers every moment, so 
movement messages must be sent out straight away (no db).


Good luck with your project ;)

danmilon.

On 07/05/2012 11:21 AM, hd nguyen wrote:

It's right Charles.

And I also understand you and Dominic's idea, I just want to find a 
tool/module that supports replicating game state between different 
servers.


If such a tool exists, it's very helpful to us than starting from 
scratch :)


On Thu, Jul 5, 2012 at 3:07 PM, Charles Care > wrote:


I think you're asking about two things: load balancing and
replication of state between instance. These are separate problems.

Nginx and http proxy will help you with load balancing and the
configuration of sticky sessions etc. This allows you to
horizontally scale your front-end servers.

However, replication of state between your application servers,
that's more tricky. You need to think about what state needs
replicating, how often, and what happens if the system has a
temporary network split. As Dominic says above, a lot of these
problems become easier if you can architect your system to support
eventual consistency (i.e. not every server will always be exactly
the same, but that they will converge on the same state). Ideally
your nodes should be able to deal with events arriving out of order.

In order to share this state, you'll need to open a communication
channel between the two node.js processes (raw TCP might be
enough, personally I would use Zeromq, but that's an
implementation detail)

USER1 -> GAME1 <-> GAME2 <- USER2

Hope that helps,

Charles


On 5 July 2012 08:53, hd nguyen mailto:nguyenhd2...@gmail.com>> wrote:

I think it turns out too detail when discussing about
code/business processing here.


To imagine easier, please look at below diagram:

As you can see, we have 2 users access to the same game hosted
in 2 nodejs servers. Client communicates to server through web
socket protocol, example user1 joins game and stick with
server1, user2 joins and stick with server2, of course through
proxy server as load balancer. 2 users on the same scene of
game, assume user1 attacks user2, so user2 must see user1's
action and vice versa.

So nginx or node http proxy can help us on this situation
transparently with as less effort as possible? Or any
different solution to get over it?



-- 
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com

To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com

For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en




--
Nguyen Hai Duy
Mobile : 0914 72 1900
Yahoo: nguyenhd_lucky
--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en



--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email t

Re: [nodejs] devil's advocate: why would I choose nodejs over MVC + IIS?

2012-07-03 Thread Dan Milon
About performance, from my POV the differences are the concurrency 
models each platform uses.


From one side, IIS has a thread pool, one thread per connection and 
blocking IO.

At the other hand, node has one thread, and non blocking IO.

First approach problem is that memory consumption is increased linearly 
with each concurrent request because each thread has its own stack. (try 
spinning 10k threads)


Also the more the requests, the more the threads running, thus more time 
is spent on context switching between these threads instead of doing 
something valuable.


The obvious solution would be async & non blocking IO, but it is not so 
straight forward to implement it, and any solution wouldnt be cross 
platform, but we are lucky all this complexity is abstracted by 
libev/libuv. Javascript made a perfect fit for a higher level language 
due to language-level anonymous functions & closures which allow you to 
write non blocking code easier.


Of course there are very many problems introduced with async & 
javascript, eg callback nightmare and you should be aware you will face 
this sooner or later.


But it is not all about performance. For me, writing nodejs code feels 
exciting and very pleasant! The community involved is very active, eager 
to help you, and all of this construct a very balanced ecosystem.


Correct me if im wrong but I believe ASP.NET's community involves old 
guys that try out something only if it has the word "enterprise" on the 
description.


Whenever i argue with a friend about performance, threads, async, sync 
and stuff it always ends up with drama! Best thing you can do is tell 
him you feel nice coding node and have him try it out, think of a 
project to do together and have fun etc. Im sure next time he will ask 
you to write your next code in node ;)


Hope I've helped,
Dan Milon.


On 07/03/2012 08:56 PM, Justin Collum wrote:
Had a discussion with a friend about Nodejs the other day. We are both 
C# / MVC / ASP.NET devs, with about 10 years experience. He asked me 
why someone would choose Nodejs over IIS + MVC . My argument was 1) 
performance 2) non-blocking IO. Keep in mind that I don't know a lot 
about node, I've built one small site and that's it. So my argument in 
favor was pretty short.


His response: Well, if I need performance on IIS I can just bump up 
the number of threads in the thread pool. Fair point.


After looking into it a bit, it seems that the big difference between 
IIS + MVC and Node is that each thread can do more in the Node  world 
because of the non-blocking IO. This cuts down on context switching 
and makes for better overall performance. Add that to the "one 
language to rule them all: coffeescript" factor and it's a clear win 
to me.


Is that a fair summary of the performance advantages of  Nodejs over 
IIS + MVC? Is there more to it?


I'm aware that you can run Nodejs via IIS but my intuition tells me 
that won't be a good fit.

--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en



--
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 Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


  1   2   >