Re: [nodejs] meaning of the semver ~

2013-05-31 Thread Dominic Tarr
10 points for alex kocharin (assuming he didn't cheat)
for the purposes of this survey it's semver.sasisfies(semverRange, semverValue)

On Fri, May 31, 2013 at 8:05 AM, dhruvbird dhruvb...@gmail.com wrote:


 On Thursday, May 30, 2013 12:52:47 PM UTC-7, Dominic wrote:

 without looking in the documentation or trying it in the repl

 what do you expect to be the results of these tests on semver ranges?

 A. semver.satisfies('~1.2.3', '1.2.4')


 True, because 1.2.3 seems to be approximately 1.2.4


 B. semver.satisfies('~1.2', '1.3.0')


 False, since 1.3.0 is not approximately 1.2


 C. semver.satisfies('~1.2', '1.2.6')


 True.



 D. semver.satisfies('1.2', '1.3.0')


 True, since I assume that 1.3.0 is 1.2.x and more.



 E. semver.satisfies('1.2', '1.2.4')


 True again.




 please don't look at the documentation, the question is:

 what do you think it means?


 ~1.2.3 probably means a version around 1.2.3 with the rev. possibly
 different. I expect only revisions = 3 to match though.




 --
 --
 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] meaning of the semver ~

2013-05-30 Thread Dominic Tarr
without looking in the documentation or trying it in the repl

what do you expect to be the results of these tests on semver ranges?

A. semver.satisfies('~1.2.3', '1.2.4')

B. semver.satisfies('~1.2', '1.3.0')

C. semver.satisfies('~1.2', '1.2.6')

D. semver.satisfies('1.2', '1.3.0')

E. semver.satisfies('1.2', '1.2.4')

please don't look at the documentation, the question is:

what do you think it means?

-- 
-- 
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-04-01 Thread Dominic Tarr
@mikeal when I last checked a few weeks ago there where over 350 stream
modules in npm.




On Tue, Mar 26, 2013 at 9:38 PM, Isaac Schlueter i...@izs.me wrote:

  You're still doing it wrong. This is like complaining that you can't
 tell a stream is ended because you waited to attach an `end` event handler.

 But that's supported, now :)  If you don't consume the stream, it
 never emits 'end', even if it never has any data.  You still have to
 read() or on('data') or resume() it.

 You could argue that the 'readable' is only for state transitions, I
 suppose, and the correct approach is to try to read, and only wait for
 'readable' if there's nothing there.  But there's little harm in
 re-emitting the event, at least the first time, and it's an easy
 change to make.  (We already special-case 'data' and 'readable' for
 other reasons.)

 Part of the reason why this is an issue for you is that the HTTP
 implementation's interaction with the TCP layer is utter shit.  Look
 for changes there in 0.12.  In the meantime, we should make this work,
 if only because some other crappily-built stream is likely to be
 similarly broken in this surprising way ;)

 Taking the bug report to an issue is 100% the correct move, thanks.
 Let's continue the discussion of that specific point there.

 --
 --
 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 Editor do you use?

2013-01-07 Thread Dominic Tarr
I use hipster
https://github.com/dominictarr/hipster
it's written in js, and runs in the terminal.
basically, the same controls as notepad,
has very crude syntax highlighting.

... and bugs, but it's just good enough that it's my main editor.

On Mon, Jan 7, 2013 at 11:47 AM, Rodrigo Fonseca fonsecaa...@gmail.comwrote:

 Thanks Jeff,

  I will try that when i get home.

 --
 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] Streams2 for arbitrary objects?

2012-12-23 Thread Dominic Tarr
I suggest you checkout Raynos' stream modules, he is mostly used Streams2,
I think you will be able to find everything you are looking for

On Sun, Dec 23, 2012 at 7:20 AM, Arpad Borsos
arpad.bor...@googlemail.comwrote:

 Hi!

 I’m really excited to read about the new streams2 interfaces. They make a
 lot of sense when you are dealing with binary/string data. The automatic
 splice()-ing and join()-ing is awesome.
 But they kind of fall short when it comes to handling arbitrary objects
 (these may also be plain strings).

 Lets just consider that I have a binary Readable stream and I want to pipe
 it to a Transform stream that parses the binary data into js objects.
 Later on, I want to read() a single object or read(n) objects. Or maybe
 even read(0) to read all the objects until 'end'. So the stream interface
 itself would take care of buffering and the likes.

 Also the other way around:
 How can I create a Writable (Transform) stream that serialized arbitrary
 objects into binary data that I can then just pipe into tcp or onto disk?

 Other than the streaming parser/serializer, I can also think of complete
 pipelines that manipulate arbitrary objects in a streaming manner.

 Something like
 ```
 Readable(…)
   .pipe(parser())
   .pipe(filter('a = 10'))
   .pipe(map('a'))
   .pipe(inGroupsOf(4))
   .pipe(sum('a'))
   .pipe(serializer())
   .pipe(…)
 ```

 Note that those “arbitrary objects” might be strings or Buffers themselves.

 So any pointers on how to achieve such a thing with streams2 would be much
 appreciated.
 -Arpad

 --
 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] Fun stuff: Let it Snow! an easyRTC, node.js, WebRTC, socket.io and WebGL demo at chat.easyrtc.com

2012-12-23 Thread Dominic Tarr
this kinda works.
I can see other user's photo, and it takes pictures, and I see the animated
gifs when someone clicks the things,
but I don't see video of other user...
running chrome 23 on macbook air

On Sun, Dec 23, 2012 at 12:11 PM, Priologic Victoria priolo...@gmail.comwrote:

 This is currently a Chrome 23+ only demo.  chat.easyrtc.com

 --
 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] peeves current best practices?

2012-10-14 Thread Dominic Tarr
Jake, it is tempting to think that the there is a technical solution to
every social problem.

In a way, git, and github is like this.

But there is so much more that, as coders, we are only starting to
discover.
Musicians probably have a lot of experience in this area.

On Sun, Oct 14, 2012 at 8:03 PM, Tim Oxley sec...@gmail.com wrote:

 Excellent. This is a far more positive angle. Point taken.


 On Saturday, 13 October 2012 05:40:17 UTC+10, Dominic wrote:

 It's really about collaboration. The answer to the problem too many
 modules isn't Write Less Modules, it's Collaborate More!

 the ability to collaborate is a soft human skill, but a skill that you
 can develop.

 On Fri, Oct 12, 2012 at 3:34 PM, Rick Waldron waldro...@gmail.comwrote:


 On Friday, October 12, 2012 at 6:15 AM, Dominic Tarr wrote:

 I was worried for a second that this post was gonna be about punctuation.

 Pleasantly Surprised!

 The hardest part is the bit about NIH. This isn't really something we
 understand properly yet. It can be a struggle just to find other modules
 that do the think you want. Sometimes you've written a module before you
 even discover that other solutions exist.

 If you do find someone has a module that is close to what you need,
 but not quite, in some important way, then you need to communicate with
 them. The best way to do this is on IRC. Unfortunately not everyone uses
 IRC.

 Please use IRC.


 +9001


 Code is a personal thing, and it's important to try and understand the
 VIBE the author is going for. Issues aren't really a way to communicate
 vibe.

 If someone is posting issues, or telling you about stuff in irc, please
 listen to them. Even if they are annoying. They will probably improve the
 usability of your module quite a bit.

 To really understand this though, I think we need anthropologists to
 live with hackers, and write a whole book about it.

 On Fri, Oct 12, 2012 at 9:52 AM, Tim Oxley sec...@gmail.com wrote:

 Yep, the idea of best practices is do this unless you have a good
 reason not to, which doesn't mean it's a blanket rule that must never be
 broken. A guideline, not a rule.

 The main issue with inconsistent sync/async functions is the behaviour
 has low discoverability unless it's documented (unlikely), you read the
 source, or you get gotcha'd by it.

 -Tim


 On Friday, 12 October 2012 08:46:52 UTC+10, Jimb Esser wrote:

 Though process.nextTick() *itself* is fast, delaying calling the
 callback until it gets through that queue can have large performance
 implications, for example, in our case, we may have a tick of our physics
 simulation queued up (which could take hundreds of ms), and if some logic
 has to go through a few process.nextTicks, all interspersed with some other
 expensive operations in between, this kind of API can lend itself to some
 poorly performing side effects.

 That being said, I do agree that it's generally best practice to do
 this, but it's good to be aware that it's not always the best for
 performance (in some of our own APIs, where we set them up to always call
 the callbacks asynchronously, we have needed to add short-cuts in a couple
 of cases where it had a significant impact on latency).

 On Thursday, October 11, 2012 1:36:58 PM UTC-7, Adam Crabtree wrote:

 It's a best practice because it helps those unfamiliar with the
 reasoning to keep from shooting themselves or their users in the foot.
 There are several ways that this may affect you, but a quick summary can be
 found here:

 http://howtonode.org/**understan**ding-process-next-**tickhttp://howtonode.org/understanding-process-next-tick

 How slow is process.nextTick? A quick benchmark reveals it's not just
 1ms, but in fact is roughly 1µs (0.001ms for the lazy):

 var i = 0, sum = 0
 ;(function foo() {
   var t = process.hrtime()
   process.nextTick(function() {
 sum += process.hrtime(t)[1]
 if(++i1000) return foo()
 console.log('Average time: ', sum/i)
   })
 })()

 That being said, there are always exceptions to the rule, and if you
 understand the tradeoffs and have a need to shave off µs, then go for it.
 Chances are though, for the other 99.9% it's a micro-optimization (no pun
 intended ;P). Again, this requires a special set of circumstances to be an
 issue, but when it is, discovering that the cause was a cache hit and a
 synchronous call to callback can be frustrating.

 Cheers,
 Adam Crabtree

 On Thu, Oct 11, 2012 at 12:50 PM, Axel Kittenberger axk...@gmail.comwrote:

  I'd rather see client patterns that are immune to  callbacks being
 called before the function returns sometimes.

 Ditto!

 We should encourage people to write callers that are good, rather than
 libraries that deliberately waste performance and tell the callers
 its alright you wrote bad code, they have to put in a
 process.nextTick anyway. And  1ms can be a lot in some areas.

 Document your function accordingly, if it guarantees a particular
 callback/return order or not. In many

Re: [nodejs] Re: How to write stream chunk by chunk with callbacks

2012-10-14 Thread Dominic Tarr
mark, just implement a stream shaped wrapper for your db client thing, (and
make sure you publish it to npm!)

On Sun, Oct 14, 2012 at 4:24 AM, Isaac Schlueter i...@izs.me wrote:

 Mark,

 The overall performance impact hasn't been fully established yet.  I
 suspect that it'll be slight, but it's unclear whether it'll be an
 improvement (owing most likely to greater hidden class optimization
 from having all streams share more of the same code), or a regression
 (owing to the fact that there's just more stuff being done).

 The syscall/IO footprint is identical, though.  Past experience in
 this area has shown that the total time spent in JS is usually a
 pretty small part of the overall latency unless the code is very hot
 or doing something very stupid.  We'll see soon.


 On Sat, Oct 13, 2012 at 5:52 PM, Mark Hahn m...@hahnca.com wrote:
  So using it in the backwards-compatible way doesn't cause any performance
  loss?  If so I can choose which to use in every situation.
 
 
  On Sat, Oct 13, 2012 at 5:31 PM, Isaac Schlueter i...@izs.me wrote:
 
  Mark,
 
  Well... yes.  If you want to siphon out the data as fast as possible,
  and it's not going to a writable stream interface of some sort, then
  you have to read() in a tight loop on every readable event.  That's
  actually not much different than the 'data' event scheme.
 
  Note that if you attach a 'data' event handler, then it'll do this for
  you.  The backwards-compatible API is exactly the one you're used to.
  The major difference is that, in 0.10, if you're using 'data' events,
  then pause and resume actually work in a non-surprising way (ie, you
  won't get 'data' events happening while it's in a paused state), and
  all streams in core will have the same set of events and methods
  (instead of each of them implementing 90% of the API in subtly
  different ways).
 
 
  On Sat, Oct 13, 2012 at 5:25 PM, Mark Hahn m...@hahnca.com wrote:
   But pipe only works if the writes are to another stream.  If they are
 to
   a
   db driver or something without pipe support then I have to do my own
   reads.
   Or am I missing something here?
  
  
   On Sat, Oct 13, 2012 at 5:19 PM, Nathan Rajlich 
 nat...@tootallnate.net
   wrote:
  
   Mark, to pump at max rate you'd use .pipe().
  
   On Sat, Oct 13, 2012 at 5:16 PM, Mark Hahn m...@hahnca.com wrote:
There is no 'data' event.  There is a read() method, and a
'readable'
event.  You call read() until it returns null, and then wait for a
readable
event to tell you it's time to read() more.
   
So, if we want to pump it at max rate we would run a tight loop to
read
and
write in the beginning and then on every readable event?   It seems
like
more work and a lot messier compared to the old data event scheme.
   
   
On Sat, Oct 13, 2012 at 5:08 PM, Alexey Petrushin
alexey.petrus...@gmail.com wrote:
   
Thanks for help, especially You Isaac for such a detailed answer.
   
As far as I understand it's possible to wrap existing evented
 stream
API
into callback interface (with in-memory data buffers to handle
mismatch
between explicit/implicit control flow).
But probably it won't worth it, it will be more easy to just use
 it
as
it's supposed to be used (with pipes) and wait untill those
 changes
in
0.10.
The new API seems to be very similar to what I asked for.
   
P.S.
   
As for the question and why do I need it - I'm working on
application
that
uses custom streams and though that maybe I can cheat and simplify
my
work a
little by not implementing complex evented interface :).
   
I once used such abstraction for working with streams in ruby:
   
to.write do |writer|
  from.read{|buff| writer.write buff}
end
   
Files are open and closed properly, buffer also have some default
size,
so
the code is very simple to use (more details
http://alexeypetrushin.github.com/vfs ).
Basically by implementing just those two methods You get ability
 to
stream
from any stream into any stream (fs, s3, sftp, ...).
   
I tried to do something similar with asynchronous streams.
   
--
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 

Re: [nodejs] peeves current best practices?

2012-10-12 Thread Dominic Tarr
I was worried for a second that this post was gonna be about punctuation.

Pleasantly Surprised!

The hardest part is the bit about NIH. This isn't really something we
understand properly yet. It can be a struggle just to find other modules
that do the think you want. Sometimes you've written a module before you
even discover that other solutions exist.

If you do find someone has a module that is close to what you need,
but not quite, in some important way, then you need to communicate with
them. The best way to do this is on IRC. Unfortunately not everyone uses
IRC.

Please use IRC.

Code is a personal thing, and it's important to try and understand the VIBE
the author is going for. Issues aren't really a way to communicate vibe.

If someone is posting issues, or telling you about stuff in irc, please
listen to them. Even if they are annoying. They will probably improve the
usability of your module quite a bit.

To really understand this though, I think we need anthropologists to live
with hackers, and write a whole book about it.

On Fri, Oct 12, 2012 at 9:52 AM, Tim Oxley sec...@gmail.com wrote:

 Yep, the idea of best practices is do this unless you have a good reason
 not to, which doesn't mean it's a blanket rule that must never be broken.
 A guideline, not a rule.

 The main issue with inconsistent sync/async functions is the behaviour has
 low discoverability unless it's documented (unlikely), you read the
 source, or you get gotcha'd by it.

 -Tim


 On Friday, 12 October 2012 08:46:52 UTC+10, Jimb Esser wrote:

 Though process.nextTick() *itself* is fast, delaying calling the callback
 until it gets through that queue can have large performance implications,
 for example, in our case, we may have a tick of our physics simulation
 queued up (which could take hundreds of ms), and if some logic has to go
 through a few process.nextTicks, all interspersed with some other expensive
 operations in between, this kind of API can lend itself to some poorly
 performing side effects.

 That being said, I do agree that it's generally best practice to do
 this, but it's good to be aware that it's not always the best for
 performance (in some of our own APIs, where we set them up to always call
 the callbacks asynchronously, we have needed to add short-cuts in a couple
 of cases where it had a significant impact on latency).

 On Thursday, October 11, 2012 1:36:58 PM UTC-7, Adam Crabtree wrote:

 It's a best practice because it helps those unfamiliar with the
 reasoning to keep from shooting themselves or their users in the foot.
 There are several ways that this may affect you, but a quick summary can be
 found here:

 http://howtonode.org/**understanding-process-next-**tickhttp://howtonode.org/understanding-process-next-tick

 How slow is process.nextTick? A quick benchmark reveals it's not just
 1ms, but in fact is roughly 1µs (0.001ms for the lazy):

 var i = 0, sum = 0
 ;(function foo() {
   var t = process.hrtime()
   process.nextTick(function() {
 sum += process.hrtime(t)[1]
 if(++i1000) return foo()
 console.log('Average time: ', sum/i)
   })
 })()

 That being said, there are always exceptions to the rule, and if you
 understand the tradeoffs and have a need to shave off µs, then go for it.
 Chances are though, for the other 99.9% it's a micro-optimization (no pun
 intended ;P). Again, this requires a special set of circumstances to be an
 issue, but when it is, discovering that the cause was a cache hit and a
 synchronous call to callback can be frustrating.

 Cheers,
 Adam Crabtree

 On Thu, Oct 11, 2012 at 12:50 PM, Axel Kittenberger axk...@gmail.comwrote:

  I'd rather see client patterns that are immune to  callbacks being
 called before the function returns sometimes.

 Ditto!

 We should encourage people to write callers that are good, rather than
 libraries that deliberately waste performance and tell the callers
 its alright you wrote bad code, they have to put in a
 process.nextTick anyway. And  1ms can be a lot in some areas.

 Document your function accordingly, if it guarantees a particular
 callback/return order or not. In many situations, standard is,
 callback immediately if you have all what is needed for the callback.
 If the caller fucks up, that one should be fixed, instead of the
 callee.

 Or in other words, cure the problem, not the symptom.

 --
 Job Board: http://jobs.nodejs.org/
 Posting guidelines: https://github.com/joyent/**node/wiki/Mailing-List-
 **Posting-Guidelineshttps://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=enhttp://groups.google.com/group/nodejs?hl=en?hl=en




 --
 Better a little with righteousness
