[nodejs] Re: find path of module require()ing

2012-11-12 Thread greelgorke
guess there is no other way. but the whole task smells like hell to me. why does your module need to know who required it? Am Samstag, 10. November 2012 15:02:50 UTC+1 schrieb boden: > > hi all, > trying to find the proper way to determine the path of the module > requiring my module given the f

Re: [nodejs] Re: trying to wrap my head around "promises" - async vs Q

2012-11-12 Thread greelgorke
my approach to handle callback sallad? use the language features. just wrote down a script that would have a 7-10 callbacks nested. The problem with the callbacks is not the callback approach. it's simple and beautiful. the problem is naive and blind utilization of the closure scope. Just an ex

[nodejs] Re: find path of module require()ing

2012-11-12 Thread boden
doesn't *have* to, but does for ease of use -- it defaults some paths relative to the caller's (the module require()ing) module location... obviously there are other approaches such as forcing the require()er to pass in those paths rather than defaulting them. i'm not all that seasoned in the n

Re: [nodejs] Re: trying to wrap my head around "promises" - async vs Q

2012-11-12 Thread Mariusz Nowak
If I would choose which tool is best for my project just by popularity factor I wouldn't go far. It's understood that Async is more popular as it doesn't introduce much learning factor and most developers are looking for quick solutions. To get promises you need to devote a while understand it.

Re: [nodejs] Please provide feedback as to best practice for reading files from a specific directory

2012-11-12 Thread kinghokum
Hi all, Just wondering if this is any better. I've tried to implement what Martin has suggested best to my knowledge. Any further feedback is appreciated. Thanks // Set up the app var express = require('express') , app = express() , fs = require('fs') , path = require('path'); // D

[nodejs] Re: Simple LightWeight OOP. 100% compatibility with JavaScript. Feedback please!

2012-11-12 Thread greelgorke
@Fredrik: enlightenment and understanding are my targets too. That's why i love to talk about such topics as well. And my position, when it comes to a daily job, is: i would use your helper if i would contribute to your projects, and hell, yes i would contribute to your projects, if i had time

Re: [nodejs] Re: trying to wrap my head around "promises" - async vs Q

2012-11-12 Thread Bradley Meck
Choose either, I do things in callback style personally to match the ecosystem when I write libraries, thats the expectation of the ecosystem. For application logic, do whatever makes it faster. There are exactly 0 absolute wins on either side. I can go on at length about the reason both have p

[nodejs] Re: trying to wrap my head around "promises" - async vs Q

2012-11-12 Thread netpoetica
This isn't Node specific, but it's a really thorough article a professor pointed me to with JavaScript examples: https://raw.github.com/kriskowal/q/master/design/README.js On Sunday, March 25, 2012 4:42:32 AM UTC-4, Andy wrote: > > *Note, I am not asking which tool is better, I am simply trying

[nodejs] Domains and connection pools

2012-11-12 Thread pie_lard
Hi, I'm trying to use domains to catch application-level errors in my server. I'm using express, connect, node-mysql and generic-pool. The node docs give an example at http://nodejs.org/api/domain.html#domain_explicit_binding which shows how to create a new domain per incoming request - ie. c

[nodejs] Re: Simple LightWeight OOP. 100% compatibility with JavaScript. Feedback please!

2012-11-12 Thread Fredrik O
I cannot talk about others, every human has responsibility over their own knowledge and understanding. But I can talk for myself and I don´t stop thinking only because someone use the class word. I trying to see features and behaviour, and this behaviour is specially bound to the word "class" a

[nodejs] Memory error / setInterval () doesn't work

2012-11-12 Thread David Fang
Hi, We are writing a script that reads a large set of JPG files on our server (infinite, since we have another process that keeps writing JPG files to the same directory) and send them to users' browsers as an MJPEG stream at fixed time interval (variable "frameDelay" in code below). This is s

Re: [nodejs] Re: trying to wrap my head around "promises" - async vs Q

2012-11-12 Thread Nuno Job
> If I would choose which tool is best for my project just by popularity factor > I wouldn't go far. I have a way to solve this issue that emulates pattern matching in javascript `github/dscape/p` while maintaing valid JS semantics. Its so unpopular even I dont use it :) (but it works

Re: [nodejs] Domains and connection pools

2012-11-12 Thread Forrest L Norvell
On Monday, November 12, 2012 at 7:25 AM, pie_lard wrote: > Hi, > > I'm trying to use domains to catch application-level errors in my server. > I'm using express, connect, node-mysql and generic-pool. > > The node docs give an example at > http://nodejs.org/api/domain.html#domain_explicit_bindi