than 

Re: [nodejs] peeves current best practices?

2012-10-12 Thread Dominic Tarr
It's really about collaboration. The answer to the problem too many
modules isn't Write Less Modules, it's Collaborate More!

the ability to collaborate is a soft human skill, but a skill that you can
develop.

On Fri, Oct 12, 2012 at 3:34 PM, Rick Waldron waldron.r...@gmail.comwrote:


 On Friday, October 12, 2012 at 6:15 AM, Dominic Tarr wrote:

 I was worried for a second that this post was gonna be about punctuation.

 Pleasantly Surprised!

 The hardest part is the bit about NIH. This isn't really something we
 understand properly yet. It can be a struggle just to find other modules
 that do the think you want. Sometimes you've written a module before you
 even discover that other solutions exist.

 If you do find someone has a module that is close to what you need,
 but not quite, in some important way, then you need to communicate with
 them. The best way to do this is on IRC. Unfortunately not everyone uses
 IRC.

 Please use IRC.


 +9001


 Code is a personal thing, and it's important to try and understand the
 VIBE the author is going for. Issues aren't really a way to communicate
 vibe.

 If someone is posting issues, or telling you about stuff in irc, please
 listen to them. Even if they are annoying. They will probably improve the
 usability of your module quite a bit.

 To really understand this though, I think we need anthropologists to live
 with hackers, and write a whole book about it.

 On Fri, Oct 12, 2012 at 9:52 AM, Tim Oxley sec...@gmail.com wrote:

 Yep, the idea of best practices is do this unless you have a good reason
 not to, which doesn't mean it's a blanket rule that must never be broken.
 A guideline, not a rule.

 The main issue with inconsistent sync/async functions is the behaviour has
 low discoverability unless it's documented (unlikely), you read the
 source, or you get gotcha'd by it.

 -Tim


 On Friday, 12 October 2012 08:46:52 UTC+10, Jimb Esser wrote:

 Though process.nextTick() *itself* is fast, delaying calling the callback
 until it gets through that queue can have large performance implications,
 for example, in our case, we may have a tick of our physics simulation
 queued up (which could take hundreds of ms), and if some logic has to go
 through a few process.nextTicks, all interspersed with some other expensive
 operations in between, this kind of API can lend itself to some poorly
 performing side effects.

 That being said, I do agree that it's generally best practice to do
 this, but it's good to be aware that it's not always the best for
 performance (in some of our own APIs, where we set them up to always call
 the callbacks asynchronously, we have needed to add short-cuts in a couple
 of cases where it had a significant impact on latency).

 On Thursday, October 11, 2012 1:36:58 PM UTC-7, Adam Crabtree wrote:

 It's a best practice because it helps those unfamiliar with the reasoning
 to keep from shooting themselves or their users in the foot. There are
 several ways that this may affect you, but a quick summary can be found
 here:

 http://howtonode.org/**understanding-process-next-**tickhttp://howtonode.org/understanding-process-next-tick

 How slow is process.nextTick? A quick benchmark reveals it's not just
 1ms, but in fact is roughly 1µs (0.001ms for the lazy):

 var i = 0, sum = 0
 ;(function foo() {
   var t = process.hrtime()
   process.nextTick(function() {
 sum += process.hrtime(t)[1]
 if(++i1000) return foo()
 console.log('Average time: ', sum/i)
   })
 })()

 That being said, there are always exceptions to the rule, and if you
 understand the tradeoffs and have a need to shave off µs, then go for it.
 Chances are though, for the other 99.9% it's a micro-optimization (no pun
 intended ;P). Again, this requires a special set of circumstances to be an
 issue, but when it is, discovering that the cause was a cache hit and a
 synchronous call to callback can be frustrating.

 Cheers,
 Adam Crabtree

 On Thu, Oct 11, 2012 at 12:50 PM, Axel Kittenberger axk...@gmail.comwrote:

  I'd rather see client patterns that are immune to  callbacks being
 called before the function returns sometimes.

 Ditto!

 We should encourage people to write callers that are good, rather than
 libraries that deliberately waste performance and tell the callers
 its alright you wrote bad code, they have to put in a
 process.nextTick anyway. And  1ms can be a lot in some areas.

 Document your function accordingly, if it guarantees a particular
 callback/return order or not. In many situations, standard is,
 callback immediately if you have all what is needed for the callback.
 If the caller fucks up, that one should be fixed, instead of the
 callee.

 Or in other words, cure the problem, not the symptom.

 --
 Job Board: http://jobs.nodejs.org/
 Posting guidelines: https://github.com/joyent/**node/wiki/Mailing-List-**
 Posting-Guidelineshttps://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
 You received this message because you

Re: [nodejs] How to aggregate streams? (multiplexer/demultiplexer)

2012-09-12 Thread Dominic Tarr
in electronics, multiplexer allows multiple channels to communicate
over a single channel.

http://en.wikipedia.org/wiki/Multiplexer

An electronic multiplexer makes it possible for several signals to
share one device or resource, for example one A/D converter or one
communication line, instead of having one device per input signal.

On the other hand, a demultiplexer (or demux) is a device taking a
single input signal and selecting one of many data-output-lines, which
is connected to the single input. A multiplexer is often used with a
complementary demultiplexer on the receiving end

You just want to merge the streams. I have some code here
https://github.com/dominictarr/event-stream/blob/master/index.js#L25-57

although it seems to have escaped the readme. oops. also, the comment is wrong.
it doesn't concat.

use this if you want to concatenate:
https://npmjs.org/package/kat

On Sun, Sep 9, 2012 at 5:36 PM, lbdremy remyloubra...@gmail.com wrote:
 Thanks for your answers :),

 The aggregate module does the job of aggretate 3 readables stream into 1
 with the Cat class, thanks.

 The code that you propose Raynos doesn't work for this case, because when
 the first readable stream will emit end, the pipe method will call the end
 method of the writable stream.
 Which means the writable stream is not more writable since this.writable
 is set to false when the end method is called. So next time another of the
 readable streams will emit data, two things can happen, the pipe method
 call the write method of the writable stream in this case the writable
 stream shoud/will throw an error since the end method has been called before
 and this.writable is false or the data emitted will be ignored because the
 writable stream has its this.writable set to false. Am I right or I miss
 something important in the code?

 For the second piece of code, you are completely right, I haven't think
 about it but it seems there is no need to do some sort of control on the
 different events since the trouble happens when data are emitted when the
 method end has already been called, in this case it can't happen. But maybe
 it would be nice to have a stream who know exactly how many streams will be
 piped and so return false when write is called until all streams are piped
 or cache the data emitted until all streams are piped.

 Interesting, why this could not be considered as demultiplexer and
 multiplexer?
 Tell me more, thank you.



 Le lundi 3 septembre 2012 18:19:34 UTC+1, Raynos a écrit :

 https://github.com/dominictarr/mux-demux

 MuxDemux is fantastic.

 However what your asking for is not a multiplexer.

 3 readable streams into one stream:

   var newStream = through()
   stream1.pipe(newStream)
   stream2.pipe(newStream)
   stream3.pipe(newStream)

 write to one into 3

   var writeStream = through()
   writeStream.pipe(stream1)
   writeStream.pipe(stream2)
   writeStream.pipe(stream3)

 On Mon, Sep 3, 2012 at 2:44 AM, lbdremy remylo...@gmail.com wrote:

 Hello,

 I'm wondering, does someone know a module that is able to aggregate
 multiple streams into 1.
 For example you give it 3 readable streams and you get 1 stream emitting
 all `data ` events from these 3 streams and emitting the `end` event when
 the 3 streams are ended.
 Same thing for writable streams, where when you write, you actually write
 to 3 streams.
 And a combinaison of both for writable/readable streams.

 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 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


 --
 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: best practice for real-time socket-based cross clustered-process data communication and computation

2012-09-12 Thread Dominic Tarr
You need to make every client a tcp server.
if they live on the same machine, use a unix socket instead of a port number.
see the docs for net.

Obviously, each node will need to keep track of every other node it
needs to communicate with. something like http://npm.im/seaport might
be good for that.

Also, what kind of messages are they sending?

On Tue, Sep 11, 2012 at 10:21 AM, Yi Tan yi2...@gmail.com wrote:
 Thanks Johnny,

 dnode is very inspiring. cluster2 may help us a lot in production!

 Regards,

 ty



 2012/9/11 Johnny Honestly mostmodern...@gmail.com

 I heard about this cluster manager today directly from the guys at ebay
 working on ql.io

 https://github.com/ql-io/cluster2

 You can stream buffers from parents to child process using stdin/out

 If you need sockets try dnode

 https://github.com/substack/dnode


 On Monday, September 10, 2012 1:45:12 AM UTC-7, Yi wrote:

 Hi node mates:

 I'm looking for your advice about how to design and implement an
 mechanism for real-time socket-based cross clustered-process data
 communication and computation.

 [The server layout]

 clientA --tcp socket-- node service A -- DataModelA -- unique radis
 data store

 clientB --tcp socket-- node service B -- DataModelB -- unique radis
 data store

 * node service A and B are cluster on the same server
 * 1 data model represent 1 client at the run time
 * both node service A and B talk to the same redis data store

 [The function request]

 I need to implement a mechanism, in which:
 1.  clients in difference processes can communication with each other
 efficiently.
 2. there need to be a centralized place for data computation base on data
 models represents difference clients

 the logic looks like the following diagram:

 clientA --tcp socket-- node service A
 |
   socket pipe
 |
v
 clientB --tcp socket-- node service B -- DataModelA and B -- unique
 radis data store

 Do you know what is the best way to do this, or is there something
 already been built

 Many thanks,

 ty

 --
 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 to make node.js HMac sha1 with salt work with microsoft sha1?

2012-09-06 Thread Dominic Tarr
maybe the microsoft version is using a different initialization vector?

On Mon, Sep 3, 2012 at 10:01 PM, kenny kien.du...@gmail.com wrote:
 Hi All,

 I have to work with microsoft database and using node.js, but I cannot make
 the hash value of the generated node.js to be the same as the one in the
 microsoft sql database?

 Is there anyways to do it?

 Also is there any library that can generate the same hash value?

 My company want to have the main website using microsoft C# and using
 node.js as the server side for mobile app?

 thank you all

 --
 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: emit('data') best practice

2012-09-05 Thread Dominic Tarr
it's much easier to write high level apis with js objects in streams,
and then pipe to a stream that can stringify it. This reduces glue code,
and  increases flexibility, because you can use a high level stream with
any kind of text-stream.

Otherwise every stream module needs a parser...
or you get more monolithic tools that wrap tcp servers or socket.io.

In this case, prehaps the best thing is to emit a data event with an
empty array in it.

the pub-sub feature of redis is a bit weird, kinda tacked on to redis,
but probably better to let it's own documented behaviour 'fall through'
rather than try to 'fix' it.

On Tue, Sep 4, 2012 at 5:15 PM, Mikeal Rogers mikeal.rog...@gmail.com wrote:
 I tend to agree.

 The current implementation in most of node allows setEncoding to change the
 data event to emit buffers. In the case of several userland streams strings
 are emitted.

 For efficiency, if people are expected to work with the data as a string it
 is much cheaper to avoid unnecessary conversions, but IMO it's painful to
 not be able to assume data events will be Buffers.

 -Mikeal

 On Sep 3, 2012, at September 3, 20128:26 PM, tjholowaychuk
 tjholoway...@gmail.com wrote:

 IMO if the idea behind streams are to act like pipes then data events
 should only be raw data aka Buffers (strings too I guess),
 if it's a non-stream then whatever I guess

 On Monday, 3 September 2012 15:44:55 UTC-7, Mike Nichols wrote:

 When issuing a redis command which expects a multi-bulk reply but the key
 does not exist, one may receive the following:
 +OK
 *0

 The redis docs say If the specified key does not exist, the key is
 considered to hold an empty list and the value 0 is sent as multi bulk
 count.

 It seems like it is proper to emit a 'data' event in a client library with
 the 'empty list' redis implies so that consuming code can use it in a
 pipeline and let the consumer handle the `empty list` there.

 This came from looking at 'https://github.com/tblobaum/redis-stream' where
 this sort of reply drops the data, thus breaking the pipeline.

 This leads me to the greater question on whether or not to emit 'data' for
 a empty value. My gut says low level libs like these _should_ emit the event
 with empty data but I wonder what other authors are preferring.

 Any opinions would be appreciated 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
 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] What the hell is travis4all?

2012-08-23 Thread Dominic Tarr
He is trying to do a good thing, he's just not doing it in a good way.

A better way, would be to make a command line tool that let you
quickly add travis to a module, and then let you use it as you choose.

And maybe made ONE PR to your most recently updated module (not ones
you havn't touched in months)

And also, to provide an email so that people can give you feedback,
and to open source the bot so the people can fix problems like,
check whether or not the module in question actually has tests.

On Thu, Aug 23, 2012 at 3:11 PM, Arnout Kazemier i...@3rd-eden.com wrote:
 If you have access to 50+ repositories, it becomes spammy quite quickly..

 --
 Arnout Kazemier
 Sent with Sparrow

 On Thursday 23 August 2012 at 15:09, Martin Wawrusch wrote:

 It is one smart way of growth-hacking. I would not consider it spammy.

 On Thu, Aug 23, 2012 at 2:51 AM, Arnout Kazemier i...@3rd-eden.com wrote:

 Oh btw, you can just block that user by clicking on the cog next to +follow

 On Thursday 23 August 2012 at 11:35, Marcel Laverdet wrote:

 Did anyone just get a kind of spammy pull request on github from
 travis4all?

 https://github.com/travis4all 1,334 repos and counting. Is this just a bot
 that is going through github and issuing automatic pull requests for all
 nodejs projects or what?

 --
 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

-- 
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: best testing framework?

2012-08-22 Thread Dominic Tarr
write your own test framework!
that teaches you every thing about error handling!

On Wed, Aug 22, 2012 at 12:11 PM, Nuno Job nunojobpi...@gmail.com wrote:
 We are going to have a nodeup episode about testing next sunday.

 I don't predict people talking about the best of anything though.

 I made specify: https://github.com/dscape/specify

 Nuno

 On Wed, Aug 22, 2012 at 8:52 AM, greelgorke g.e...@wowbiz.de wrote:
 http://toolbox.no.de/packages/cucumber
 mocha
 chai
 vows

 more here http://toolbox.no.de/categories/Testing%20%2F%20Spec%20Frameworks

 Am Mittwoch, 22. August 2012 05:31:02 UTC+2 schrieb ss9:

 hey all, i have a node app with backbone on the front end.  i'm looking
 for a relatively straightforward testing framework a la cucumber that i
 can implement on both the backend and front end. any suggestions?

 thanks!
 R

 --
 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] a pakage that exports few modules