[nodejs] Re: Memory error / setInterval () doesn't work

2012-11-12 Thread mscdex
On Nov 12, 12:17 pm, David Fang wrote: > It's possible that they were caused by our mistakes in the code, but we > have inspected this seemingly simple script many many times ;-(  Therefore > I'm posting the code below.  Any comments / suggestions are greatly > appreciated! Did you try using `req

[nodejs] html5 video not working with node.js

2012-11-12 Thread Yash Girdhar
I am trying to play a video using html5 video tag in chrome. when I play the video in a different file, containing just the video tag, the video is playing.but when I embed the video in the html file of node server, it is not. The other functionalities of the node server are working as expected

[nodejs] Ping Server & Client UDP socket

2012-11-12 Thread 510carlos
I am attempting to create a small ping for proof of concept. I am just learning node.js. I want the client to send a packet over UDP. The server should acknowledge it by writing to console and send another packet of the the same size back to the client. This is what I have so far.: Server: va

Re: [nodejs] html5 video not working with node.js

2012-11-12 Thread Mark Hahn
> when I embed the video in the html file of node server What do you mean by embed? Surely you don't mean putting the video data in an actual .html file. On Mon, Nov 12, 2012 at 1:16 PM, Yash Girdhar wrote: > > I am trying to play a video using html5 video tag in chrome. when I play the video i

Re: [nodejs] html5 video not working with node.js

2012-11-12 Thread Yash Girdhar
actually, I have made a simple real time drawing board in node.js, using socket.io.Now, I want to embed real time video sync in the same file. So, to start with I just added a video tag to the html file of the node.js server(I am attaching both the files for your reference), to make sure that

Re: [nodejs] html5 video not working with node.js

2012-11-12 Thread Nathan Rajlich
Are you implementing the static file serving yourself? You're likely not supporting the Range header and 206 partial responses, which HTML5 tags expect to work properly. I'd recommend using connect's static() middleware. On Mon, Nov 12, 2012 at 1:44 PM, Yash Girdhar wrote: > actually, I have mad

Re: [nodejs] Re: trying to wrap my head around "promises" - async vs Q

2012-11-12 Thread Andy
One of them problems even with this approach is that you write and read code backwards. It executes bottom to top because you have to define named callback functions first. I find it much more natural with promises because not only is your code organized, but it reads top to bottom and is MUCH

Re: [nodejs] Re: trying to wrap my head around "promises" - async vs Q

2012-11-12 Thread Andy
On Sunday, November 11, 2012 10:46:05 PM UTC-8, Mikeal Rogers wrote: > > > Some people clearly like promises, but the dominant pattern in node is not > promises, it's callbacks, with complex callback issues managed with async. > > Stating your opinion strongly does not make it a fact. This is you

RE: [nodejs] Re: trying to wrap my head around "promises" - async vs Q

2012-11-12 Thread Domenic Denicola
An interesting alternative is to use Q’s new “nodeify” function: function returnsPromiseOrCallsback(callback) { return Q.resolve(5).nodeify(callback); } If callback is a function, it will call callback(null, 5); otherwise it will return the promise for 5. Similarly it will pass rejection reaso

Re: [nodejs] Re: trying to wrap my head around "promises" - async vs Q

2012-11-12 Thread Matt
On Mon, Nov 12, 2012 at 5:48 PM, Andy wrote: > One of them problems even with this approach is that you write and read > code backwards. It executes bottom to top because you have to define named > callback functions first. I find it much more natural with promises because > not only is your code

Re: [nodejs] Re: trying to wrap my head around "promises" - async vs Q

2012-11-12 Thread Mark Hahn
> because you have to define named callback functions first. No you don't. I always name then in order ... func1 = -> do something; func2() func2 = -> do something; func3() func3 = -> do something func1() On Mon, Nov 12, 2012 at 2:48 PM, Andy wrote: > One of them problems even with this a

Re: [nodejs] Domains and connection pools

2012-11-12 Thread pie_lard
Cool - thanks! This definitely could be better documented. It's a pretty easy trap to fall into. Also, your solution still depends on process.domain which isn't mentioned officially (ie. at http://nodejs.org/api/process.html ). On Monday, 12 November 2012 18:55:33 UTC, Forrest L Norvell wrot

Re: [nodejs] Re: trying to wrap my head around "promises" - async vs Q

2012-11-12 Thread Andy
> > In JavaScript the order you define things doesn't matter. > It does if your function declaration style is var funcName = function() { }; which is the style I use. Personal preference obviously. > > -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node

Re: [nodejs] Re: trying to wrap my head around "promises" - async vs Q

2012-11-12 Thread Mark Hahn
Read the message before this. I explained how it works in a forward way with your preferred method of function definition. That is what I always use. On Mon, Nov 12, 2012 at 3:46 PM, Andy wrote: > > >> >> In JavaScript the order you define things doesn't matter. >> > > It does if your function

Re: [nodejs] Re: trying to wrap my head around "promises" - async vs Q

2012-11-12 Thread Mark Hahn
P.S. Coffeescript only supports that way of defining a function. On Mon, Nov 12, 2012 at 3:51 PM, Mark Hahn wrote: > Read the message before this. I explained how it works in a forward way > with your preferred method of function definition. That is what I always > use. > > > On Mon, Nov 12,

Re: [nodejs] html5 video not working with node.js

2012-11-12 Thread Ryan Schmidt
On Nov 12, 2012, at 16:32, Nathan Rajlich wrote: > Are you implementing the static file serving yourself? The only route defined in app.js is: app.get('/', function (req, res) { res.sendfile(__dirname + '/index.html'); }); Therefore "/" is the only route that will be served. If you also wan

Re: [nodejs] Domains and connection pools

2012-11-12 Thread Forrest L Norvell
On Monday, November 12, 2012 at 3:36 PM, pie_lard wrote: > Cool - thanks! > > This definitely could be better documented. It's a pretty easy trap to fall > into. > > Also, your solution still depends on process.domain which isn't mentioned > officially (ie. at http://nodejs.org/api/process.h

[nodejs] How can I get the complete reference of the Node API?

2012-11-12 Thread Tang Tianyong
I wonder the API's just simple description, like the API assert.fail, when I follow the example code, I can not get the correct output as the comment say: -- Code -- var assert = require('assert'); var iX = 4; var iY = 5

[nodejs] Re: various failures on stable test suite

2012-11-12 Thread Mac Chambers
=== release test-child-process-fork2 === Path: simple/test-child-process-fork2 PARENT send child server handle CHILD got message: { hello: 'world' } PARENT got message: { gotHandle: true } CLIENT connected CLIENT connected CLIENT connected CLIENT connected CLIENT

Re: [nodejs] Re: Setup environment variables?

2012-11-12 Thread Adam Tolley
Setting environment vars is pretty basic unix knowledge - what was lost on me is that process.env contained those variables. I assumed nodejs had its own environment vars set up by passing in arguments on launch, or a file, not just bootstrapping the current shell environment - thats pretty sli

Re: [nodejs] Re: various failures on stable test suite

2012-11-12 Thread Ben Noordhuis
On Mon, Nov 12, 2012 at 11:52 PM, Mac Chambers wrote: > === release test-child-process-fork2 === > Path: simple/test-child-process-fork2 > PARENT send child server handle > CHILD got message: { hello: 'world' } > PARENT got message: { gotHandle: true } > CLIENT connected > CLIENT connected > CLIEN

[nodejs] Re: How can I get the complete reference of the Node API?

2012-11-12 Thread mscdex
On Nov 12, 8:33 pm, Tang Tianyong wrote: > assert.fail(iX, iY, "iX is bigger than iY", "<"); > // prints nothing, because it does not fail This *should* print something, and it does when I try it on node 0.8.14. assert.fail() should *always* throw an exception. It does not do any checks: https:/

[nodejs] Re: How can I get the complete reference of the Node API?

2012-11-12 Thread Tang Tianyong
Thanks for your help. The source code can explain everything. :P On Tuesday, November 13, 2012 11:01:29 AM UTC+8, mscdex wrote: > > On Nov 12, 8:33 pm, Tang Tianyong wrote: > > assert.fail(iX, iY, "iX is bigger than iY", "<"); > > // prints nothing, because it does not fail > > This *should* p

[nodejs] [ANN] AwsSum v0.12

2012-11-12 Thread Andrew Chilton
Hi everyone, I'd like to announce the latest version of AwsSum (http://awssum.io/), v0.12. A great deal of work has gone into this release with many bug fixes but the highlights of the new features are: * support for the new Sydney region * PriceClass support in CloudFront * CORS support in S3 *