2012-08-22 Thread Dominic Tarr
each module should to just one thing. if it does a lot of things it
should really be separate modules.

On Fri, Aug 17, 2012 at 5:01 PM, Osher E osher...@gmail.com wrote:
 here, I'm looking at:
  http://wiki.commonjs.org/wiki/Packages/1.1

 Specifically - search for directories, and you'll end up with the
 following findings in the texts, all of them under the section

 Package Descriptor File


 directories.lib - directory of modules to be loaded under the packages
 namespace. require(name/subfilename) must return modules from this
 directory. Definition must be relative to the package description file.

 directories - Object hash of package directories. Typical directories
 include lib, src, doc, jars, test and bin. Package manager tools
 must use these directory definitions to find various package components.




 And from that I learn that I should be able to create a package from which I
 should be able to require(mypackage/somemodule)
 Did anybody here did it before?



 Here's what I try:

 {
   name: common-core,
   version: 0.0.1,
   description: common tools - wrappers for logger and crypto, a
 config-base util and more,
   main: index.js,
   directories.lib: lib,
   directories: {
 test: test,
 lib : lib
   },
   scripts: {
 test: node node_modules/vows/bin/vows --spec
   },
   repository: hg+http://private-lan:2782/common-core;,
   license: none,
   dependencies: {
 log4js: 0.5.*,
 crypto: 0.0.3,
 underscore: ~1.3.3,
 validator: ~0.4.10
   },
   devDependencies: {
 vows: *
   }
 }

 Classic Folder structure

 /common-core
   /lib
  config.js
  logger.js
  enc.js
  minimo.js
  ...and more
   /test
  ... all test files
  package.json
  index.js
  README.md

 There just have to be a way to do it...


 On Friday, August 17, 2012 5:42:57 PM UTC+3, Osher E wrote:

 here, I'm looking at:

 http://wiki.commonjs.org/wiki/Packages/1.1

 Specifically - search for directories, and you'll end up with these
 texts:

 directories.lib - directory of modules to be loaded under the packages
 namespace. require(name/subfilename) must return modules from this
 directory. Definition must be relative to the package description file.

 directories - Object hash of package directories. Typical directories
 include lib, src, doc, jars, test and bin. Package manager tools
 must use these directory definitions to find various package components.



 And from that I learn that I should be able to create a package from which
 I should be able to require(mypackage/somemodule)
 Did anybody here did it before?


 --
 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: best testing framework?

2012-08-22 Thread Dominic Tarr
nuno,

https://github.com/dominictarr/macgyver
https://github.com/dominictarr/it-is
https://github.com/dominictarr/assertions
https://github.com/dominictarr/synct
https://github.com/dominictarr/asynct
https://github.com/dominictarr/meta-test

... to many, but I learnt a lot.
now I mostly just use straight scripts that error if the test fails.

with an assertion lib if I feel that it is warranted.

macgyver, it-is, and assertions are really assertions libs, and not
test frameworks.

meta-test was part of an an ambitious project to wrap every test
framework and thus grab the data out of any test run... but evenually
I realized that the only thing general enough to work with everything
is to just grab stdio and exit codes.





On Wed, Aug 22, 2012 at 3:59 PM, Alan Gutierrez a...@prettyrobots.com wrote:
 I created Proof...

 https://github.com/bigeasy/proof

 It is nice to have your own test framework. You spend so much time and 
 attention
 on testing, you're going to be plauged with insights as to how testing should 
 be
 done. Creating my own test framework helps me to be my own programmer.

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

 On Wed, Aug 22, 2012 at 12:19:28PM +0200, Dominic Tarr wrote:
 write your own test framework!
 that teaches you every thing about error handling!

 On Wed, Aug 22, 2012 at 12:11 PM, Nuno Job nunojobpi...@gmail.com wrote:
  We are going to have a nodeup episode about testing next sunday.
 
  I don't predict people talking about the best of anything though.
 
  I made specify: https://github.com/dscape/specify
 
  Nuno
 
  On Wed, Aug 22, 2012 at 8:52 AM, greelgorke g.e...@wowbiz.de wrote:
  http://toolbox.no.de/packages/cucumber
  mocha
  chai
  vows
 
  more here 
  http://toolbox.no.de/categories/Testing%20%2F%20Spec%20Frameworks
 
  Am Mittwoch, 22. August 2012 05:31:02 UTC+2 schrieb ss9:
 
  hey all, i have a node app with backbone on the front end.  i'm looking
  for a relatively straightforward testing framework a la cucumber that i
  can implement on both the backend and front end. any suggestions?
 
  thanks!
  R
 
  --
  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

-- 
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: best testing framework?

2012-08-22 Thread Dominic Tarr
matt, Marak:

If you see a job that needs doing, it's your job.

On Wed, Aug 22, 2012 at 5:06 PM, Matt hel...@gmail.com wrote:
 I just wish everyone agreed on TAP output (I see proof does). We should
 really be thinking about a future where we have the equivalent of Perl's
 CPAN Testers, and a common output format is vital for something like that.

 Perl's CPAN Testers take the whole of CPAN (the equivalent of the NPM
 archive) and run tests on different platforms and different versions of
 Perl, including development versions of Perl, and provide authors with handy
 reports to fix their issues. They also provide the core Perl developers with
 info if a development version of Perl breaks something that is commonly used
 on the CPAN. There's a huge culture of testing in the Perl world that can be
 learned from here.

 Matt.


 On Wed, Aug 22, 2012 at 9:59 AM, Alan Gutierrez a...@prettyrobots.com
 wrote:

 I created Proof...

 https://github.com/bigeasy/proof

 It is nice to have your own test framework. You spend so much time and
 attention
 on testing, you're going to be plauged with insights as to how testing
 should be
 done. Creating my own test framework helps me to be my own programmer.

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

 On Wed, Aug 22, 2012 at 12:19:28PM +0200, Dominic Tarr wrote:
  write your own test framework!
  that teaches you every thing about error handling!
 
  On Wed, Aug 22, 2012 at 12:11 PM, Nuno Job nunojobpi...@gmail.com
  wrote:
   We are going to have a nodeup episode about testing next sunday.
  
   I don't predict people talking about the best of anything though.
  
   I made specify: https://github.com/dscape/specify
  
   Nuno
  
   On Wed, Aug 22, 2012 at 8:52 AM, greelgorke g.e...@wowbiz.de wrote:
   http://toolbox.no.de/packages/cucumber
   mocha
   chai
   vows
  
   more here
   http://toolbox.no.de/categories/Testing%20%2F%20Spec%20Frameworks
  
   Am Mittwoch, 22. August 2012 05:31:02 UTC+2 schrieb ss9:
  
   hey all, i have a node app with backbone on the front end.  i'm
   looking
   for a relatively straightforward testing framework a la cucumber
   that i
   can implement on both the backend and front end. any suggestions?
  
   thanks!
   R
  
   --
   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


 --
 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

Re: [nodejs] Creating Proper Benchmarks

2012-08-22 Thread Dominic Tarr
the best and worst run may be the most important runs. the worst run
in particular.
you may have code that usually runs well, but might have bad worst
case performance.

depending on how your code is used, the biggest improvement may come
from improving the worst-case performance.

On Wed, Aug 22, 2012 at 4:40 PM, Alan Gutierrez a...@prettyrobots.com wrote:
 I'm starting to use `node-bench` to benchmark a packet parsing library, binary
 to JSON conversion and vice-versa.

 I'm wondering if, when you create your benchmarks, how do you account for
 garbage collection? Has anyone written some nice libraries or gists that would
 help get better results out of `node-bench` like throwing away the best and
 worst run? (Found `visualbench` and plan on using it.)

 --
 Alan Gutierrez - http://twitter.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

-- 
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] Creating Proper Benchmarks

2012-08-22 Thread Dominic Tarr
you need to use some statistics, and measure your mean, and
std-deviation, in the least.

On Wed, Aug 22, 2012 at 5:18 PM, Dominic Tarr dominic.t...@gmail.com wrote:
 the best and worst run may be the most important runs. the worst run
 in particular.
 you may have code that usually runs well, but might have bad worst
 case performance.

 depending on how your code is used, the biggest improvement may come
 from improving the worst-case performance.

 On Wed, Aug 22, 2012 at 4:40 PM, Alan Gutierrez a...@prettyrobots.com wrote:
 I'm starting to use `node-bench` to benchmark a packet parsing library, 
 binary
 to JSON conversion and vice-versa.

 I'm wondering if, when you create your benchmarks, how do you account for
 garbage collection? Has anyone written some nice libraries or gists that 
 would
 help get better results out of `node-bench` like throwing away the best and
 worst run? (Found `visualbench` and plan on using it.)

 --
 Alan Gutierrez - http://twitter.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

-- 
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: Writing data to a socket

2012-08-22 Thread Dominic Tarr
as mentioned above, you need to explicitly write \n's if you want to
get your new lines,
tcp will rechunk things as it decides is best. if you want to split
the modules by line on the other side I have this module:
https://github.com/dominictarr/event-stream#split-matcher

it works just like String#split but on a stream.


On Wed, Aug 22, 2012 at 4:30 AM, Juan Ignacio Dopazo
dopazo.j...@gmail.com wrote:
 Yup, I eventually had a facepalm moment and landed on this page:
 http://en.wikipedia.org/wiki/Nagle's_algorithm.

 The explanation is very clear. I still have doubts about whether
 socket.setNoDelay() is working as expected or not, but I'm coming to terms
 on the fact that I need to use some sort of message format that I can
 identify.

 Now to see if I can get this little network program to work.

 Thank you all a lot!

 Juan


 2012/8/21 greelgorke g.e...@wowbiz.de

 i just thought about it and i had to remind me about tcp itself. so. the
 question is not how to force tcp to send one byte at a time, but what do you
 want to send. the way how to use tcp ist:
 - define your message format (i.E. HTTP does it)
 - use tcp as it is. tcp will break up your messages if they dont fit into
 a single data-package so you'll have to merge may be
 - parse it to your message format.


 in your case i would do on server something like this

 connection.on('data', function(data){
   data.split('\n').forEach(function(message){
 console.log('message received:'+message);
   });
 });

 and on client just send 'a\n'  so i defined my message format as
 \n-separated string.

 its the way of tsp/ip or even most of protokoll families in OSI-meant way
 not to tweak the underlying protokoll for higher-level purposes, but to
 define your own one on top of them. Thats how internet and all the stuff
 works.



 Am Montag, 20. August 2012 17:20:38 UTC+2 schrieb Juan Ignacio Dopazo:

 Thank you both!

 I hadn't noticed client.write(str, callback), but when I test it I still
 get the same result. And client.end('a') only writes once, then marks the
 socket as not writable.

 I figured out that the socket had a buffer. I wanted to understand a bit
 more about why. And also the description for socket.setNoDelay() says:

 Disables the Nagle algorithm. By default TCP connections use the Nagle
 algorithm, they buffer data before sending it off. Setting true for noDelay
 will immediately fire off data each time socket.write() is called.


 But if I do client.setNoDelay() in the client I still see the same
 result. Could it be a bug or am I missing something else?

 Juan

 2012/8/20 Clément Fossati fossati...@gmail.com

 Hi Juan,

 It's because the socket has a buffer and it's not flush everytime you
 write on it.

 If you want to send multiple message, you can use client.end('a');
 instead of client.write('a');

 You don't need to write client.end(); because you socket is already
 half-closed by the client.end('a');

 Regards,
 Clément

 Le dimanche 19 août 2012 21:01:09 UTC+2, Juan Ignacio Dopazo a écrit :

 Hi!

 I'm getting a weird result when writing to a socket. I wrote a simple
 experiment with a client and a server:

 server.js
 var net = require('net');

 net.createServer(function (connection) {
   console.log('client connected');
   connection.on('data', function (data) {
 console.log('data: ' + data);
   });
 }).listen(1337);

 client.js
 var net = require('net');

 var client = net.connect({port: 1337}, function () {
   console.log('connected');
   var i = 0;
   function send() {
 client.write('a');
 if (++i  100) {
   process.nextTick(send);
 } else {
   client.end();
 }
   }
   send();
 });

 I expected the server to show 100 lines of data: a, but I ended up
 getting a smaller number of data: aaa lines. There's 
 socket.setNoDelay()
 that seems to be what I want, but it doesn't seem to have any effect.

 What am I missing?

 Thanks a lot,
 Juan

 --
 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


 --
 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 

Re: [nodejs] Creating Proper Benchmarks

2012-08-22 Thread Dominic Tarr
this one has confidance intervals, https://github.com/bestiejs/benchmark.js

which is what you need to detect the likehood that one run really did
improve on another or if it was just a fluke.

On Wed, Aug 22, 2012 at 6:34 PM, Alan Gutierrez a...@prettyrobots.com wrote:
 On Wed, Aug 22, 2012 at 05:19:31PM +0200, Dominic Tarr wrote:
 On Wed, Aug 22, 2012 at 5:18 PM, Dominic Tarr dominic.t...@gmail.com wrote:
  the best and worst run may be the most important runs. the worst run
  in particular.
  you may have code that usually runs well, but might have bad worst
  case performance.
 
  depending on how your code is used, the biggest improvement may come
  from improving the worst-case performance.

 you need to use some statistics, and measure your mean, and
 std-deviation, in the least.

 Erm. So, can I do this with `node-bench` easily, or have I just signed
 up for creating a benchmarking framework? Is the ease of use jsperf.com
 misleading?

 Ideally, I'd like a report that says, all things being equal, a is
 faster than b. I can reason about whether all things will always be
 equal separately.

 --
 Alan Gutierrez - http://twitter.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

-- 
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: [node-dev] Hardened node

2012-08-04 Thread Dominic Tarr
I've been considering a AST manipulation approach to security lately,
substack used a this approach to provide consistent stacktraces in any browser.

https://github.com/substack/node-stackedy

It would allow child processes because you could ensure that whenever
node starts it instruments the code with the right permissions.

I havn't tried this yet though, it could work.

The *right* way is surely os level though, as there is hardware
support for virtualization at that lever.


On Fri, Aug 3, 2012 at 9:23 PM, Bradley Meck bradley.m...@gmail.com wrote:
 If you do use chroots as jails, beware of chroot jail breaking using fd
 exploits and other techniques. Ensure your used is still non-privileged on
 the filesystem as appropriate.


Re: [nodejs] Most efficient way of piping HTTP body through a tunneling proxy

2012-08-03 Thread Dominic Tarr
@john I applaud your efforts for FREE WIFI!

does the firewall permit http pipelining?

also, have you heard of dnstunneling? http://dnstunnel.de/

with a little bit more work you could make your http-tunnel into a
reliable stream
that maintained stream semantics over disconnects.

On Fri, Aug 3, 2012 at 10:37 AM, Diogo Resende drese...@thinkdigital.pt wrote:
 I'm not sure why you don't use .pipe().. you don't need to buffer all the
 request before sending it. The headers should have a content-length so your
 endpoint will know about it. Just send the data directly to the other end
 instead of buffering.

 --
 Diogo Resende

 On Monday, July 30, 2012 at 22:40 , axs wrote:

 Thank you, Mikeal. I use request quite a bit in my projects, and it's great.
 However, I won't be using request for this project, because I need to write
 this one at the transport layer. Eventually I will be redirecting various
 requests to other servers and examining data at the transport layer. I just
 need to make this barebones version function and then branch from it. Any
 ideas on how to pipe the request into the socket?

 I thought of listening to the 'connection' event on the proxy server, and
 piping the socket into the tunnel. But this won't differentiate between http
 and https requests without parsing the request header, which I'm not sure
 how to do.

 Regards,
 Alex

 On Monday, July 30, 2012 5:21:04 PM UTC-4, Mikeal Rogers wrote:

 request does all of this, including SSL tunneling.

 req.pipe(request(req.url, {proxy:'https://site.com'})).pipe(resp)

 -Mikeal

 --
 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] NodeJS ReadStream not reading bufferSize bytes at a time

2012-08-03 Thread Dominic Tarr
Gill, the kPool is a large buffer that ReadStream cuts buffers out of,
I think, to minimize the allocation of memory...

I was reading through this the other day, and noticed that the default
buffer size is larger than the default kPoolSize. that seems wrong.

you'd need to recompile node, of course, but making kPoolSize larger
should work.

On Fri, Aug 3, 2012 at 8:50 AM, Gill taran.i...@gmail.com wrote:
 I think this is related: https://github.com/joyent/node/issues/2098

  - Gill


 On Thursday, 2 August 2012 23:32:39 UTC-7, Gill wrote:

 Ben, thanks for the reply. I have a doubt that its just a hint, because
 how come it is exactly 40960 bytes every time. The underlying filesystem is
 a custom coded one, which WILL return the exact number of bytes that were
 asked for. Line 38 for /lib/fs.js says:

 var kPoolSize = 40 * 1024;

 Do you think changing it to 128 * 1024 will change anything?

  - Gill

 On Thursday, 2 August 2012 16:29:43 UTC-7, Ben Noordhuis wrote:

 On Thu, Aug 2, 2012 at 9:21 PM, Gill taran.i...@gmail.com wrote:
  I have a code where the NodeJS server reads a file and streams it to
  response, it looks like:
 
  var fStream = fs.createReadStream(filePath, {'bufferSize': 128 *
  1024});
  fStream.pipe(response);
 
  The issue is, Node reads the file exactly 40960 bytes a time. However,
  my
  app would be much more efficient (due to reasons not applicable to this
  question), if it reads 131072 (128 * 1024) bytes at a time.
 
  Is there a way to force Node to read 128 * 1024 bytes at a time from
  the
  stream?
 
  Thanks in advance!

 No. bufferSize is a hint, not an imperative. It's up to the operating
 system to honor 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

-- 
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 Dominic Tarr
try removing whitespace from the ends

text = text.trim()

On Thu, Aug 2, 2012 at 3:24 PM, Dan Milon danmi...@gmail.com wrote:
 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

-- 
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 Dominic Tarr
try removing whitespace from the ends

text = text.trim()

On Thu, Aug 2, 2012 at 3:24 PM, Dan Milon danmi...@gmail.com wrote:
 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

-- 
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] fundamental stream questions

2012-08-01 Thread Dominic Tarr
A1) you need to assign a listener _before_ nextTick.

A2) you only need to call destroy() if you've decided to end the stream early.
streams must cleanup after they have emitted 'end', (or you have called end()
and they are only a writable stream)

On Wed, Aug 1, 2012 at 6:45 AM, Carlos cmu...@gmail.com wrote:
 Question 1

 When I read things like data will be lost if there is no listener when a
 Readable Stream emits a 'data' event, it's pretty obvious that I need to
 have a listener attached before the stream is capable of emitting events.
 How can I guarantee this?  Said another way, what is the earliest point in
 one-and-only js thread and/or the event-loop when a stream can emit an
 event?

 I am looking at this from two sides.  On one side, I need to make sure I
 don't miss any data events.  On the other side, I don't want to accidentally
 create blocking code by doing something which would delay the data events.

 Question 2

 If I create a steam indirectly, such as with fs.create ReadStream(...) who
 is responsible for releasing the file descriptor (or other resources)?
 Should I call destory() on the stream or not?

 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] detect network speed, serve content accordingly

2012-07-30 Thread Dominic Tarr
no, you should be able to detect network speed, because tcp uses smart
end points, and dumb relays.

basically, if the network is slow, packets will be dropped before
they reach the other end, and have to be resent. this should manifest
it self in node as write()=== false on your HttpResponse object, and a
'drain' event it is ready again.

if you stop writing to a stream when it asks, then this should
theoretically be something like the network speed. of course, you
could have the client stream something back, too.

here are two modules for measuring the throughput of streams,

https://github.com/fent/node-streamspeed
https://github.com/dominictarr/probe-stream

keep in mind that it may not be accurate if you are piping to the
network with a stream that doesn't respect pause.

it's probably best to have the detector on the receiving end.

On Mon, Jul 30, 2012 at 12:04 PM, Mark Hahn m...@hahnca.com wrote:
 I assume you mean the network speed to a particular client on each session.
 The client side is almost always the limiting factor and will vary from
 session to session.

 I would do it by measuring the page load time in javascript and then sending
 the test result to the server, maybe using ajax, and then saving this info
 in the server's session store for that particular client.  The server can
 then adjust its behavior however it wants.

 On Sun, Jul 29, 2012 at 4:35 PM, jerome jeromecoving...@gmail.com wrote:

 I guess my point is, if anybody has any information on the process of
 detecting network speeds, and adjusting behavior between the client/server
 in response, I'd be interested in exploring what's possible.

 --
 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: Trying to understand streams and child processes

2012-07-30 Thread Dominic Tarr
the function you pass to an EventEmitter#on is not a callback, it is
an event listener.

the difference, is that callbacks are called exactly once, and the
first argument reserved for an error parameter.

an event listener, on the other hand, may be called 0 or more times,
until you remove the listener, or when ever the event emitter has finished.
and there is no error paramater (the event emitter should just emit a
separate 'error' event)

On Tue, Jul 31, 2012 at 3:20 AM, carlton carltondick...@gmail.com wrote:
 I've tried a range of ftp modules, some are out of date and don't work with
 the latest version of Node and other don't seem to support SFTP and the fact
 I need to use a key to connect to my server.

 Do you know much about child_process etc...I'm wondering if the 'fork'
 functionality is what I should be using.

 i.e. I connect to the SFTP with the parent process and form child to make my
 other commands and also create new event listeners for when the data
 returns.

 I may also give this a chance  https://github.com/sergi/jsftp as I tried it
 a while ago only to get error FTP is not defined which was odd as the
 module seems to be required without an error


 On Monday, 30 July 2012 15:11:34 UTC+1, Roly Fentanes wrote:

 Why not try using one of the ftp modules?

 http://toolbox.no.de/search?q=ftp

 On Monday, July 30, 2012 4:01:43 AM UTC-7, carlton wrote:

 Hi there,

 I am trying to implent a nodejs script that connects to one of our
 servers using sftp.

 So far I can connect using child process and spawning a command such
 as...

 sftp -o Port=22-o PasswordAuthentication=no-o
 UserKnownHostsFile=/home/carlton/.ssh/known_hosts-o
 IdentityFile=private_key-o StrictHostKeyChecking=no-o
 BatchMode=nodeploy@46.x.x.x:/home/carlton/to_process

 Now this is the part that has me confused...

 I then need to execute commands on the ftp server (e.g. list files,
 rename files) so I listen to the 'data' event

 sftp.stdout.on('data', function (data) {
 console.log('stdout: ' + data);

 sftp.stdin.write(ls -l\r\n);

 sftp.stdout.on('data', function(data){
 console.log('File list:', data.toString());

  // Parse file names here

 sftp.stdin.write(rename
 /home/carlton/FTP_test/to_process/old.php /home/ carlton
 /FTP_test/processed/new.php\n);
 });
 });

 Is this the correct way to structure things (i.e. creatiung event
 listener again for the 'data' event within the callback of the previous
 'data' event listener)?
 I found it hard to find any examples similar to what I need to do which
 made me think I haven't built this as it should have been.

 --
 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: A Galaxy within NodeJS

2012-07-30 Thread Dominic Tarr
write 5 alien species on the box, and then let the others be a surprise.

On Tue, Jul 31, 2012 at 12:02 AM, Stephan Bruny
the.deathg...@googlemail.com wrote:
 As far as we know we are the only intelligent (whatever this means) species
 in our galaxy, that is much bigger than 8000 lightyears (it's 100,000ly to
 120,000ly according to my astronomy book).
 So I think 5 species in one little dwarf-galaxy is a lot!

 Am Sonntag, 29. Juli 2012 19:02:51 UTC+2 schrieb Dominic:

 the only thing crazy about this idea is the low number of alien
 species, I mean,
 only 5 across 8000 light years?

 On Sat, Jul 28, 2012 at 6:52 AM, Robert L blk.rab2...@gmail.com wrote:
  Hi, everybody
 
  I'm developing a NodeJS addon which is target as a high concurrency tcp
  ipv4/v6 server.
  I use pthread and epoll to implement the framework, and the performance
  seens very good.
  Maybe I will announce it in days, and its already months of work.
  I want to add support of client connection ability to it before the
  announce.
 
  After that, I plan to add a serviceHandler method(in c/c++ addon way),
  for
  people using it, to implement their protocol/service of their usage.
  And it can run on pthread, although performance gain by pthread is not
  very
  good, but it still works.
 
  I would like to know how many concurrency connections and requests per
  second do people expect? and for a mmo server?
  There is people claim to achieve 140k requests/sec, is it good enough?
 
  Thanks
 
  *This is my first post here :)
 
 
  Stephan Bruny於 2012年7月27日星期五UTC+8下午3時38分49秒寫道:
 
  Lua is as capable as any other language ;)
  And yes, it is faster when it comes to matrices because of its well
  designed table-approach.
  But it suffers from the same limitations as all dynamic languages do.
  Doing all the calculations within Redis wouldn't speed up the system.
  BUt
  it's a nice idea for another project, to make a completely data-driven
  game
  that is calculated on the database...
 
  My idea so far is NodeJS doing all I/O-Stuff from/to the clients. This
  will be fast as hell.
  The procedural algorithm that calculates the galaxys geometry and
  physics
  will be running in another C-Process that can emit events.
  So Node will contain Networking-Routines and Game Logic.
 
  In an MVC (that I might choose for architecture) context Node would
  represent models and controllers.
  The C-Process would be a special model bound to the workflows within
  the
  Node-Application, and the client contains views only.
 
  I'm not sure about the design of the C-Process - wether it's a library
  running it's own thread or and independent program communicating via
  binary
  protocoll or even another server?
  I like to keep things as simple as possible and as small as possible.
  So a
  simple (threaded) C-Library would be my favourite choice.
 
  The next problem is the galaxy-algorithm itself. It will include
  techniques like Octrees, Level Of Detail, Cellurar Noise and Perlin
  Noise.
  Alltogether mixed up with phyical, chemical and other parameters.
 
  So I guess my math teacher was right when he said, I will regret
  quitting
  so many math-classes :-D
 
 
 
  On Friday, July 27, 2012 4:24:03 AM UTC+2, Johnny Honestly wrote:
 
  Is Lua capable of this? If so you can stream between Node.js and
  Redis,
  which has Lua scripting built in, and run your scripts right on your
  data.
 
  Curiously, the site says your scripts shouldn't be functions tho
  http://redis.io/commands/eval
 
  Is this your side project?
 
  On Wednesday, July 25, 2012 12:26:56 PM UTC-7, Stephan Bruny wrote:
 
  If you don't call me crazy then you are!
  Some years ago I've been a game developer (NDS, PC, XBOX 360) but now
  I
  earn my bucks with web development like most of us I guess?
  I used NodeJS for middleware, small websites and applications within
  service-environments and it always proofed to be blazing fast.
 
  But now comes the time to make a game again. A real huge thing. An I
  mean huge ;)
  Maybe some of you know what I mean when I say Shores of Hazeron.
  It's a mixture between (MMO)RPG, simulation and strategy within a
  whole
  galaxy that is simulated on the server side.
 
  To make a short version of my idea:
  The game simulates an entire dwarf-galaxy (about 8000 light years)
  where
  we put like 5 alien races.
  The player has a lot of crafting abilities, can build houses, invent
  technology, etc. to finally build a rocket flying to the moon(s)
  orbiting
  his home world.
  The player's race might colonize it's solar system and head for
  intergalactic travelling and maybe meet one of the other races...and
  then...phew phew phew. ;)
 
  You might expect a game design document, but I'm working as a product
  manager within an agile team, and I'd say, as long as I don't need to
  sell
  something to a publisher, I can keep it agile from the idea to the
  implementation.
 
  Technically there are some hard rocks to break.
  Rendering a 

Re: [nodejs] Re: Standard Test Runner for Node

2012-07-16 Thread Dominic Tarr
_everyone_ a strong opinion on this.

our test frameworks need to be rewritten now that we have domains.

maybe, write through exercises in the book?

On Tue, Jul 17, 2012 at 8:32 AM, Roly Fentanes roly...@gmail.com wrote:
 If you can get your tests' point across clearly by using node's `assert`
 module and it's not that much difficult to structure compared to a full
 featured test framework, then consider using it.

 Otherwise, mocha is the popular recent one, and my personal choice. nodeunit
 is easy to understand too, and has been around for a while. vows used to be
 the choice, there's still a lot of popular modules with their tests written
 with vows. But it's no longer maintained and it shows.

 chai is often used along with these to make assertions easier to understand.


 On Monday, July 16, 2012 9:56:14 AM UTC-7, Alex Young wrote:

 Hello,

 I write about Node a lot, and I often illustrate concepts using tests.
 However, there isn't a standard test runner for Node.

 So, let's say I'm writing a book about Node.  I'd like to include examples
 using a test runner that's idiomatic, lightweight, and likely to be around
 in a year or two.  I'm thinking Mocha or Nodeunit might be a good idea.

 My projects from 2010-2011 seemed to use Nodeunit, and I've switched a few
 to Mocha with very little trouble.  Their APIs aren't directly compatible
 but the same concepts can be readily gleaned in both.

 Does anyone have any strong opinions about this? What test runner would
 you expect (or want) to see in books about Node?

 Thanks,

 Alex

 --
 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 / Google Feed API

2012-07-16 Thread Dominic Tarr
you need to post the error.

On Mon, Jul 16, 2012 at 9:55 PM, Florian Shena florian.sh...@gmail.com wrote:
 Hi everybody,

 I want to use the google feed API on my nodejs app. So far I've loaded the
 api using the Nodejs http.request but when I call google.load(feeds, 1)
 I get an error :

 var http = require('http');

 var options = {
   host: 'www.google.com',
   port: 80,
   path: '/jsapi',
   method: 'GET'
 };

 var req = http.request(options, function(res) {

   res.setEncoding('utf8');

   res.on('data', function (chunk) {
 console.log('BODY: ' + chunk.google.load(feeds, 1));
   });

   res.on('error', function(e) {
 console.log('problem with request: ' + e.message);
   });

 });

 --
 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


[node-dev] Stream tweaks proposal

2012-07-15 Thread Dominic Tarr
I've been writing and using a lot of streams lately,
and have some proposals for some small changes to node's streams.

https://gist.github.com/3117184

in some parts it's a tightening up on expected behaviour,
in others it's a few small changes to Stream#pipe.

cheers, Dominic


Re: [nodejs] ANN: mmmagic 0.2.0

2012-07-15 Thread Dominic Tarr
this would be really cool as a stream.

for the people too lazy to click on the link what this library does is
detect file type by reading a bit of it.

@mscdex is there a list of types that it can detect?

On Sun, Jul 15, 2012 at 2:06 PM, mscdex msc...@gmail.com wrote:
 For those interested, mmmagic 0.2.0 has been released. (Get it now via `npm
 install mmmagic`).

 After much wrangling, the highlights of this new and improved version
 include:

 * Libmagic now compiles on Windows under MSVC! No more bundled precompiled
 binaries!
 * GYP goodness all the way down!
 * The bundled magic database is now used by all OSes that do not have an
 existing magic database installed in any of the usual places. Previously,
 only Windows users enjoyed this feature.
 * Zlib requirement removed.
 * Support for Windows, Linux, Mac, and FreeBSD (all tested).

 mmmagic is an addon that lets you harness the power of the `file` command in
 your scripts without spinning up a child process!

 GitHub Repo: https://github.com/mscdex/mmmagic

 --
 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 to use node and npm commands after reboot

2012-07-15 Thread Dominic Tarr
You need to provide more details about what you did,
in order for someone to guess what might have gone wrong.

A link to what every script you used to install node.

A link is always good.

If you used something like nave then it creates node in a subshell and
won't work until you run the script again.



On Mon, Jul 16, 2012 at 12:36 PM, mscdex msc...@gmail.com wrote:
 On Sunday, July 15, 2012 6:26:46 AM UTC-4, raul112 wrote:

 I mean, I can't run command node myexample.js or any command like node
  because the bash say me bash: node can't find. Neither with npm
 command. But if I try reinstall, I get a error. I think I just have
 installed both but I can startup them after reboot.


 find / -type f -name node

 --
 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] Abnormal Exit

2012-07-15 Thread Dominic Tarr
you can throw anything in js, even an empty string.
(a good way to break a test framework)

would this work?

stderr.on('drain', function () {
  process.exit(1)
})

console.error('fail')

On Mon, Jul 16, 2012 at 6:18 AM, Alan Gutierrez a...@prettyrobots.com wrote:
 I'm writing command line utilities in Node.js. Here's a snippet that is
 a source of some concern for me.

 try {
   options = require('arguable')(__filename);
 } catch (error) {
   console.error('error: ' + e.message);
   console.error(e.usage);
   process.exit(1);
 }

 frobinate(options.severity);

 Essentially, I'm calling an options parser and finding errors that
 prevent me form continuing. I want to exit with a non-zero exit code.

 However, if I exit abruptly, I find that the console is not always
 flushed. Sometimes on Windows. Sometimes when piping stderr.

 I'm wondering when I can count on a flush of stderr before exit, when I
 can't, and what you feel is the right way to exit from a command line
 program, if you have any thoughts on the matter.

 Currently, I'm creating a main function, surrounding that in a try/catch
 block, and throwing special exceptions to indicate that the error does
 not involve a stack trace.

 --
 Alan Gutierrez - http://github.com/bigeasy - http://twitter.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

-- 
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] Abnormal Exit

2012-07-15 Thread Dominic Tarr
oh, you would have to assign the 'drain' listener after you've decided to exit.


On Mon, Jul 16, 2012 at 3:56 PM, Alan Gutierrez a...@prettyrobots.com wrote:
 On Mon, Jul 16, 2012 at 01:25:50PM +1200, Dominic Tarr wrote:
 On Mon, Jul 16, 2012 at 6:18 AM, Alan Gutierrez a...@prettyrobots.com 
 wrote:
  I'm writing command line utilities in Node.js. Here's a snippet that is
  a source of some concern for me.
 
  try {
options = require('arguable')(__filename);
  } catch (error) {
console.error('error: ' + e.message);
console.error(e.usage);
process.exit(1);
  }
 
  frobinate(options.severity);
 
  Essentially, I'm calling an options parser and finding errors that
  prevent me form continuing. I want to exit with a non-zero exit code.
 
  However, if I exit abruptly, I find that the console is not always
  flushed. Sometimes on Windows. Sometimes when piping stderr.
 
  I'm wondering when I can count on a flush of stderr before exit, when I
  can't, and what you feel is the right way to exit from a command line
  program, if you have any thoughts on the matter.
 
  Currently, I'm creating a main function, surrounding that in a try/catch
  block, and throwing special exceptions to indicate that the error does
  not involve a stack trace.

 you can throw anything in js, even an empty string.
 (a good way to break a test framework)

 would this work?

 stderr.on('drain', function () {
   process.exit(1)
 })

 console.error('fail')

 Wouldn't that abruptly exit the program the first time stderr drains? I
 imagine that it drains multiple times during the life of the program, if
 I write warnings while running.

 Currently, I'm doing...

   try {
 main();
   }  catch (e) {
 if (e.code != null  !isNaN(e.code))
   process.on('exit', function () { process.exit(e.code) });
 else
   throw e;
   }

 But, I'm trying to imagine situations where catching that error in that
 way will cause the program to keep on going, instead of petering out.

 --
 Alan Gutierrez - http://github.com/bigeasy - http://twitter.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

-- 
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] remoteable events

2012-07-13 Thread Dominic Tarr
I have a module that is just straight forward EventEmitter you just
pipe it through a stream,
so it works over any IO that is implemented as a stream. (which is
everything except UDP) for web sockets, use
https://github.com/substack/shoe

https://github.com/dominictarr/remote-events

On Fri, Jul 13, 2012 at 12:13 PM, Tim Caswell t...@creationix.com wrote:
 If you want multi-transport, freestyle rpc (with callbacks), then
 dnode-protocol (by substack) or smith (by me) are nice.

 https://github.com/substack/dnode-protocol/
 https://github.com/c9/smith

 On Thu, Jul 12, 2012 at 7:07 PM, Oliver Leics oliver.le...@gmail.com wrote:
 https://github.com/nodejitsu/nssocket/

 On Thu, Jul 12, 2012 at 10:50 PM, Matt hel...@gmail.com wrote:
 https://github.com/hookio/hook.io


 On Thu, Jul 12, 2012 at 4:07 PM, rektide rekt...@voodoowarez.com wrote:

 Hi nodejs group,

 Any suggestions for drop-in enhancements/replacements to EventEmitter
 which allow events to
 replicate cross-process or across different systems?

 Bonus points for anything that supports multiple transports!

 -rektide

 --
 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



 --
 Oliver Leics @ G+
 https://plus.google.com/112912441146721682527

 --
 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] Streams to and from Browser

2012-07-13 Thread Dominic Tarr
also see https://github.com/substack/shoe

it's a wrapper for SockJs (websockets, with fallbacks) that presents a Stream.

also useful is https://github.com/dominictarr/mux-demux which allows
you to multiplex streams through a single stream, so you can use
multiple streams through a single websocket connection.


On Fri, Jul 13, 2012 at 4:11 PM, Alan Gutierrez a...@prettyrobots.com wrote:
 On Thu, Jul 12, 2012 at 01:38:02PM -0700, Andrew Lunny wrote:
 On 12 July 2012 11:58, Alan Gutierrez a...@prettyrobots.com wrote:

  I could have swore I *just* saw a project that exposes the Stream API to
  the browser so that you can use things like `event-stream` on the
  browser to communicate with the server. It looked like it came out of
  NodeConf. I even think I bookmarked it.
 
  Or was it all a dream?
 
 https://github.com/maxogden/domnode is probably what you're thinking of.

 Yes, exactly. Thank you.

 --
 Alan Guterrez - @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

-- 
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] New module : VarStream

2012-07-11 Thread Dominic Tarr
you should adapt this to follow the node.js stream api.
nodejs.org/api/stream.html

then it'll be a lot more useful because it will be compatible with
every sort of io module in node. for example, then you'd be able to
just do this:
read from a file:
var scope = {}
fs.createReadStream(file).pipe(new VarStream(scope, true))
  .on('end', function () {console.log(scope)})

or write to a file

new VarStream(scope).pipe(fs.createWriteStream(file))

unfortunately, most websocket libraries do not follow the node.js
stream api (YET!).
but here is one: https://github.com/substack/shoe


On Tue, Jul 10, 2012 at 4:18 AM, Nicolas FROIDURE
nicolas.froid...@gmail.com wrote:
 A small message to inform you of the creations of a new module called
 VarStream and recently published in npm.

 The idea behind VarStream is to linearize variables to be able to read them
 inside a stream sequentially instead of wait the datas to be fully loaded
 like with JSON or XML. It also allows to merge multiple stream sources for
 more flexibility.

 VarStream is also human readable, allowing to use it as a configuration and
 localization file format.

 Here is the repository : https://github.com/nfroidure/VarStream
 Here is a proof of concept use case that use VarStreams to synchronize
 variables beetween clients using web sockets :
 https://github.com/nfroidure/WebSockIPC

 I would like to have advices on VarStreams and pull requests since i'm new
 to NodeJS, it probably needs some improvements.

 --
 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 pause or stop live streaming

2012-07-10 Thread Dominic Tarr
this question does not have enough information to answer it.

what modules/API/framework are you using to 'stream live' as you say?

I'm not familiar with socket.send(..) node uses socket.write(data) or
socket.pipe(stream)

On Tue, Jul 10, 2012 at 2:58 AM, Ket kettin...@gmail.com wrote:
 Hi guys,

 I've socket.send(something); to start streaming live. But what if I want to
 stop or pause sending withing leaving the web page.

 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] opening external editor from node

2012-07-08 Thread Dominic Tarr
substack has a module that does this
https://github.com/substack/node-editor

I haven't used it, but someone mentioned it, and this jogged my memory

On Sun, Jul 8, 2012 at 10:22 PM, Antoine van Wel
antoine.van@gmail.com wrote:
 You are right, when trying to open an editor which actually launches
 in a new window works fine.

 What's not working is when running under Linux from a terminal and try
 to open up vi which would run in the same terminal. I'm guessing all
 input/output is captured which should not happen here. It results in
 no editor being launched at all.


 Antoine

 On Sun, Jul 8, 2012 at 12:12 PM, Angel Java Lopez ajlopez2...@gmail.com 
 wrote:
 I just tried in Node REPL, Windows, and it worked fine. The editor is
 launched, and when I close the editor (nodepad++), the and we're back...
 message appears.

 What did you expect?

 On Sun, Jul 8, 2012 at 6:54 AM, Antoine van Wel antoine.van@gmail.com
 wrote:

 Hi,

 I'm programming a small command-line application and want to open up
 an external editor, and hand back control to node after the user exits
 the editor. Tried opening up vi with child_process.exec and .spawn but
 that did not quite do what I expected.

   1 var exec = require(child_process).exec;
   2
   3 var child = exec(vi /tmp/test, function(error, stdout, stderr) {
   4   console.log(and we're back...);
   5 });


 Any thoughts?


 Antoine

 --
 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] `close` event is emitted only when `server.connections === 0`

2012-07-08 Thread Dominic Tarr
it would actually be handy to be able to kill a server.
I want it simulating server chrashes when testing proxies.

On Mon, Jul 9, 2012 at 1:01 AM, Ben Noordhuis i...@bnoordhuis.nl wrote:
 On Sun, Jul 8, 2012 at 2:12 AM, Kilian C. kilian.ciuff...@gmail.com wrote:
 As I can see here: https://github.com/joyent/node/issues/1383
 The `close` event is emitted only when `server.connections === 0`

 While I can not understand motivations behind this, it would be great if
 someone could answer to this:
 How socket clients have to notice a server.close() call?

 Define 'socket client'?

 Should I manually loop through the sockets list and destroy them all?
 Without the close event this can be done only wrapping/overriding the close
 method.

 Am I totally wrong on this?
 --
 Kilian C.

 --
 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 extract values from the JSON data receiving

2012-07-07 Thread Dominic Tarr
var msg = JSON.parse(json)

On Sat, Jul 7, 2012 at 7:08 PM, Ket kettin...@gmail.com wrote:
 Hi I have this code when I send message:

 var msg = {
 name: userName,
 text: ABCD
  };
  var json = JSON.stringify({ type:'message', data: msg });
  socket.send(json);

 And here the code that receives the message:

 socket.addEventListener(message, function(event) {
  console.log (event.data);
 });

 Here's what it displays:

 {type:message,data:{name:userName,text:ABCD}}

 How do I make it display like this:

 userName
 ABCD

 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] Re: best practice for defining an interface

2012-07-06 Thread Dominic Tarr
interfaces are really only a tiny aspect of code correctness.
especially in evented programming, it's often essential that
say, a function callsback eventually, and only once.

for a Stream, or a more generic event emitter, it may be necessary
to assert that things happen in a particular order.
I'm experimenting with this currently.

maybe this can be considered like a 'temporal interface'?

On Sat, Jul 7, 2012 at 1:21 PM, Alexey Petrushin
alexey.petrus...@gmail.com wrote:
 Write executable specification is a good option.

 --
 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: Doing asynchronous processing before piping HTTP requests

2012-07-04 Thread Dominic Tarr
probably since express was written before 0.8 an so has the baken in
assumption that it doesn't buffer.

On Wed, Jul 4, 2012 at 7:58 PM, mark gocoffee...@gmail.com wrote:
 mh well, i tested it with an express server before, now tried it again
 with a pure node.httpServer und there it works, interesting must be
 something with express then

 On Jul 4, 8:29 am, mscdex msc...@gmail.com wrote:
 On Jul 4, 2:09 am, mark gocoffee...@gmail.com wrote:

  the data event after .pause() should stop emitting events? i just
  tried this and it still emits, i'am on node v 0.8.1

 What if you add your 'data' event handler _before_ calling
 req.pause() ?

 --
 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: many events transmitting small amounts of data compared to one final event transmitting all the data

2012-07-04 Thread Dominic Tarr
here is an even simpler option https://github.com/felixge/node-growing-file

it uses the approach @hasanyasin recommends, and exposes it as a stream.

On Thu, Jul 5, 2012 at 9:20 AM, mscdex msc...@gmail.com wrote:
 On Jul 4, 5:15 pm, mscdex msc...@gmail.com wrote:
 On Jul 4, 4:20 pm, hasanyasin hasanya...@gmail.com wrote:

  Did you take a look at the code example I gave? You do not need to use
  watch if your process is running and the file is being written constantly.
  For exact implementation of tail -f completely in Node, please take a look
  at the working code I had given the address for.

 IMHO it's best to use watchFile so that you don't perform a lot of
 unnecessary polling stat calls (especially synchronous ones).

 Using fs.open + fs.watchFile + fs.fstat + fs.read is probably your
 best bet.

 With regards to the linked stackoverflow example, it's best to avoid
 creating a new Buffer every time you read.

 You should also either: keep reading from the file while the current
 position is less than the last checked file size and avoid extra
 unnecessary stat calls until you are finished, or just read the whole
 delta (current file size - current position) from the get-go instead
 of one small chunk at a time.

 --
 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: Doing asynchronous processing before piping HTTP requests

2012-07-03 Thread Dominic Tarr
If you check the current documentation:

Issues an advisory signal to the underlying communication layer,
requesting that no further data be sent until resume() is called.

Note that, due to the advisory nature, certain streams will not be
paused immediately, and so 'data' events may be emitted for some
indeterminate period of time even after pause() is called. You may
wish to buffer such 'data' events.

http://nodejs.org/api/stream.html#stream_stream_pause

so, pause does not buffer. possibly changing to that behaviour will be
explored in 0.9

however, it is pretty simple to pipe to a buffering stream and then to
where every you want it, (i frequently use quite long chains of
streams).

if you copy the properties you are interested in (headers,
httpVersion, etc) to the next stream and most likely it will just
work.

cheers, Dominic

On Wed, Jul 4, 2012 at 10:41 AM, mscdex msc...@gmail.com wrote:
 On Jul 3, 5:49 pm, Domenic Denicola dome...@domenicdenicola.com
 wrote:
 Thanks very much for pointing this out; I didn't know we would get this in
 the 0.8 upgrade. Do you have any more details on the remaining piping
 issue? Marco, would you recommend calling this new `pause` over using a
 buffered stream?

 I can't find the link I saw originally, but there's a comment [1] made
 by mikeal awhile back that mentions it. You might try searching the
 node gh issues for 'pause' or something like that.

 The implementation for the new pause fix internally does buffering for
 any 'data' events that happen to make it in after the stream is
 paused. When you resume, it replays these events in order before
 emitting any new 'data' events.

 [1] 
 https://github.com/joyent/node/commit/e6b6075024e9f1330575b10d7e6552e1ea6dad56#commitcomment-939063

 --
 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] best practice for defining an interface

2012-07-03 Thread Dominic Tarr
I'd probably write a function that asserted that each object
implemented the right functions, and threw if something was wrong, and
then call that from each file. Most people would just put that in the
tests, however.

to take that to the next level, you could wrap functions with
functions that checked the argument/return types, and generated run
time errors. the checker could be disabled in production mode.
this approach is known as design by contract, it's not particularly
popular though.

I am writing a module for this https://github.com/dominictarr/macgyver
with the aim of using it to make assertions about the order, and
eventual occurrence of events, in streams for example.

but in general, simply having unit tests should probably suffice to
make sure your modules stay consistent.



On Mon, Jul 2, 2012 at 3:48 AM, Dave Horton d...@dchorton.com wrote:
 Since javascript provides no explicit support for the concept of interfaces
 (but, as always, probably a hundred ways to roll your own), what is the node
 best practice or recommendation for defining an interface?

 As background, I am building some node modules that will interwork with each
 other, yet be loosely coupled.  And I want to allow others to plug in new
 modules into this mini framework in the future.  So defining an abstract
 interface for some of the different sets of functionality seems to be a good
 way to go.  I have the use of utils.inherit, but I'm not looking for
 inheritence here so that is not the solution I want.  I want to be able to
 define interfaces, and then create objects which declaratively implement one
 or more interfaces.

 (I realize this is not a node question, per se, rather more of a generic JS
 question, but I think by pushing forward into the world of more complex
 server-side development node module developers would encounter this issue
 and I would like to be aware of and conform to what bp exist)

 --
 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: Doing asynchronous processing before piping HTTP requests

2012-07-03 Thread Dominic Tarr
@mscdex you are correct.

reading the code, in 0.8 http streams will not emit 'data' in the paused state.

https://github.com/joyent/node/blob/master/lib/http.js#L117-125

which has changed from 0.6

https://github.com/joyent/node/blob/v0.6/lib/http.js#L97-107


On Wed, Jul 4, 2012 at 5:13 PM, mscdex msc...@gmail.com wrote:
 On Jul 4, 12:24 am, Dominic Tarr dominic.t...@gmail.com wrote:
 http://nodejs.org/api/stream.html#stream_stream_pause

 so, pause does not buffer. possibly changing to that behaviour will be
 explored in 0.9

 That's for streams in general. Check the http core module and you'll
 see it uses a _pendings array to buffer 'data' events after pausing a
 request.

 --
 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: Wrap functions as streams (pipemaster)

2012-06-27 Thread Dominic Tarr
there is need for base classed with more of the holes filled in than
require('stream').Stream to make it easier to create streams.

it looks like this is what stream-stack is trying to achive,
but to be honest, I can't quite see how it is best used.

but maybe that is just because my approach is different.

I've had a lot of luck with this function:
https://github.com/dominictarr/event-stream#through-write-end

it just creates a stream that by default, calls this.emit('data', data)
on write, but you can pass in a custom write and end functions.

it takes care of a lot of stuff that Stream doesn't do, like handle
pause(), resume(), emits close after end() is called, and 'end' is
emitted.

it takes care of lots of little niggly stuff that needs to be done to
work right, but can be tricky to debug.

actually, that is the hardest thing about streams, testing them.
I'm experimenting along those lines with this:
https://github.com/dominictarr/event-stream#through-write-end

it's a declarative assertion lib, for making assertions about the
order of events/function invocations. the idea is to make it easy to
have a reusable thing that checks a stream never emits 'data' after
'end' or always eventually emits 'close', stuff like that.



On Wed, Jun 27, 2012 at 8:28 PM, Johnny Honestly
mostmodern...@gmail.com wrote:
 SWEET I got some question answered in this thread.

 Very helpful with the stream spec, thank you @dominic

 See also TooTallNate's https://github.com/TooTallNate/node-stream-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

-- 
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] Addon: Native vs JS?

2012-06-26 Thread Dominic Tarr
I have not written any C addons, but I do know that EventEmitter has
been removed from the C side of node.

a tight wrapper based on callbacks, and then wrap that with a Stream
api on the js side is indeed how node does it.

reading through github.com/joyent/node/blob/master/lib/fs.js should be helpful.

there is quite a bit to writing a Stream that works well.

I am developing a Stream spec here https://gist.github.com/2850882

I'm just building it from studying stream.js, reading code in node.js
core streams.

cheers, Dominic

On Wed, Jun 27, 2012 at 2:40 AM, Dan Søndergaard dan1...@gmail.com wrote:
 Hi,

 I'm trying to write my first node addon (I have no previous experience with
 C++ whatsoever). It's basically a wrapper for the PortAudio library.

 I started out thinking that I would do the whole thing in C++, but now I
 realize that it is very difficult to implement the EventListener and Stream
 interfaces in native code, which tells me that I should just write a very
 basic, direct wrapper to the library, and then build up a usable API in
 Javascript afterwards. Is this correct?

 Assuming that I'm going to write the exposed API in JS, how would I approach
 that?

 If it's possible to write the entire thing in C++, how do I then inherit
 EventListener and Stream?

 I apologize if the explanation is confusing, I'm still just trying to figure
 out the different layers of abstraction in node :-)

 Thanks,

 Dan

 --
 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: Sticky sessions using the new cluster API?

2012-06-26 Thread Dominic Tarr
I understand that the cluster api works by passing a file descriptor
to the worker process.

is it possible pass a file descriptor after you have started reading from it?

On Wed, Jun 27, 2012 at 9:30 AM, Isaac Schlueter i...@izs.me wrote:
 For sessions, I recommend using redis with redsess:
 https://github.com/isaacs/redsess

 On Tue, Jun 26, 2012 at 7:58 AM, Bradley Meck bradley.m...@gmail.com wrote:
 +1 for not including this, sticky sessions are painful when they become the
 least common denominator.


 On Tuesday, June 26, 2012 8:48:00 AM UTC-5, Ben Noordhuis wrote:

 On Tue, Jun 26, 2012 at 6:02 AM, dhruvbird dhruvb...@gmail.com wrote:
  Just saw the blog post introducing 0.8 and it seems that it's a
  conscious
  decision to leave sticky sessions out.

 That's correct.

 --
 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] Wrap functions as streams (pipemaster)

2012-06-23 Thread Dominic Tarr
I have a collection of functions similar to this here:

https://github.com/dominictarr/event-stream

you need to add `destroy`, and should add `pause` and `resume`.

this may be helpful: https://gist.github.com/2850882

it's my best effort at defining the correct behaviour for streams,
such that pipe will work correctly.
it's not official of course, its just constructed from
reading node/lib/stream.js and so on, and figuring it out.

cheers, Dominic

On Sat, Jun 23, 2012 at 10:23 PM, dolphin 278 dolphin...@gmail.com wrote:
 Good day

 I did not found any modules to easily wrap any function to stream interface,
 so i made my own. Point is to have an option to pipe streams to different
 filters and transformations, without describing stream interface from
 scratch every time.

 Usage:

 var FuncWrapper = require('pipemaster').FuncWrapper,
     streamFunc;
 function asyncExample(x, callback) {
    callback(null, x * x); // first argument is an optional error.
 }
 streamFunc = new FuncWrapper(asyncExample);
 streamFunc.write(2);  // streamFunc emits '4'
 streamFunc.write(6);  // streamFunc emits '36'


 There is another class for easy filtering, called StreamFilter for em, easy
 filtering :)

 var StreamFilter = require('pipemaster').StreamFilter,
     streamFunc;
 function filterAsync(item, callback) {
     callback(null, item === 4);
 }
 streamFunc = new StreamFilter(filterAsync, true);
 streamFunc.write(1);
 streamFunc.write(4);
 streamFunc.write(2);
 // streamFunc emits only '4'


 Installation, as always - npm install pipemaster, github link
 - https://github.com/dolphin278/pipemaster/

 Hope it would be helpful for someone :)
 --
 Boris Egorov
 skype/gtalk/nickname: dolphin278
 mobile: +7 905 728 1543

 --
 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] Wrap functions as streams (pipemaster)

2012-06-23 Thread Dominic Tarr
there is a bug in your ReduceStream.
streams are immutable, so you'll need be able to return the new total.
modifying it will create a new string.

in all my messing around with this stuff, the most useful function
I've made is this:

https://github.com/dominictarr/event-stream/blob/master/index.js#L17-71

it just creates a simple ReadableWritableStream, and you can pass in
custom write and end functions. sensible default implementations of
pause, resume, and destroy are included.

it sets writable and readable for you, and always emits 'close' etc.

I'm in the process of refactoring the rest of my stream functions to
be interms of es.through()

On Sun, Jun 24, 2012 at 12:20 AM, José F. Romaniello
jfromanie...@gmail.com wrote:
 I started something like this few weeks ago nothing there yet but the readme
 file ( readme driven development).

 https://github.com/jfromaniello/funstream



 El sábado, 23 de junio de 2012, dolphin 278 escribió:

 Thanks for your reply Dominic i am in the middle of implementing those
 functions. I'll use your information. Thanks again.
 -
 Boris Egorov
 skype/gtalk/nickname: dolphin278
 mobile: +7 905 728 1543


 On Sat, Jun 23, 2012 at 3:24 PM, Dominic Tarr dominic.t...@gmail.com
 wrote:

 I have a collection of functions similar to this here:

 https://github.com/dominictarr/event-stream

 you need to add `destroy`, and should add `pause` and `resume`.

 this may be helpful: https://gist.github.com/2850882

 it's my best effort at defining the correct behaviour for streams,
 such that pipe will work correctly.
 it's not official of course, its just constructed from
 reading node/lib/stream.js and so on, and figuring it out.

 cheers, Dominic

 On Sat, Jun 23, 2012 at 10:23 PM, dolphin 278 dolphin...@gmail.com
 wrote:
  Good day
 
  I did not found any modules to easily wrap any function to stream
  interface,
  so i made my own. Point is to have an option to pipe streams to
  different
  filters and transformations, without describing stream interface from
  scratch every time.
 
  Usage:
 
  var FuncWrapper = require('pipemaster').FuncWrapper,
      streamFunc;
  function asyncExample(x, callback) {
     callback(null, x * x); // first argument is an optional error.
  }
  streamFunc = new FuncWrapper(asyncExample);
  streamFunc.write(2);  // streamFunc emits '4'
  streamFunc.write(6);  // streamFunc emits '36'
 
 
  There is another class for easy filtering, called StreamFilter for em,
  easy
  filtering :)
 
  var StreamFilter = require('pipemaster').StreamFilter,
      streamFunc;
  function filterAsync(item, callback) {
      callback(null, item === 4);
  }
  streamFunc = new StreamFilter(filterAsync, true);
  streamFunc.write(1);
  streamFunc.write(4);
  streamFunc.write(2);
  // streamFunc emits only '4'
 
 
  Installation, as always - npm install pipemaster, github link
  - https://github.com/dolphin278/pipemaster/
 
  Hope it would be helpful for someone :)
  --
  Boris Egorov
  skype/gtalk/nickname: dolphin278
  mobile: +7 905 728 1543
 
  --
  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: Closures versus Prototypes for Flow Control

2012-06-23 Thread Dominic Tarr
@alan no problem!
@brandon, I stand corrected. near-hit is more accurate!

On Sat, Jun 23, 2012 at 6:07 AM, Alan Gutierrez a...@prettyrobots.com wrote:
 On Fri, Jun 22, 2012 at 04:21:00AM +1200, Dominic Tarr wrote:
 also, this is control flow, not flow control.

 This near collision in nomenclature is most unfortunate, but control flow
 refers to the transference of control from one phase to the next. (this is 
 the
 case you are discussing)

 flow control refers to controling rates of (eg, data) flow through a 
 system.
 Quite a different concept but also important in node -- when it comes to
 streaming.

 I really hate to be this anal, but it's just that I streams are a really 
 great
 aspect of node and the more people that understand them the better, therefore
 I want to be as clear as possible.

 Thank you for correcting me in the nicest way possible. I appreciate the
 correction. I'm happy to learn the correct the nomenclature. I might even 
 start
 to sound like I know what I'm talking about.

 --
 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

-- 
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] Wrap functions as streams (pipemaster)

2012-06-23 Thread Dominic Tarr
not sure if useful though

haha, I wrote that, tested it. (although not with stream interface,
but I could add that easy)

...but never used it.

https://github.com/dominictarr/reducer

I was wanting to make it continuous, so that you could update an item
later, and it would reupdate the total... and have it periodically
emit the result, so that each update you emit the new total.

of course that does require you to remember all the inputs.

maybe it would be useful for aggregating stats out of logs, something
like that...

On Sun, Jun 24, 2012 at 9:08 AM, José F. Romaniello
jfromanie...@gmail.com wrote:
 Excellent Dominic, yes! The idea of reduce ( idea, 0 code) was to make a
 readable/writeable stream. For each chunk passed to the reduce, it will
 execute the reduce function, when the input stream ends it will the reduce
 stream will emit one and only one data event with the value of the
 accumulator and it will ends. The example i wrote is totally wrong and
 should be


 var aFileStream = fs.createReadStream(foo.txt);
 aFileStream.pipe(funs.reduce( function (prev, chunk) { return prev +
 chunk.match(/o/g).length; }))
              .pipe(funs.map( function (total) { return  total amoun of 'o':
  + total; }))
              .pipe(process.stdout);

 Not sure if is useful though

 --
 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: using modules that are being used by modules

2012-06-23 Thread Dominic Tarr
npm is actually quite smart about this,
if app and swig both have underscore in thier package.json it will
install like this

after a fresh install, if they depend on the same version of underscore

app/node_modules/swig
app/node_modules/underscore

or if they need different versions it will be like this:

app/node_modules/swig
app/node_modules/swig/node_modules/underscore
app/node_modules/underscore

here swig gets it's own version.
this is a really great way to do it because prevents dependency hell.
which means, you can break your api, and wont break people's apps,
as long as you use module versions correctly.


On Sun, Jun 24, 2012 at 2:13 PM, Angelo Chen angelochen...@gmail.com wrote:
 right, thanks.

 On Jun 24, 10:10 am, Ryan Schmidt google-2...@ryandesign.com wrote:
 On Jun 23, 2012, at 21:04, Angelo Chen wrote:

  I use swig in my node app, and I know swig uses underscore, do i have
  to npm install underscore, or just use the one being used by swig?

 Install your own copy of underscore and use that. Do not rely on internal 
 details of modules that might change in the future (i.e. do not rely on the 
 fact that swig uses underscore today, because it might not do so tomorrow, 
 or it might change to a different version of underscore with which your code 
 is not compatible).

 --
 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: Closures versus Prototypes for Flow Control

2012-06-21 Thread Dominic Tarr
also, this is control flow, not flow control.

This near collision in nomenclature is most unfortunate,
but control flow refers to the transference of control from one
phase to the next.
(this is the case you are discussing)

flow control refers to controling rates of (eg, data) flow through a system.
Quite a different concept but also important in node -- when it comes
to streaming.

I really hate to be this anal, but it's just that I streams are a
really great aspect of node
and the more people that understand them the better, therefore I want
to be as clear as possible.



On Thu, Jun 21, 2012 at 11:30 PM, Mariusz Nowak mari...@medikoo.com wrote:
 Alan, we use asynchronous programming for tasks that take time, so in that
 case, whether we wrap such tasks with closure or prototype solution wouldn't
 make difference in performance. I think debating on performance in that case
 is pointless.

 As a side node be sure to check also deferred/promises concept, it's much
 more powerful than callbacks when dealing with complicated asynchronous
 flow.


 On Wednesday, June 20, 2012 2:33:41 PM UTC+2, Alan Gutierrez wrote:

 The right way of coding nodejs applications prompts me to post some
 benchmarks
 I was playing with a few days ago to answer this very question.

 My benchmarks looked at the performance of using closures for asynchronous
 flow
 control, where you are creating closures with each function call.

 A common model for flow control is to use closures. Here is an example
 from the
 delightful little `Step` library by Tim Caswell.

     Step(
       function readSelf() {
         fs.readFile(__filename, this);
       },
       function capitalize(err, text) {
         if (err) throw err;
         return text.toUpperCase();
       },
       function showIt(err, newText) {
         if (err) throw err;
         console.log(newText);
       }
     );

 I wanted to see how the creation of closures at function invocation would
 compare to the use of an object, where the steps would be object member
 functions and state would be preserved in `this`. Maybe creating an object
 would
 be faster since the member functions are already created, they only need
 to be
 assigned.

 I created a JSPerf that tested closures versus prototypes for this use
 case.

 http://jsperf.com/flow-control/3

 The tests are not asynchronous. I only want to test the cost of creating
 the
 closures versus creating the object and fussing with `this`.

 Each function sums an array after after first popping the last element.
 The pop
 is one step. The sum is another. There is no external flow control. The
 popper
 function calls the sum function when it is done.

 Looks like the prototype method might be slightly faster, but not fast
 enough to
 make me want to explore using object member functions for flow control
 when
 closures are familiar and easy to read.

 Rough Edges

 I did find an interesting case where if you assign a method to an object
 member,
 as you might do during object creation, performance drops dramatically.
 This can
 be seen in Closure assigned to object property and Closure assigned to
 object
 property, not called.

 However, you can make the problem go away if you assign the function to a
 variable, then assign the property using the function name. This can be
 seen in
 Closure assigned to object property via variable.

 Also, performance in Firefox 13 is a different story. Using an object to
 model
 flow is all kinds of faster.

 Conclusions

 Maybe closures are a work in progress with a few gotchas, but it's
 probably not
 worth my time to create a convoluted new async pattern to second-guess V8.

 --
 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

-- 
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: The right way of coding nodejs applications: functional or string Object Oriented ?

2012-06-20 Thread Dominic Tarr
prototype chains and closure scopes actually work in a precisely similar way.

this gist gives some examples of identical structures created with
scopes and prototypes.

https://gist.github.com/2904285


On Thu, Jun 21, 2012 at 7:34 AM, P. Douglas Reeder reeder...@gmail.com wrote:
 Use the style that your team find most natural for the problem you're 
 solving.  That will make it easier to fix bugs and add enhancements.

 If profiling shows one part of your app is the bottleneck, consider rewriting 
 it.

 Other problems may make other styles more appropriate.

 --
 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: JSON5: modern JSON

2012-06-15 Thread Dominic Tarr
that is what I meant by usually

On Fri, Jun 15, 2012 at 1:29 AM, Alexey Petrushin
alexey.petrus...@gmail.com wrote:
 If you really need a comment in JSON you can usually just use a ignored
 field:
 Except if You iterate 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

-- 
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] crazy ideas in proxing.

2012-06-15 Thread Dominic Tarr
so,

For a while I've been wondering, could I make a *really* simple proxy?

Although in http 1.1 multiple requests may be made in the same tcp
connection, a well behaved client is not allowed
to make requests to different hosts in the same connection, so this
begs the question: is it necessary to properly parse http?
as long as you can parse the first header, and then connect the tcp
stream to the right place... then every thing should just work,
including WebSockets.

It was marak who originally suggested this idea to me.

so, today I actually tried it... and it looks like: IT WORKED!!!

https://github.com/dominictarr/badass

npm install badass

I've implemented just enough to make a load-balancer with sticky
sessions. basically it just matches the text before the first empty
line. pulls out the headers with a few regexps, and then just sends
the rest through as buffers. it also extracts the first header on the
response, so you can force a cookie to get sticky sessions.

it's only about 100 lines, and it does next to nothing to the tcp
stream, so it should be really fast.

but I havn't benchmarked it yet.

also, I havn't written a detailed test suite that cover all the error paths.
(connections unexpectedly closing etc)

There are some things that will never do, like, deliver it's own error messages.
But thats okay. I'm trying to be ruthlessly simple.
If you want a fully featured proxy, use something else.

cheers, Dominic

-- 
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: Best use cases for Node.JS

2012-06-15 Thread Dominic Tarr
and, of course, you get to run javascript on both the client and the server.

which is a very interesting advantage in some cases.

such as architectures where the client is 'just another node'.

On Sat, Jun 16, 2012 at 2:33 AM, Fadrizul H fadri...@gmail.com wrote:
 Lol stop spamming. Anyways, Nodejs is great for not only web platforms. Also
 for heavy network io interactions such as mobile apps, single page apps and
 etc.

 On Jun 15, 2012 10:30 PM, alFReD NSH farid...@googlemail.com wrote:

 This is a great article about this subject:
 http://nodeguide.com/convincing_the_boss.html

 --
 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: Unloading a module from require

2012-06-15 Thread Dominic Tarr
what you _could_ do, is instrument the code by parsing and inserting
additional calls.
with this technique you can add counters that make it safe to run
untrusted code.

so you can prevent things like: while (true);

which would loop forever. you could also use this technique to abort
any io operation,
and to clearTimeout etc.

of course, most people are not crazy enough to pull something like this off.

you need to be a bit of a mad scientist.

like substack!
https://github.com/substack/node-falafel
https://github.com/substack/node-stackedy



On Fri, Jun 15, 2012 at 3:18 AM, mgutz mario.l.gutier...@gmail.com wrote:
 In our case, our xml builder like templates are javascript modules loaded
 via require. Templates in development mode should not be cached. `delete
 require.cache` works for us.

 On Thursday, June 14, 2012 1:12:20 AM UTC-7, Dan Milon wrote:

 What is the use case of unloading a module?

 On 06/14/2012 10:02 AM, yogesh agrawal wrote:
  delete require.cache is not good way to unload.
 
  Some times module doesn't get unloaded after deleting it from cache.
  Modules api lacks unload method :(
 
  On Thu, Jun 14, 2012 at 11:28 AM, Ben thebucks...@gmail.com
  mailto:thebucks...@gmail.com wrote:
 
      I'm interested in this question too. I tried it once, but all the
      async operations started by the modules remained active even after
      unloading it. Try for example a simple setInterval() that writes
      something to the log every second, in the module - when you unload
      the module, the timer is still running.
 
      Is there a better way to do it?
 
 
 
      On Wednesday, June 13, 2012 4:40:55 PM UTC-3, Andrew Finnell wrote:
 
          I did some research in the group and it appears someone had a
          similar question about unloading modules that were loaded with
          require.
 
          Am I correct in reading that the use of nodules would allow me
          to require('./module1') then dump the entire contents of that
          module programmaticly at a later time? Then reload it if I
          felt like it, all within the same node 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
      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
 
 
 
 
  --
  Yogesh Agrawal
  +91-9351507770
  --
  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] crazy ideas in proxing.

2012-06-15 Thread Dominic Tarr
actually, bouncy started out very much like this, but ended up parsing
http properly.

On Sat, Jun 16, 2012 at 3:17 AM, Nathan Rajlich nat...@tootallnate.net wrote:
 Sounds a lot like SubStack's bouncy: https://github.com/substack/bouncy

 Very cool nonetheless!

 On Fri, Jun 15, 2012 at 6:45 AM, Dominic Tarr dominic.t...@gmail.com
 wrote:

 so,

 For a while I've been wondering, could I make a *really* simple proxy?

 Although in http 1.1 multiple requests may be made in the same tcp
 connection, a well behaved client is not allowed
 to make requests to different hosts in the same connection, so this
 begs the question: is it necessary to properly parse http?
 as long as you can parse the first header, and then connect the tcp
 stream to the right place... then every thing should just work,
 including WebSockets.

 It was marak who originally suggested this idea to me.

 so, today I actually tried it... and it looks like: IT WORKED!!!

 https://github.com/dominictarr/badass

 npm install badass

 I've implemented just enough to make a load-balancer with sticky
 sessions. basically it just matches the text before the first empty
 line. pulls out the headers with a few regexps, and then just sends
 the rest through as buffers. it also extracts the first header on the
 response, so you can force a cookie to get sticky sessions.

 it's only about 100 lines, and it does next to nothing to the tcp
 stream, so it should be really fast.

 but I havn't benchmarked it yet.

 also, I havn't written a detailed test suite that cover all the error
 paths.
 (connections unexpectedly closing etc)

 There are some things that will never do, like, deliver it's own error
 messages.
 But thats okay. I'm trying to be ruthlessly simple.
 If you want a fully featured proxy, use something else.

 cheers, Dominic

 --
 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: crazy ideas in proxing.

2012-06-15 Thread Dominic Tarr
On Sat, Jun 16, 2012 at 6:51 AM, Joshua Holbrook
josh.holbr...@gmail.com wrote:
 What made substack change tactics?

 This:

 Although in http 1.1 multiple requests may be made in the same tcp
 connection, a well behaved client is not allowed
 to make requests to different hosts in the same connection

 That is, multiple requests on the same tcp connection was desirable
 for Sub. Dominic, however, isn't supporting that for the sake of
 simplicity.

sorry, this is wrong, maybe I wasn't clear. multiple requests can
still come through on the same connection, but the limitation is that
only the headers of the FIRST request are parsed and modifyable.

the rest of the requests will just go to the same place that you sent
the first one, but there is no support for altering them.

-- 
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: crazy ideas in proxing.

2012-06-15 Thread Dominic Tarr
On Sat, Jun 16, 2012 at 9:08 AM, Tim Dickinson price.ti...@gmail.com wrote:
 I think callback style is better then just returning values for the host and
 port. If hostname is stored in a database then you might run into problems.

This is by design. It's not very good load-balancing if you have to
do another network round trip to know where to send a message.

You are probably only balancing to tens, or maybe hundreds of servers.
that is well within the bounds of nodejs in-memory data. If you have
the data at hand, then you can respond immediately.

If your servers are stored in a database like couch, then you might
listen on the couchdb changes feed to keep an up to date in memory
store. I wish more databases had apis like the couchdb changes feed.

-- 
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: JSON5: modern JSON

2012-06-14 Thread Dominic Tarr
if you really need a comment in JSON you can usually just use a ignored field:

{
  REM: ugly, but this will be ignored,
  name: modulename
}

pays to have glanced at, or written the thing that reads this though.


On Thu, Jun 14, 2012 at 6:07 PM, Oleg Efimov (Sannis)
efimo...@gmail.com wrote:
 As I know, XML spec does not describe single format for arrays/maps
 representation. There is more other things in YAML that odes not exist in
 XML.

 Especially for human-readable configs YAML looks pretty good.

 четверг, 14 июня 2012 г., 4:38:55 UTC+4 пользователь Matt Sergeant написал:

 On Wed, Jun 13, 2012 at 4:46 PM, trans transf...@gmail.com wrote:

 Well, the later statement isn't really true. YAML is certainly more
 complex than JSON. And that's b/c it 1) caters to human readability and
 editability and 2) is a full serialization format. But it's not more complex
 than XML by any means.


 YAML Spec: http://www.yaml.org/spec/1.2/spec.html - 89 Pages.

 XML Spec: http://www.w3.org/TR/REC-xml/ - 36 Pages.

 You were saying?

 --
 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] Stream on 'close' event

2012-06-01 Thread Dominic Tarr
that sounds very reasonable

I pretty much never call write directly. I always let pipe do that for
me, and pipe cleans up after close, so that would work. and write will
never be called after 'close'.

I've been extremely enthusiastic about the Stream api for nearly a
year now, but have only just realized the purpose of 'close'.

I've written an informal spec up here, based on my understanding of
`Stream` and `pipe`

https://gist.github.com/2850882

I am just trying to document what a user stream must implement in
order to fully work with Steam#pipe, so this is a tad more general
than http://nodejs.org/api/stream.html

comments appreciated.

On Fri, Jun 1, 2012 at 7:57 PM, Axel Kittenberger axk...@gmail.com wrote:
 I'm not too much into the node specifics of streams, but I say.

 If its an expected end, call close.
 If its an unexpected end, call error then close,
 if someone calls write after close, throw an error. Since this should
 never happen in a correctly written application, if its okay it
 terminates if this is not catched.

 On Fri, Jun 1, 2012 at 7:54 AM, Dominic Tarr dominic.t...@gmail.com wrote:
 what should a writable stream do if it's underlieing communication layer 
 closes?
 I see that .pipe listens on the end event of both source and dest streams,

 https://github.com/joyent/node/blob/master/lib/stream.js#L109

 what should the WritableStream do if write is called after 'close' is
 emitted? emit an 'error'?

 how should someone writing to a stream know that the stream is closed?
 listen on 'close'? or 'error'? or check stream.writable befor writing?

 what is the best way?

 cheers, Dominic

 --
 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


[nodejs] Stream on 'close' event

2012-05-31 Thread Dominic Tarr
what should a writable stream do if it's underlieing communication layer closes?
I see that .pipe listens on the end event of both source and dest streams,

https://github.com/joyent/node/blob/master/lib/stream.js#L109

what should the WritableStream do if write is called after 'close' is
emitted? emit an 'error'?

how should someone writing to a stream know that the stream is closed?
listen on 'close'? or 'error'? or check stream.writable befor writing?

what is the best way?

cheers, Dominic

-- 
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: JSON5: modern JSON

2012-05-29 Thread Dominic Tarr
eval isn't evil, but it has potential for evil. using eval in for
configuration files is not bad, because you know what they contain,
after all, you are editing them by hand.

if you are sending JSON5 or eval'd js remotely that is probably a bad idea.

On Tue, May 29, 2012 at 4:24 PM, Dick Hardt dick.ha...@gmail.com wrote:

 On May 28, 2012, at 6:35 PM, Arunoda Susiripala wrote:

 Why do you need serialization for Date.
 Just save the timestamp.

 Easier to hand edit which was one of the goals of this project.

 --
 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: callbacks vs. streams

2012-04-28 Thread Dominic Tarr
There is one very good reason for using streams in a case like this,
that no one has mentioned yet.

First, lets just suppose that N is very large.
Also lets generate primes in nextTick so that it never blocks for very long.

And the thing that consume's the primes (data) only needs one at a time.

There could be a variety of reasons for this. one might be that it's
serializing them as a web service.

Now, streams have a cool feature that EventEmitters do not have.
pause()/resume()

Like streams, TCP also has pause. If the pipe is congested or packets
are being dropped
TCP actually slows down a bit.

So if you've made PrimeStream respect pause/resume then it will only
go as fast as the bottleneck (tcp) can handle them!

you can't do that will callbacks.

a callback might be fine if I only want N  ~500 but what if I want
billions and billions of primes?

what if I didn't know how many primes I want. I could just say give me
ALL the primes!
(N = Infinity) and then close the connection when I'm satisfied.

Another benefit of using streams is that you don't need to keep
everything in memory.
you can upload a file that is larger than your ram with streams (I
think you might need to keep a list of primes to calc the next prime,
so this benefit doesn't apply to this case)

in summary, use streams if:
  * you can start using the data before you have received everything.
  * you would like to be able to throttle the rate something is produced.

usually this is IO related. although, if you have I -- O it may make
sense to keep the _through_ part in the shape of a stream also.

use callbacks if:
  * you can't do the next thing until after a thing is done.
  * you need the whole thing.

example: create a driectory, delete a file. parse a JSON document
(note, if the document is LARGE and list like, it may make sense to
stream it)

use an EventEmitter if:
  * many things will happen
  * things will happen more than once.
  * multiple listeners may be interested in an event.

note: createServer(function (req, res) {...
is not a callback, because callbacks ALWAYS have err as the first argument.
as pointed out above. it's an event listener. which has no error argument.



On Sat, Apr 28, 2012 at 10:23 PM, Oliver Leics oliver.le...@gmail.com wrote:
 As i see it: We have a prime number generator that constantly *emits*
 prime numbers. This is a *stream* of prime numbers. Thus: Use
 stream.Stream.

 IMHO implementing this as a stream it is not over-engineered. For me
 it is the optimum way as streams provides a standard method for
 everything emitting data. It makes it very easy to hook into that
 stream of data and do whatever needs to be done with that prime
 numbers. I do not have to read lots of API documentation. All i need
 to know: It is a standard node stream of data.

 BTW: I'm writing this as i recently added 'lazy' to my toolbelt of
 indispensable node modules.

 On Sat, Apr 28, 2012 at 12:04 PM, Jorge jo...@jorgechamorro.com wrote:
 Hi Bruno,

 On Apr 28, 2012, at 11:14 AM, Bruno Jouhier wrote:

 Neither!

 I think that question should be callbacks vs. events vs. streams:
       • Callback: called only once, when the function is done, to return 
 result (optional) or error.
       • Event: called repeatedly by the function to notify its listeners. 
 Can be used to send intermediate results as they come.
       • Stream: higher level concept based on events, with standardized 
 event types (data, end, error, drain) and standardized API (pause, resume, 
 write, ..).
 So, assuming prime computation is asynchronous:

       • If the function computes the N first primes and returns them all at 
 once, it should use a callback.
       • If the function returns the primes one by one, it should use 
 events. It may also use a stream but that seems a bit over-engineered.


 Good, yes, that's the way it is in node, but it does not explain *why* it is 
 so.

 .readFile() could as well deliver the chunks to the cb as they're read from 
 disk, and to use it you'd need to write just one line:

 fs.readFile(path, cb);

 While to do the same with an evented interface there's a lot of boilerplate 
 to write, and an extra object to create:

 reader= new fileReaderConstructor(path);
 reader.on('data', cb);
 reader.on('end', endCB);
 reader.on('error', errorCB);

 It seems to me that the former is more functional and makes good use of 
 closures (*), while the latter is the approach a classic OOP programmer 
 would tend to write instead.

 (*)In JavaScript we don't need to create objects to save state.
 --
 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
 

Re: [nodejs] Question: Misuse of variables bound to exports object?

2012-04-28 Thread Dominic Tarr
it's a bit ugly i guess, but there is nothing wrong with it.

that it's named exports tells you quite a lot actually.


On Sat, Apr 28, 2012 at 4:54 PM, akira nhy...@googlemail.com wrote:
 I am sorry if this is not node related, I just thought this might be a
 good place to ask since a lot of module developers are on this list.

 Using this simple example, I would like to inherit a form

 exports.EmailForm = forms.Form.extend({
    email_address  : forms.EmailField({required: true})
 })

 exports.ExtendedEmailForm = exports.EmailForm.extend({ // - Extending
 EmailForm
    subject    : forms.CharField({maxLength: 100})
    , message  : forms.CharField()
    , sender   : forms.EmailField({required: true})
 })


 Is this a misuse? It works, but normally one would do something like
 this:

 var EmailForm = forms.Form.extend({
    email_address  : forms.EmailField({required: true})
 })


 But I would like to export the simple EmailForm class for usage in
 other modules too. 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] Re: callbacks vs. streams

2012-04-28 Thread Dominic Tarr
oh, forgot something about event listeners:

  unlike callbacks, you can decide when you are no longer interested

oh, I just reread the original message where you are talking about
calling the callback multiple times. that is what streams are for. a
callback should never callback twice. those bugs can be really hard to
find.

example, what is wrong with this code:

function parseJson (file, cb) {
  fs.readFile(fileName, function (err, data) {
if(err) return cb(err);
try { cb(null, JSON.parse(data)); }
catch (err) { cb(err); }
  });
}

?

On Sat, Apr 28, 2012 at 11:10 PM, Dominic Tarr dominic.t...@gmail.com wrote:
 There is one very good reason for using streams in a case like this,
 that no one has mentioned yet.

 First, lets just suppose that N is very large.
 Also lets generate primes in nextTick so that it never blocks for very long.

 And the thing that consume's the primes (data) only needs one at a time.

 There could be a variety of reasons for this. one might be that it's
 serializing them as a web service.

 Now, streams have a cool feature that EventEmitters do not have.
 pause()/resume()

 Like streams, TCP also has pause. If the pipe is congested or packets
 are being dropped
 TCP actually slows down a bit.

 So if you've made PrimeStream respect pause/resume then it will only
 go as fast as the bottleneck (tcp) can handle them!

 you can't do that will callbacks.

 a callback might be fine if I only want N  ~500 but what if I want
 billions and billions of primes?

 what if I didn't know how many primes I want. I could just say give me
 ALL the primes!
 (N = Infinity) and then close the connection when I'm satisfied.

 Another benefit of using streams is that you don't need to keep
 everything in memory.
 you can upload a file that is larger than your ram with streams (I
 think you might need to keep a list of primes to calc the next prime,
 so this benefit doesn't apply to this case)

 in summary, use streams if:
  * you can start using the data before you have received everything.
  * you would like to be able to throttle the rate something is produced.

 usually this is IO related. although, if you have I -- O it may make
 sense to keep the _through_ part in the shape of a stream also.

 use callbacks if:
  * you can't do the next thing until after a thing is done.
  * you need the whole thing.

 example: create a driectory, delete a file. parse a JSON document
 (note, if the document is LARGE and list like, it may make sense to
 stream it)

 use an EventEmitter if:
  * many things will happen
  * things will happen more than once.
  * multiple listeners may be interested in an event.

 note: createServer(function (req, res) {...
 is not a callback, because callbacks ALWAYS have err as the first argument.
 as pointed out above. it's an event listener. which has no error argument.



 On Sat, Apr 28, 2012 at 10:23 PM, Oliver Leics oliver.le...@gmail.com wrote:
 As i see it: We have a prime number generator that constantly *emits*
 prime numbers. This is a *stream* of prime numbers. Thus: Use
 stream.Stream.

 IMHO implementing this as a stream it is not over-engineered. For me
 it is the optimum way as streams provides a standard method for
 everything emitting data. It makes it very easy to hook into that
 stream of data and do whatever needs to be done with that prime
 numbers. I do not have to read lots of API documentation. All i need
 to know: It is a standard node stream of data.

 BTW: I'm writing this as i recently added 'lazy' to my toolbelt of
 indispensable node modules.

 On Sat, Apr 28, 2012 at 12:04 PM, Jorge jo...@jorgechamorro.com wrote:
 Hi Bruno,

 On Apr 28, 2012, at 11:14 AM, Bruno Jouhier wrote:

 Neither!

 I think that question should be callbacks vs. events vs. streams:
       • Callback: called only once, when the function is done, to return 
 result (optional) or error.
       • Event: called repeatedly by the function to notify its listeners. 
 Can be used to send intermediate results as they come.
       • Stream: higher level concept based on events, with standardized 
 event types (data, end, error, drain) and standardized API (pause, resume, 
 write, ..).
 So, assuming prime computation is asynchronous:

       • If the function computes the N first primes and returns them all 
 at once, it should use a callback.
       • If the function returns the primes one by one, it should use 
 events. It may also use a stream but that seems a bit over-engineered.


 Good, yes, that's the way it is in node, but it does not explain *why* it 
 is so.

 .readFile() could as well deliver the chunks to the cb as they're read from 
 disk, and to use it you'd need to write just one line:

 fs.readFile(path, cb);

 While to do the same with an evented interface there's a lot of boilerplate 
 to write, and an extra object to create:

 reader= new fileReaderConstructor(path);
 reader.on('data', cb);
 reader.on('end', endCB);
 reader.on('error', errorCB);

 It seems

Re: [nodejs] Re: callbacks vs. streams

2012-04-28 Thread Dominic Tarr
oops,

s/file/fileName

... that is the easy to find bug, but there is another one lurking...

On Sun, Apr 29, 2012 at 12:01 AM, Oliver Leics oliver.le...@gmail.com wrote:
 On Sat, Apr 28, 2012 at 1:58 PM, Dominic Tarr dominic.t...@gmail.com wrote:
 example, what is wrong with this code:

 function parseJson (file, cb) {
  fs.readFile(fileName, function (err, data) {
    if(err) return cb(err);
    try { cb(null, JSON.parse(data)); }
    catch (err) { cb(err); }
  });
 }

 ?

 Throws, as fileName will be undefined :-P

 --
 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: callbacks vs. streams

2012-04-28 Thread Dominic Tarr
@jorge

exactly. that means that you callback both succeed and failed.

On Sun, Apr 29, 2012 at 12:41 AM, Lothar Pfeiler
lpfei...@googlemail.com wrote:
 ... just clicked the send button too early.

 I use streams if the expected data is big and I want the memory
 consumption to be low. Meaning, Please interrupt me, and give me
 small chunks, because I couldn't handle the big response.

 Lothar

 On Apr 28, 10:15 am, Lothar Pfeiler lpfei...@googlemail.com wrote:
 I understand the philosophy of using callbacks as Please call me
 back, when the job is done. Meaning, call me back after calculating
 all prime numbers. (avoid roundtrips)

 I understand the event emitter philosophy as Please interrupt me all
 the time you have news for me. Meaning, interrupt me for every single
 prime number. (lots of roundtrips, because I want to show the most
 current state all the time)

 So, a PrimeNumberGenerator could offer both versions for every
 purpose. And every single app might have a different understanding of
 the job size (or chunk size) and what are the news. So, the question
 for the app (which uses the PNG)  would be, whether it wants to act on
 every event or just act on a final result.

 Lothar

 On Apr 28, 6:20 am, Mark Hahn m...@hahnca.com wrote:







  How can it be sugar?  It isn't compiled into anything else.  Sugar is part
  of a syntax in a language.

  You can call it whatever you want but it is a anonymous function being used
  as a callback and passed to a node function that is called many times.

  On Fri, Apr 27, 2012 at 8:57 PM, crypticswarm 
  crypticsw...@gmail.comwrote:

   On Fri, Apr 27, 2012 at 10:40 PM, Mark Hahn m...@hahnca.com wrote:

 I would say that in node calling a callback more than once is not 
only
   discouraged, but forbidden, as if it were part of an implied, non 
   written
   contract.

   Then how do you explain ...

       http.createServer(function (req, res) {

   http.createServer(function (req, res) {})

   is sugar for:

   http.createServer().on('request', function (req, 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

 --
 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: Queryable JSON Streams

2012-04-24 Thread Dominic Tarr
performing a join like operation on a two streams is certainly possible,
as is filtering or mapping a stream.

I have a lib for some of this stuff
https://github.com/dominictarr/event-stream

max, min, sort, count etc, unfortunately cannot return a correct answer
until they have received the end event, so using the Stream interface in
that case looses the purpose of streams.

although, if you are interested in streaming aggregates that periodically
emit the most uptodate aggregate (rather than a single final answer) I also
played around with making a realtime map reduce lib. I havn't used it for
anything, but it has tests.

https://github.com/dominictarr/reducer

It can also deal with the case where a row is updated and that has changed
the total.
I've implemented several ways of handling updates.



On Wed, Apr 25, 2012 at 2:10 AM, manimal45 moshir.mik...@gmail.com wrote:

 It's all good and creative, nonetheless, does anyone outthere has
 looked at twitter's storm.
 It's closer to what I've got in mind (see first post) and goes a
 little step further with algorithmics:
 - joins
 - aggregates
 - ...

 For instance joining two json streams coming from two different
 databases can be achieved simply by bolts in storm (which i don't know
 and don't want to use at all because configuration seems not that
 simple !!).

 Most of existing module focus on parsing json chunks to ouptut json
 rows.
 I instead assume json is parsed (thanks to wonderful modules outhere)
 and want to compose streams.

 Go and look at storm to get an idea of the use cases better than i
 could explain myself.


 On 24 avr, 14:43, Nuno Job nunojobpi...@gmail.com wrote:
  Roly you could have told me this existed :PP God damnit :)
 
  Stoked!
 
  Nuno
 
 
 
 
 
 
 
  On Tue, Apr 24, 2012 at 1:35 PM, Roly Fentanes r...@markover.me wrote:
   in mind continously prints j

 --
 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] ender vs. browserify?

2012-04-23 Thread Dominic Tarr
you'd probably still need a bit on the server side, for validation. you
wouldn't want to give the browser direct access to your database for
example.

On Mon, Apr 23, 2012 at 6:10 PM, Mark Hahn m...@hahnca.com wrote:

 I am thinking of putting the entire app in a client-side browserify
 bundle.  I can create the entire BODY element of the dom from js code
 including the style info.  The idea here is to release an app by just
 releasing the bundle.

 I could create a generic index.html file that requires the bundle.

 I have one question though.  How/where would I store my image files?  I
 can imagine putting image files in package folders installed from npm but
 then how would I serve them?  I doubt I want the node_modules folder inside
 my web root folder.  :-)

  --
 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] ender vs. browserify?

2012-04-23 Thread Dominic Tarr
oh right, that is because you are listing a directory and then requiring
each item automatically.

how does onejs handle that case?

you are right about browserify poluting the global namespace. it should
define it's stuff inside a closure.

On Tue, Apr 24, 2012 at 12:11 PM, Azer Koçulu a...@kodfabrik.com wrote:

 On Sun, Apr 22, 2012 at 9:11 PM, Dominic Tarr dominic.t...@gmail.com
 wrote:
  browserify has _by far_ the most test coverage. I know from my own
 dabbling
  in the problem that there are _alot_ of edgecases.

 I confidently say that OneJS is a well-tested project that faced
 _more_ edge-cases already and solved those issues. And I think
 browserify has some issues which can't be considered as edge-cases,
 e.g; polluting global scope, a lot.

 To have an idea of the accuracy of OneJS, check the following examples;
 - MultiplayerChess.com built with OneJS:
 http://multiplayerchess.com/mpc.js
 - ExpressJS built with OneJS: https://gist.github.com/2415048

 ExpressJS is not a client-side project but it's a good example project
 to see the accuracy of the implementations of CommonJS specs. And I
 get following error when I try to build it with browserify;

  ./node_modules/.bin/browserify index.js -o express.js
 Expressions in require() statements:
require(./middleware/+name)
 Expressions in require() statements:
require(this.engine)
 SyntaxError: 'return' outside of function
  at line 22:32 in expression:

  if (res._hasConnectPatch) return;
at
 /home/azer/dev/express/node_modules/browserify/node_modules/deputy/node_modules/detective/node_modules/burrito/index.js:16:17
at
 /home/azer/dev/express/node_modules/browserify/node_modules/deputy/node_modules/detective/node_modules/burrito/index.js:41:11
at Function.find

 (/home/azer/dev/express/node_modules/browserify/node_modules/deputy/node_modules/detective/index.js:15:5)
at Function.find

 (/home/azer/dev/express/node_modules/browserify/node_modules/deputy/index.js:38:27)
at Function.anonymous
 (/home/azer/dev/express/node_modules/browserify/lib/wrap.js:435:39)
at Function.require
 (/home/azer/dev/express/node_modules/browserify/index.js:155:28)
at /home/azer/dev/express/node_modules/browserify/lib/wrap.js:458:14
at Array.forEach (native)
at Function.anonymous
 (/home/azer/dev/express/node_modules/browserify/lib/wrap.js:457:27)
at Function.require
 (/home/azer/dev/express/node_modules/browserify/index.js:155:28)



 Best,

 Azer

 
  https://github.com/substack/node-browserify/tree/master/test
 
  I just use browserify now
 
 
  On Mon, Apr 23, 2012 at 6:07 AM, Mark Hahn m...@hahnca.com wrote:
 
OneJS moves the revolution of NPM one step forward and makes it
   available for client-side projects!
 
  Does this mean you can load a module directly from the npm registry into
  the client to run? Can you also query the registry?
 
  --
  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] ender vs. browserify?

2012-04-22 Thread Dominic Tarr
browserify has _by far_ the most test coverage. I know from my own dabbling
in the problem that there are _alot_ of edgecases.

https://github.com/substack/node-browserify/tree/master/test

I just use browserify now

On Mon, Apr 23, 2012 at 6:07 AM, Mark Hahn m...@hahnca.com wrote:

   OneJS moves the revolution of NPM one step forward and makes it
 available for client-side projects!

 Does this mean you can load a module directly from the npm registry into
 the client to run? Can you also query the registry?

 --
 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] finding modules matching a name glob

2012-04-21 Thread Dominic Tarr
there are lots of places that the installed modules could turn up. the best
might be to use npm ls (or link to npm), that will find you all the dirs,
and the have plugin authors add a field to their package.json that
indicates it is a plugin.

On Sat, Apr 21, 2012 at 4:04 PM, Mark Hahn m...@hahnca.com wrote:

 I need a plug-in system for my app and I'd like for my user to be able to
 install a plug-in by just doing the standard `npm install foo` where foo is
 the name of the module.  When my app starts I want to find all plugins for
 my app and require them without knowing their names.

 I'm thinking that any and all modules with a name matching *_myapp_plugin
 (I don't know my app's name yet)  would be loaded (required).  The user of
 my app would then be able to enable/disable these plugins through the UI.

 I considered walking the dir tree looking for node_module folders, but
 then I started thinking about all the complications.  Maybe I should steal
 code from node require.  Of course if node allowed wild cards in the
 require function that would be ideal.

 I'd be happy to make this plug-in system a module.  Node doesn't have
 enough modules yet.


  --
 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 stalls

2012-04-17 Thread Dominic Tarr
what are the units on the time axis?

this should only happen if you are doing too much sync processing.

does it still happen if you run bench your app with ab?
if so, remove parts of your app until the problem stops.

also, garbage collection: I've done some experiments creating objects until
node crashes, and I noticed pauses as the heap grew large.

how large are the requests to the backends? if they are very large and you
are buffering them all into memory, maybe that could be a clue?

these are just ideas that come to mind. I don't really know.

this also looks like a lead https://github.com/dannycoates/v8-profiler

On Tue, Apr 17, 2012 at 7:48 PM, Martin Koch m...@issuu.com wrote:

 Hi Group

 We're running nodejs as a frontend for several backend services to
 dispatch incoming requests and process and return results from the backend
 services. We're processing around 20 requests / second.

 Sometimes, we observe that the execution thread stalls. Stalls are
 detected by a simple setInterval function that is called regularly and logs
 a complaint if actual time elapsed is greater than the expected elapsed
 time. I have attached a histogram of the distribution of stall delays - it
 may provide a clue.

 We THINK that the stalls are somehow socket-related, but we haven't been
 able to recreate this reliably (or tweak os-level or user-level socket
 parameters that make the problem go away).

 So I'd like to ask the group two questions:

1. Is anyone else running into similar behavior?
2. Can anyone provide pointers for how to find out exactly where
(which function call) nodejs is stalled?

 Thanks,
 /Martin Koch

 --
 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] npmjs.org missing results

2012-04-17 Thread Dominic Tarr
it doesn't show all the results of provide any way to see the next page or
tell you how many you may be missing. when it was written there where only
about 1k modules if i recall.

i use this now

http://eirikb.github.com/nipster/

On Wed, Apr 18, 2012 at 12:33 AM, Alan Hoffmeister 
alanhoffmeis...@gmail.com wrote:

 Hello guyz!

 I don't know if this is the rigth place, but let's get started.
 I use npmjs.org a lot for searching modules, and a ton of times I left
 it without success in my search. Let's take a quick example, try
 searching for mongoose, and this is what it's showing me:

 http://postimage.org/image/5mgder0jp/

 Everything but mongoose... Now try to search for express:

 http://postimage.org/image/wbodsv3il/

 The same. It is just with me?

 --
 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


[nodejs] high level style

2012-04-16 Thread Dominic Tarr
with all the discussion about semicolons the last day,
I woke up with the urge to express my opinions on programming style.

tl;dr:
I'm interested in the style of how you piece together your application,
not where you put punctuation, at the end of the day,
I think this makes a lot more difference to how hard programming is.

https://gist.github.com/2401787

this is just what came to mind this morning,
I would like to hear what you think are important style considerations
(except if it's about semicolons)

cheers,
Dominic

-- 
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