[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 following requirements:
>
> * must be strict mode complaint
> * cannot depend on node arguments (i.e. process.argv)
> * must work when being required from different modules in the same 
> execution (i.e. my module is already cached)
>
> i ended up patching Module._load() to capture the request and then 
> wrapping it in a closure like shown here: 
> https://github.com/bodenr/expose/blob/master/index.js
>
> however this doesn't feel right -- i must be missing something.
>
> thx in advanced
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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 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 
example:

function lolAssert(){
  var forClojure = 'lol'
  require('child_process').exec( 'echo lol', function(err, stdout,stderr){
require('assert').ok(~stdout.indexOf(forClojure))
  })
}

exec callback utilizes a clojure scope directly. in most cases you can 
easily avoid this:

function execCB(err, stdout,stderr){
require('assert').ok(~stdout.indexOf( this ))
}

function lolAssert(){
  var forClojure = 'lol'
  require('child_process').exec('echo lol', execCB.bind(forClojure))
}

you can write it this way all way down. in most cases you even need the 
clojure scope/ this-binding. The script i wrote is nothing more that a 
number of small functions with no cb-nesting, no dependencies to 3rd party 
libs. this approach is perfectly usable for most of use cases, since the 
node callback pattern does not utilize this bindings. jQuery is different.

Am Montag, 12. November 2012 07:46:05 UTC+1 schrieb Mikeal Rogers:
>
> It's great that you have a strong opinion. Here's some numbers:
>
> Here's the number of modules that depend on async and Q.
>
> async: 975
> Q: 109
>
> Here are the numbers of downloads in the last month.
>
> async: 120,271
> Q: 33,242
>
>
> 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 your 
> preference, and many others, but not the majority.
>
> If you write a library, it better use callbacks if you want people to use 
> it. Using callbacks in your own application code is the path of least 
> resistance for using the majority of value in the node ecosystem. That's a 
> fact, there are numbers. It's not everyone's preference, but it's the most 
> popular by far.
>
> -Mikeal
>
> On Nov 11, 2012, at November 11, 20125:18 PM, Andy 
> > 
> wrote:
>
> To reply to my own very old thread after getting some solid experiences 
> with promises, the answers to my questions are:
>
> 1. *async* is a library that passes callbacks around. it's ugly and it 
> sucks.
>
> 2. a* promise *is just an object. Don't let anyone tell you differently, 
> they are just trying to confuse you. It's an object that has method names 
> that everyone's agreed on, like *then *and *done *which will magically 
> trigger your callbacks for you. With promises, you include *Q* and you 
> just pass around Q objects (called deferreds and promises). It's just that 
> everyone agreed that the promise object will have a *.then* method, which 
> you can call and your function jumps next in line onto the promise chain 
> magically.
>
> The libraries should *not *be used together. Once you get your head 
> around promises and use them in field you won't want to use anything else.
>
> If you are exposing an API, you should still take/call a callback. If 
> you're writing a database client you don't want to give the user a promise 
> and force them into your model. Just call their callback at the end of your 
> own, internal beautiful promise chain. It will be our terrible secret.
>
> Promises aren't perfect and can get strange when doing some complex 
> composition (lots of return statements to return promise chains), but they 
> make writing async code soo nice.
>
> -- 
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: 
> https://github.com/joyent/node/wiki/Mailing-List-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


[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 and interest on the 
topics there. but i also would ask you, why do you use such a helper and 
try to trigger your thinking about it as well :). 

the worst thing is not that people use class-emulating helpers and libs, 
the worst thing is when they do it to avoid the confrontation with the 
language and it's internals. ignorance is the enemy, not tools. you said, 
one has not to be an expert, but a knowledge about fundamental concepts of 
the language is crucial. But many some developers just see "Class" and 
shutdown exploration mode in their brains, asume a paradigm, that isn't 
there, and wonder then,  why JS is so lame. 

Am Montag, 12. November 2012 13:47:26 UTC+1 schrieb Fredrik O:
>
> Hi Bruno,
>
> It was nice to hear, thanks for sharing that information.
>
> greelgorke:
>
> I seek enlightenment and understanding in general. I wanted to get people 
> thoughts and why they have those thoughts, by using as much as possible 
> real arguments/fact, even if it may be hard within a subject like this. 
> Thanks for your contribution (and everybody else for that sake) to this 
> thread anyway :-)
>
> Den fredagen den 9:e november 2012 kl. 23:05:47 UTC+1 skrev Bruno Jouhier:
>>
>> Hi Frederik,
>>
>> I wrote a helper very similar to yours (with a little plus: a concise 
>> syntax for property getters and setters) early in our project.
>>
>> I just did a grep and we now have more than 250 classes in more than 200 
>> modules defined with this helper. The helper keeps our code lean, 
>> consistent, well organized and pleasant to read. And, unlike some of the 
>> fancier helpers, it does not impact performance. Looking back, this is a 
>> total winner.
>>
>> If this can make you feel better
>>
>> Bruno
>>
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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 wrap my head around "promises" - async vs Q

2012-11-13 Thread greelgorke
it's not backwards. first function is on top, last at the bottom, 
functions, which may appear multiple times in the callback chain are at the 
top most position by convention. i use the function declaration statement 
for this, because they get hoisted and the definition order is irrelevant 
then. There is no problem with named functions, they are good 
for stack-traces anyway. here just a snippet:

function rebuild(){
  checkErr.apply(null,arguments)
  vLog('rebuild dependencies...')
  exec("npm rebuild", dbJSON)
}

function dbJSON(){
  checkErr.apply(null,arguments)
  vLog('database.json...')
  exec("cp -f config/database.shared.json config/database.json", 
createLogFolder)
}

function createLogFolder(){
  checkErr.apply(null,arguments)
  vLog('create log folder...')
  if (fs.existsSync('./log')) prepareDistribution()
  else exec("mkdir log && touch log/dummy_file", prepareDistribution)
}

function prepareDistribution() {
  checkErr.apply(null,arguments)
  vLog('prepare distribution...')
  exec('git add . -Af && git commit -m "deployment script done 
preparation"', deploy)
}

its a part of a script that just runs on bare node. it's an approach you 
always can be used, in every node environment. it just use functions with 
well defined scope, they can be easily reused. the disadvantage of this 
approach is that you need to use bind or shared variables in outer scope 
instead of clojure scope. bind is much slower in v8, and shared variables 
may be evil.

Am Montag, 12. November 2012 23:48:33 UTC+1 schrieb 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 
> easier to trace flow.
>
> On Monday, November 12, 2012 1:39:37 AM UTC-8, greelgorke wrote:
>>
>>
>> function execCB(err, stdout,stderr){
>> require('assert').ok(~stdout.indexOf( this ))
>> }
>>
>> function lolAssert(){
>>   var forClojure = 'lol'
>>   require('child_process').exec('echo lol', execCB.bind(forClojure))
>> }
>>
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: How to be sure in delivering data between server and client?

2012-11-19 Thread greelgorke
server code would be nice.

Am Donnerstag, 15. November 2012 10:56:30 UTC+1 schrieb greeka:
>
> I have TCP server written in NodeJS and clients on flash. The 
> communications between clients and server builded ower my own protocol 
> (small commands - max 50 bytes per command). But some time (aprox 10% from 
> total commands sent from server to client) we lost the data. And I can't 
> understand why and can't understand the relationship of what is happening. 
> Some time it's happens right after connections to client, some time after a 
> couple minutes after connect. Some time all ok. No any disconnects or error.
>  So my questions:
> - how to be 100% sure that all data is delivered to client (by NodeJS 
> side)?
> - if previous is impossible, how to check that my command is delivered?
>
> How to understand and when to use:
>
>- socket.setTimeout(timeout, 
> [callback])
>- 
> socket.setNoDelay([noDelay])
>- socket.setKeepAlive([enable], 
> [initialDelay])
>
>
> Could these methods help me?
>
> P.s. It's our dev server with couple of clients. The network is stable, 
> ping 100%.
> Sorry for my English.
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: What triggers an error being emitted in http.request?

2012-11-28 Thread greelgorke
from http://nodejs.org/api/http.html#http_http_request_options_callback:

If any error is encountered during the request (be that with DNS 
resolution, TCP level errors, or actual HTTP parse errors) an 'error' event 
is emitted on the returned request object.

read: anything what results in invalid HTTP process will emit an 'error'.

Am Dienstag, 27. November 2012 15:20:42 UTC+1 schrieb GinnyD:
>
> I am currently using the http module to perform a POST operation to a 
> remote API call and I'm trying to figure out the best way to handle error 
> situations where things don't quite go as planned.  I thought I could use 
> the error event emitter but I have a situation where the server returns a 
> 500 http status code but my code in the error event emitter never fires.   
> My question is what will cause the error event emitter to fire?  Is a http 
> return code of 500 enough or is it looking for something else in the 
> response from the call?  The snippet of the node code in question is listed 
> below. The res.statusCode shows a value of 500, but the console.log within 
> the error emitter never fires off.  This is occuring on version 0.8.11. 
>  Any guidance would be appreciated.
>
> Ginny
>
>
> *var post_data = querystring.stringify(data);*
>
> *
> *
>
> *// An object of options to indicate where to post to*
>
> *var post_options = {*
>
> *host: host_url,*
>
> *port: port_num,*
>
> *path: url_path,*
>
> *method: 'POST',*
>
> *headers: {*
>
> *'Content-Type': 'application/x-www-form-urlencoded',*
>
> *'Content-Length': post_data.length*
>
> *}*
>
> *};*
>
> *
> *
>
> *var req = http.request(post_options, function(res) {*
>
> *  console.log('STATUS: ' + res.statusCode);*
>
> *  console.log('HEADERS: ' + JSON.stringify(res.headers));*
>
> *  res.setEncoding('utf8');*
>
> *  res.on('data', function (chunk) {*
>
> *console.log('BODY: ' + chunk);*
>
> *  });*
>
> *});*
>
> *
> *
>
> *req.on('error', function(e) {*
>
> *  console.log('problem with request: ' + e.message);*
>
> *});*
>
> *
> *
>
> *req.write(post_data);*
>
> *req.end();*
>
>
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: What triggers an error being emitted in http.request?

2012-11-29 Thread greelgorke
HTTP 500 is not an HTTP error, it's a valid HTTP response code, only 
signals that the responding server can't deliver requested response due to 
an internal error. there is nothing wrong happend on HTTP side. that's why 
error event isn't emitted. You have to clearly distinguish between HTTP and 
the things that happens in Server/Client. It's not that surprising... 

Am Donnerstag, 29. November 2012 14:31:29 UTC+1 schrieb GinnyD:
>
> I read that same thing, that is why I was surprised when I was seeing a 
> value of 500 returned via the res.statusCode property in the included 
> code yet the emit code never fired.
>
> On Wednesday, November 28, 2012 4:14:27 AM UTC-5, greelgorke wrote:
>>
>> from http://nodejs.org/api/http.html#http_http_request_options_callback:
>>
>> If any error is encountered during the request (be that with DNS 
>> resolution, TCP level errors, or actual HTTP parse errors) an 'error' event 
>> is emitted on the returned request object.
>>
>> read: anything what results in invalid HTTP process will emit an 'error'.
>>
>> Am Dienstag, 27. November 2012 15:20:42 UTC+1 schrieb GinnyD:
>>>
>>> I am currently using the http module to perform a POST operation to a 
>>> remote API call and I'm trying to figure out the best way to handle error 
>>> situations where things don't quite go as planned.  I thought I could use 
>>> the error event emitter but I have a situation where the server returns a 
>>> 500 http status code but my code in the error event emitter never fires.   
>>> My question is what will cause the error event emitter to fire?  Is a http 
>>> return code of 500 enough or is it looking for something else in the 
>>> response from the call?  The snippet of the node code in question is listed 
>>> below. The res.statusCode shows a value of 500, but the console.log within 
>>> the error emitter never fires off.  This is occuring on version 0.8.11. 
>>>  Any guidance would be appreciated.
>>>
>>> Ginny
>>>
>>>
>>> *var post_data = querystring.stringify(data);*
>>>
>>> *
>>> *
>>>
>>> *// An object of options to indicate where to post to*
>>>
>>> *var post_options = {*
>>>
>>> *host: host_url,*
>>>
>>> *port: port_num,*
>>>
>>> *path: url_path,*
>>>
>>> *method: 'POST',*
>>>
>>> *headers: {*
>>>
>>> *'Content-Type': 'application/x-www-form-urlencoded',*
>>>
>>> *'Content-Length': post_data.length*
>>>
>>> *}*
>>>
>>> *};*
>>>
>>> *
>>> *
>>>
>>> *var req = http.request(post_options, function(res) {*
>>>
>>> *  console.log('STATUS: ' + res.statusCode);*
>>>
>>> *  console.log('HEADERS: ' + JSON.stringify(res.headers));*
>>>
>>> *  res.setEncoding('utf8');*
>>>
>>> *  res.on('data', function (chunk) {*
>>>
>>> *console.log('BODY: ' + chunk);*
>>>
>>> *  });*
>>>
>>> *});*
>>>
>>> *
>>> *
>>>
>>> *req.on('error', function(e) {*
>>>
>>> *  console.log('problem with request: ' + e.message);*
>>>
>>> *});*
>>>
>>> *
>>> *
>>>
>>> *req.write(post_data);*
>>>
>>> *req.end();*
>>>
>>>
>>>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] "this" and that

2012-12-12 Thread greelgorke
you should really read the book first... complaining about "rtfm-calls" 
without knowing basic stuff about the language is pretty much trolling.

Am Mittwoch, 12. Dezember 2012 04:18:08 UTC+1 schrieb spqr:
>
>
> Thanks for your help on this, I think you solved my problem with "this" by 
> helping me avoid eval().  
> Coming at JavaScript with some history in lisp, maybe my question should 
> have been "why does JavaScript have eval()?" ;-)
> (Hah! I know it still has its uses...)
>
> I just constructed this code:
>
> var myobjs = { p1234: { a: 1,
>b: function() { var c = this.a; return 0; }},
>   p2345: { a: 2,
>b: function() { var c = this.a; return 1; }}};
>
> var q = "p1234";
> myobjs[q].b();
>
> I ran a quick test and it works like a charm.  I noticed that the object 
> keys can be
> literals or strings and it still works.  Is there any preference on which 
> to use? 
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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 get session of java

2012-12-12 Thread greelgorke
it depends on how java session is implemented. is it persisted in a db? 
then you just have to read the session-id cookie in node and fetch it from 
db. if its in-memory stored in java, then you have to implement a rpc/rest 
interface in java, which profides the session data as json to your node 
application. if it's pure cookie/localstorage based, thans just read them.

Am Mittwoch, 12. Dezember 2012 10:00:05 UTC+1 schrieb ayaz ali:
>
> i need the complete session object which is created after login. it may 
> contain any thing any solution please

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] [CONCURRENT REQUEST]

2012-12-12 Thread greelgorke
requests are always coming on the same socket. After the TSP-Handshake 
server opens a new socket for the connection to the client and handles the 
requests over it. the socket on bound on listen-port is still there for 
accepting connections. OS buffers incomming requests on this socket 
internaly in a queue. node handles this situation in the same way as other 
systems do: it accepts (or rejects) the connection opens a new socket for 
the client-connection and calls your callback passing the 
connection-object. the only difference in node is, that instead of spawning 
new threads it emits 'connection' events and the triggering of the 
connection-handler-function is handled by the event-loop.

Am Mittwoch, 12. Dezember 2012 10:12:51 UTC+1 schrieb Hardik Shah:
>
> Hi Nikhil,
> Thanks for the knowledge sharing...
> As you are saying that each request is coming on different TCP socket, 
> then again number of socket is limited (2^16=65536 - 1024 some reserved 
> sockets)  so as per theory it can handle at max 64k concurrent request? is 
> it like that? 
> Thanks in advance.
>
>
> On Monday, 9 April 2012 14:36:33 UTC+5:30, Nikhil wrote:
>>
>> On Mon, Apr 9, 2012 at 2:32 PM, FleetCommand  
>> wrote:
>> > Hi all ,
>> >
>> > I would like to know , how node.js handles if two requests come in 
>> parallel.
>> > For example : first a  dynamic http request comes wich requires some
>> > processing.
>> >  suppose node.js is fetching parameters from request body and performing
>> > some validations,
>> >  At the same time if a new request comoes (it can either be static file
>> > serving request or dynamic).
>> >   So how node.js will handle this situation.
>>
>> Amit,
>>
>> Each request is still coming on a different TCP socket, for all
>> purposes two different channels.
>> Each of these sockets has it's own object in the JS environment as
>> well (the argument to the tcp/http
>> server callback). read() is done on a socket, so the two requests data
>> will not overlap.
>>
>> Nikhil
>>
>>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] [CONCURRENT REQUEST]

2012-12-12 Thread greelgorke
see here http://en.wikipedia.org/wiki/Berkeley_sockets#accept.28.29

Am Mittwoch, 12. Dezember 2012 10:29:21 UTC+1 schrieb greelgorke:
>
> requests are always coming on the same socket. After the TSP-Handshake 
> server opens a new socket for the connection to the client and handles the 
> requests over it. the socket on bound on listen-port is still there for 
> accepting connections. OS buffers incomming requests on this socket 
> internaly in a queue. node handles this situation in the same way as other 
> systems do: it accepts (or rejects) the connection opens a new socket for 
> the client-connection and calls your callback passing the 
> connection-object. the only difference in node is, that instead of spawning 
> new threads it emits 'connection' events and the triggering of the 
> connection-handler-function is handled by the event-loop.
>
> Am Mittwoch, 12. Dezember 2012 10:12:51 UTC+1 schrieb Hardik Shah:
>>
>> Hi Nikhil,
>> Thanks for the knowledge sharing...
>> As you are saying that each request is coming on different TCP socket, 
>> then again number of socket is limited (2^16=65536 - 1024 some reserved 
>> sockets)  so as per theory it can handle at max 64k concurrent request? is 
>> it like that? 
>> Thanks in advance.
>>
>>
>> On Monday, 9 April 2012 14:36:33 UTC+5:30, Nikhil wrote:
>>>
>>> On Mon, Apr 9, 2012 at 2:32 PM, FleetCommand  
>>> wrote:
>>> > Hi all ,
>>> >
>>> > I would like to know , how node.js handles if two requests come in 
>>> parallel.
>>> > For example : first a  dynamic http request comes wich requires some
>>> > processing.
>>> >  suppose node.js is fetching parameters from request body and 
>>> performing
>>> > some validations,
>>> >  At the same time if a new request comoes (it can either be static file
>>> > serving request or dynamic).
>>> >   So how node.js will handle this situation.
>>>
>>> Amit,
>>>
>>> Each request is still coming on a different TCP socket, for all
>>> purposes two different channels.
>>> Each of these sockets has it's own object in the JS environment as
>>> well (the argument to the tcp/http
>>> server callback). read() is done on a socket, so the two requests data
>>> will not overlap.
>>>
>>> Nikhil
>>>
>>>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: Why no additional parameters in (async. node.js API) callback functions?

2012-12-12 Thread greelgorke
why? its the simpliest and most common way, that's it. passing by custom 
params has to be implemented in the async function itself, there is no 
native support in js nor node for this. and since use of clojures is very 
common in js world, mostly noone cares about it. but yes it may help to 
un-clutter the callbacks a bit and helpt to build pure functions with 
explicit parameters. but i doubt that it would be a performance 
improvement, because v8 optimized clojurescope-access very well, see 
here http://jsperf.com/bind-vs-clojure/2

Am Mittwoch, 12. Dezember 2012 10:36:29 UTC+1 schrieb Michael Hasenstein:
>
> This is not a technical question (I'm quite clear about how the stuff 
> works). I also did some (Google) research before asking.
>
> I'm just curious if there is a good reason that I just fail to see... I AM 
> aware that very obviously I am not the first person to think about this, 
> but I just could not find ANY good explanation for the "WHY".
>
> Let me just give an example.
>
> I get an array of strings (filenames, e.g. from fs.readDir), and now I 
> want to process them: fs.stat(), fs.readFile(), then minify, then 
> fs.writeFile().
>
> now. all those operations are asynchronous unless I use the sync-version 
> of those functions.
>
> PROBLEM:
>
> I really, really, REALLY need that filename string it all started with in 
> the other functions - so now, with node.js callback API being as it is, I 
> have to write code that I really, REALLY dislike, because it seems 
> suboptimal compared to what I COULD do.
>
> What I COULD do but which the node.js callbacks don't allow is the passing 
> of additional parameters to my callback.
>
> Code: 
> function onStat(err, stat) {
> if (stat.isFile()) {
> //fs.readFile(...)... WHICH FILE
> }
> }
>
> files.forEach(function (file) {
> fs.stat( + file), onStat);
> });
>
> I AM AWARE HOW TO SOLVE THIS. Pls. don't reply showing me how I can easily 
> solve this with additional function scopes.
>
> My issue with adding additional functions is that that solution SUCKS. If 
> I could just add additional parameters to the fs.stat() call which my 
> callback gets as 3rd, 4th, etc parameter (or an array or an object, 
> whatever) the sun would still shine.
>
> However, node.js makes me add additional quite useless scopes. 
> ALTERNATIVELY I write all those callback functions into the lexical scope 
> of the forEach() - that's what has been called "callback hell" for a long 
> time - no way.
>
> So, can anyone enlighten me - and I MAY INDEED be simply incredibly stupid 
> not to see the point without help - why node.js could not just let me add 
> custom parameters for callbacks? Again: additional scope-producing 
> functions are NOT OPTIMAL IMHO - it produces overhead both in the code and 
> during runtime. There MUST be a reason, otherwise by now, node.js almost at 
> version 0.9, would have been changed, wouldn't it? I mean, libraries like 
> YUI3 give me the option to add my own custom parameters to be passed down 
> to callback functions, to solve this exact problem.
>
> TIA!
>
>

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


[nodejs] Re: Why no additional parameters in (async. node.js API) callback functions?

2012-12-12 Thread greelgorke
yes, thanks, for the hint. :)

Am Mittwoch, 12. Dezember 2012 12:16:27 UTC+1 schrieb Ruben Tan:
>
> I think you meant "closure". clojure is a language running on JVM.
>
> On Wednesday, December 12, 2012 6:59:56 PM UTC+8, greelgorke wrote:
>>
>> why? its the simpliest and most common way, that's it. passing by custom 
>> params has to be implemented in the async function itself, there is no 
>> native support in js nor node for this. and since use of clojures is very 
>> common in js world, mostly noone cares about it. but yes it may help to 
>> un-clutter the callbacks a bit and helpt to build pure functions with 
>> explicit parameters. but i doubt that it would be a performance 
>> improvement, because v8 optimized clojurescope-access very well, see here 
>> http://jsperf.com/bind-vs-clojure/2
>>
>> Am Mittwoch, 12. Dezember 2012 10:36:29 UTC+1 schrieb Michael Hasenstein:
>>>
>>> This is not a technical question (I'm quite clear about how the stuff 
>>> works). I also did some (Google) research before asking.
>>>
>>> I'm just curious if there is a good reason that I just fail to see... I 
>>> AM aware that very obviously I am not the first person to think about this, 
>>> but I just could not find ANY good explanation for the "WHY".
>>>
>>> Let me just give an example.
>>>
>>> I get an array of strings (filenames, e.g. from fs.readDir), and now I 
>>> want to process them: fs.stat(), fs.readFile(), then minify, then 
>>> fs.writeFile().
>>>
>>> now. all those operations are asynchronous unless I use the sync-version 
>>> of those functions.
>>>
>>> PROBLEM:
>>>
>>> I really, really, REALLY need that filename string it all started with 
>>> in the other functions - so now, with node.js callback API being as it is, 
>>> I have to write code that I really, REALLY dislike, because it seems 
>>> suboptimal compared to what I COULD do.
>>>
>>> What I COULD do but which the node.js callbacks don't allow is the 
>>> passing of additional parameters to my callback.
>>>
>>> Code: 
>>> function onStat(err, stat) {
>>> if (stat.isFile()) {
>>> //fs.readFile(...)... WHICH FILE
>>> }
>>> }
>>>
>>> files.forEach(function (file) {
>>> fs.stat( + file), onStat);
>>> });
>>>
>>> I AM AWARE HOW TO SOLVE THIS. Pls. don't reply showing me how I can 
>>> easily solve this with additional function scopes.
>>>
>>> My issue with adding additional functions is that that solution SUCKS. 
>>> If I could just add additional parameters to the fs.stat() call which my 
>>> callback gets as 3rd, 4th, etc parameter (or an array or an object, 
>>> whatever) the sun would still shine.
>>>
>>> However, node.js makes me add additional quite useless scopes. 
>>> ALTERNATIVELY I write all those callback functions into the lexical scope 
>>> of the forEach() - that's what has been called "callback hell" for a long 
>>> time - no way.
>>>
>>> So, can anyone enlighten me - and I MAY INDEED be simply incredibly 
>>> stupid not to see the point without help - why node.js could not just let 
>>> me add custom parameters for callbacks? Again: additional scope-producing 
>>> functions are NOT OPTIMAL IMHO - it produces overhead both in the code and 
>>> during runtime. There MUST be a reason, otherwise by now, node.js almost at 
>>> version 0.9, would have been changed, wouldn't it? I mean, libraries like 
>>> YUI3 give me the option to add my own custom parameters to be passed down 
>>> to callback functions, to solve this exact problem.
>>>
>>> TIA!
>>>
>>>

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


Re: [nodejs] Re: Why no additional parameters in (async. node.js API) callback functions?

2012-12-12 Thread greelgorke
i meant not pure functionAL style, but pure 
functions: http://en.wikipedia.org/wiki/Pure_function
the state of the art at the moment is to use closures, which often are not 
pure functions. they close over some values from the parent scope, that is 
not under control of the closure itself. the closure scope acts as implicit 
parameter or state (or dependency) to that closure. that is the case where 
you need nesting closures.
Function#bind is one way to replace the need for closing over the parent 
context and reduce the nesting to the depth of 1 (without control 
structures). same would happen if the parameters would be carried over via 
the async-func itself. both methods make the implicit parameters from 
closure-scope explicit. the libs may add additional parameter, which may be 
a hash or an array, which should be carried other to the callback. 

but, all 3 ways will not really reduce callback spaghetti, in some cases 
the bind- and the param-carry-overapproach will even reduce readability, 
when the parts of an algorithm are separated into code, that calles the 
async function, and the closure, and the closure is defined somewhere apart 
from the caller, asume the onStat definition in a separate file (for 
reuse). you still have to chain the calls in some way. 

i think it's the matter of being used to. the nested callbacks seem to me 
sometimes to be just an async-replacement for heavy nested loop/condition 
statements:

for(file in files){
  if(fs.stat(file).isFile()){
theFile = fs.readFile(file)
if( theFile){
  //doSomething
}
  }
}

vs.

files.map(function(file){
  fs.stat(file,function(stats){
if(stats.isFile()){
  fs.readFile(file, function(err, theFile){
 //dosomething
  })
}
  })
})

so nesting the callbacks may be even helpfull, because they present the 
asyncronous algorithm in the same way as synchronous code would do. but of 
cause you could use aync lib to line up them more, but thats an other story.


Am Mittwoch, 12. Dezember 2012 12:21:58 UTC+1 schrieb Michael Hasenstein:
>
> CORRECTION, I take my last statement back, you DID add to the 
> conversation and I am a bad reader. 
>
> I had already considered the performance issue of having the API 
> functions not just call the callback, but also having to handle 
> OPTIONAL additional parameters, which in node.js might happen some 
> millions of times per second. 
>
> A definitive statement in that direction is what I'm actually looking 
> for, if THAT was indeed the reason. I dislike nesting my functions, 
> even though pure functional style would go A LOT deeper (with the 
> nesting) :) 
>
>
>
>
> On Wed, Dec 12, 2012 at 12:16 PM, Ruben Tan > 
> wrote: 
> > I think you meant "closure". clojure is a language running on JVM. 
> > 
> > On Wednesday, December 12, 2012 6:59:56 PM UTC+8, greelgorke wrote: 
> >> 
> >> why? its the simpliest and most common way, that's it. passing by 
> custom 
> >> params has to be implemented in the async function itself, there is no 
> >> native support in js nor node for this. and since use of clojures is 
> very 
> >> common in js world, mostly noone cares about it. but yes it may help to 
> >> un-clutter the callbacks a bit and helpt to build pure functions with 
> >> explicit parameters. but i doubt that it would be a performance 
> improvement, 
> >> because v8 optimized clojurescope-access very well, see here 
> >> http://jsperf.com/bind-vs-clojure/2 
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: Why no additional parameters in (async. node.js API) callback functions?

2012-12-12 Thread greelgorke
Well, DOM Event API defines the EventListener interface. you could do this:
document.body.addEventListener('click', 
{foo:'foo',handleEvent:function(ev){console.log(this.foo)}})
and this will print foo to your console, but thats, right. it's possible 
just to pass a function and most of devs do this and use closure scope 
instead or even bind.

Am Mittwoch, 12. Dezember 2012 16:35:50 UTC+1 schrieb Patrick Mueller:
>
> On Wednesday, December 12, 2012 4:36:29 AM UTC-5, Michael Hasenstein wrote:
>
>> ...
>>
>> So, can anyone enlighten me - and I MAY INDEED be simply incredibly 
>> stupid not to see the point without help - why node.js could not just let 
>> me add custom parameters for callbacks? Again: additional scope-producing 
>> functions are NOT OPTIMAL IMHO - it produces overhead both in the code and 
>> during runtime. There MUST be a reason, otherwise by now, node.js almost at 
>> version 0.9, would have been changed, wouldn't it? I mean, libraries like 
>> YUI3 give me the option to add my own custom parameters to be passed down 
>> to callback functions, to solve this exact problem.
>>
>
> I blame the folks who designed the DOM APIs, and entrenched this pattern 
> in people's minds.
>
> Over the years I've used various libraries in other languages with 
> callbacks, which allow you to register more than just a function with a 
> callback.  Typically either an "object", in which case the callback 
> function might be specified as the name of the method on the object, or a 
> "userdata" wad, which is just arbitrary data that is passed to the callback 
> as an additional parameter.  Or both!
>
> An example is VisualAge Smalltalk UI callbacks, as described here:
>
> 
> http://www.scribd.com/doc/53673525/142/Widget-Event-Handling-and-Callbacks
>
> Quick example:
>
> button
> addCallback: XmNactivateCallback
> receiver: self
> selector: #pressed:clientData:callData:
> clientData: someData.
>
> Which should be read as: "for the 'button' widget, call a callback when 
> the widget is activated (XmNactivateCallback).  The callback will send the 
> message #pressed:clientData:callData: with args [button someData 
> activateEventData] to the receiver (self)
>
> In JS, you could imagine it like this:
>
> button.addCallback("activate", this, "pressed", someData)
>
> where the "this" object in this scope has a method "pressed", that looks 
> like this:
>
> function pressed(eventObject, clientData, callData) {
> // eventObject == button
> // clientData == someData
> // callData == the event data
> }
>
> Of course, being Smalltalk, there were various shortened versions of the 
> #addCallback: method, when you didn't need to send client data, or needed 
> to pass a block instead of receiver/message, etc.
>
> Life was good. Or more declarative and less code-y anyway.
>
> Most JS libraries don't have any of this built-in.  You can only send a 
> function.  So the trick (as you know) is to hook all that other stuff up to 
> the function via bind(), or bind-by-hand by writing wrapping functions.
>
> You're starting to see more of this though; Backbone has a "context" 
> parameter for it's "on" function:
>
> http://backbonejs.org/#Events-on
>
> which lets you do things like this:
>
> model.on('change', this.render, this)
>
> which handles the case of passing a "this" in (the "receiver" parameter in 
> the Smalltalk example) for the render function, which immediately seems 
> like you'd want to pass in like this instead (but can't, right now):
>
> model.on('change', this, "render")
>
> You're not going to change the JS universe, which is seemingly stuck 
> forever in the "you only get to associate a function with a callback" mode, 
> but maybe you can build an easier pattern to do the bind, or something. 
>  Wonder if macros would help?  See:
>
> http://sweetjs.org/
>  
>

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


Re: [nodejs] "this" and that

2012-12-14 Thread greelgorke
and don't forget bind:

myFunc = foo.bind(bar)

baz.foo = myFunc

baz.foo() // this === bar,  not baz 

Am Freitag, 14. Dezember 2012 00:21:19 UTC+1 schrieb Michael Jackson:
>
> The best explanation I've ever heard for "this" in JavaScript:
>
> > The word "this" refers to whatever was on the left of the period when 
> the function was called. If nothing was, it refers to the global scope.
>
> Obviously this is a bit simplified because it doesn't take into account 
> Function#call/apply, but it is sufficient to explain the concept most of 
> the time. So, yes, "this" can be very useful if you know what is going to 
> be to the left of the period. It's also especially useful in functions that 
> are members of another function's prototype.
>
> --
> Michael Jackson
> @mjackson
>
>
>
> On Tue, Dec 11, 2012 at 1:46 PM, spqr >wrote:
>
>> I'm writing a fairly unusual type of node program that manages and runs 
>> JavaScript objects that the master program loads at start-up.
>> I don't want to go into more detail than that, but I do want to make one 
>> comment.  It seems to me that "this" as it is defined in 
>> JavaScript, is close to useless. Because I load my objects dynamically 
>> and call their functions via eval(), when they need to run, 
>> "this" never has a useful value.  Sure, I worked around it by getting a 
>> reference to the object I really want and passing it in to the
>> function as an argument (annoying and ugly, but workable).  I'm just 
>> curious if anyone really thinks 'this" is useful.  I've seen the
>> construct where you set a var in the object itself that is a reference to 
>> the object... honestly, that looks pretty "off" itself, but also
>> doesn't work when eval() is involved.  
>>
>> Is "this" in JavaScript really useful for anything?
>>
>> -- 
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines: 
>> https://github.com/joyent/node/wiki/Mailing-List-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


[nodejs] Re: Good error messages: Method's file location without stacktrace

2012-12-14 Thread greelgorke
taken from console.js in core:

exports.trace = function(label) {
  // TODO probably can to do this better with V8's debug object once that is
  // exposed.
  var err = new Error;
  err.name = 'Trace';
  err.message = label || '';
  Error.captureStackTrace(err, arguments.callee);
  console.error(err.stack);
};

Am Freitag, 14. Dezember 2012 08:06:24 UTC+1 schrieb Jonathan Dickinson:
>
> It looks like you can only do it with errors:
>
> (new Error()).stack
>
> Taking require() as an example (if you were in control of it) you would 
> make require() add the stack trace to the module before any code in the 
> module executes. Now within the context of the B load you find out that it 
> is a cycle back to A, so your require() method would do something like:
>
> function require(arg) {
>   var stackInfo = getStackInfo(arg);
>   if (stackInfo) {
>// We can do this because the 'prologue' of "A" would have populated 
> the stack trace in our internal modules set.
>throw new CycleError(getStackInfo(arg) + " [" + arg + "] has a cyclic 
> dependency with [" + currentModule + "] " + (new Error()).stack;
>   }
> }
>
> Alternatively you could require that your components advertise their 
> dependencies up-front (similar to package.json). You could then discover 
> cycles (and load order, by the way) before running anything using Tarjan's 
> Strong Connected Components Algorithm: 
> http://en.wikipedia.org/wiki/Tarjan's_strongly_connected_components_algorithm
> .
>
> At the end of the day though getting source information for a function 
> could be an amazing addition for so many development cases, especially 
> providing useful debugging info.
>
> On Friday, 14 December 2012 06:23:16 UTC+2, Martin Heidegger wrote:
>>
>> Hello everybody,
>>
>> I am writing on a system that should detect and resolve dependencies of 
>> code before executing it. So method A references method B so method B needs 
>> to be called before A. So far that works fine, however when I throw a 
>> circular dependency error message all the error message says is "[function] 
>> has a circular dependency to [function]"... thats very few information for 
>> debugging. I want to improve on that by at least displaying the line-number 
>> of the methods. So far I haven't found a way to do that. It should be 
>> possible because the VM should know where a method has been written (else 
>> it could not tell me the location on a stacktrace).
>>
>> Have I missed something? Is this worth a feature request?
>>
>> yours
>> Martin.
>>
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Maybe of interest: Why we need a NodeJS application server or: writing boilerplate code considered harmful

2012-12-15 Thread greelgorke
for me, it's more than freedom, but also an approach comes close to true 
modularisation: unix-philosophy. it's in node its rebuild with 
one-function-modules a la substack + simple but powerfull and flexible 
interface convention: callbacks + streams. if i think i need an application 
server, i'd rather go back to jee, ror or even .net if it fits my task.

but we for sure need some help in finding the right modules.

Am Samstag, 15. Dezember 2012 19:52:04 UTC+1 schrieb Mark Hahn:
>
> I'm sure many would appreciate such a comprehensive large framework. 
> I and many others in the node community would not. 
>
> One characteristic of the node "philosophy" is freedom.  The freedom 
> to plug existing small modules together like a lego set.  The freedom 
> to easily write our own modules.  The freedom to swap out modules for 
> others as better ones come along.  The freedom to make our 
> architecture unique while not writing code from scratch or even using 
> boilerplate. 
>
> If I had to live within the constraints of J2EE or ROR or even 
> Express, I would find another job.  My architecture migrates quickly 
> from project to project with each one more awesome than the last.  Any 
> existing framework would be outdated within a year as far as I am 
> concerned. 
>
> It is a new world.. 
>
> On Sat, Dec 15, 2012 at 2:13 AM, Angel Java Lopez 
> > 
> wrote: 
> > Hi people! 
> > 
> > Panyasan, very interesting... but I don't see the need of most of your 
> > items. Maybe you want not an "application server" (ooops I still 
> > remember J2EE... argg... ;-) but an "opinionated web framework" (like 
> Ruby 
> > on Rails wo/model code generation) (in the comments to your post, Geddy 
> was 
> > mentioned). 
> > 
> > Let's review: 
> > 
> > It should also not force a different programming model on developers 
> (like 
> > Opa or Meteor), but let you code in plain old asynchronous javascript. 
> No 
> > to-javascript-compilation (except optionally). No magic. Just the right 
> > tools. 
> > It exists. Node.js + Javascript ;-) 
> > 
> > It should have an integrated API for client and server. 
> > Can you elaborate this? 
> > 
> > It should provide a static HTTP server, REST routing, and bidirectional, 
> > realtime messaging and broadcasting (such as Socket.io). 
> > Then require('socket.io'); Why "static" for HTTP server? There is 
> middleware 
> > for Connect/Express. REST routing: it's not my area, but there are some 
> > modules. 
> > 
> > It should offer async startup/plugin/configuration system like 
> > Cloud9′sArchitect. 
> > Easy one (maybe some boilerplate for async support), or someone writing 
> it 
> > as a module, then require it; 
> > 
> > It should provide an out-of-the box system and API for user & group 
> > management, registration, access control, Password 
> storage/retrieval/update 
> > etc, preferrably with a set of built-in templates that can be used for 
> > managing the most generic configuration tasks. With this, a pluggable 
> system 
> > to use third-party authentication providers. 
> > ??? A bit: invoicing to users included, paypal system, etc. ;-) Ok, 
> again, 
> > it could be resolved with a module. 
> > 
> > It should also provide an integrated system of data modeling and 
> > persistence. I really do not care about database technology. I simply 
> want 
> > to store, edit and retrieve my model data. 
> > I work in many technologies, and all these or not needed, or provided by 
> a 
> > library and tools. 
> > 
> > t could also have a toolset that would allow you to deploy your 
> application 
> > instantly to a cloud provider such as Heroku or Nodejitsu. 
> > Again, Node.js 
> > 
> > Sorry if it sounds harsh, I don't manage English expressions and 
> variants, 
> > it's not my mother tongue. But IMNSHO, we don't need all that, unless 
> you 
> > like Ruby on Rails and alike (maybe Geddy). 
> > 
> > Other opinions? 
> > 
> > I think that that is the key point of your post: RoR-like or not 
> (Node.js 
> > community (or part of community) actually "prefers" Sinatra-like). 
> > "Application Server" term confused me. In my jargon, it's related to 
> things 
> > where the business logic, application resides, exposed to many kind of 
> > clients (web, desktop, no web, whatever the future will bring to us, 
> > etc) SAP uses that term too, a la J2EE (sorry for mention it again 
> ;-) 
> > 
> > Angel "Java" Lopez 
> > @ajlopez 
> > gh:ajlopez 
> > 
> > On Fri, Dec 14, 2012 at 10:51 AM, panyasan 
> > > 
> wrote: 
> >> 
> >> This is not strictly a technical question on node, so please excuse if 
> >> this is the wrong forum, but if you're interested, I'd like to hear 
> your 
> >> opinions on the following blog post: 
> >> 
> >> 
> >> 
> http://panyasan.wordpress.com/2012/12/10/why-we-need-a-nodejs-application-server-or-writing-boilerplate-considered-harmful
>  
> >> 
> >> 
> >> -- 
> >> Job Board: http://jobs.nodejs.org/ 
> >> Posting guidelines: 
> >> https://github.com/joyent/node/

Re: [nodejs] Maybe of interest: Why we need a NodeJS application server or: writing boilerplate code considered harmful

2012-12-15 Thread greelgorke
in fact we have allready several "stacks" for web development, which are 
something like ou wish: the connect-stack including express and comatible 
stuff like passport. flatiron is another one. there are even frameworks on 
top of them preselecting stuff, like all the ror-clones: geddy, tower, 
railways etc. all the stuff is allready there, with freedom and 
preselection.
but as said before, node don't claim to be chimera making everything 
possible. there are some classes of usecases where node just fits, and 
classical web development is not that case. we dont even have this problem. 
our problem is to know, which case is better solved by node, and then to 
find the right modules.

i think that a thing like an application server is just one solution to the 
problem: (1)how to find the right libraries, (2)integrate them and 
(3)ensure they evolve and are maintained.
1: improve the search and combine it with ranking including usage 
statistics, reputation and activity of the project. there is workinprogress 
on it.
2: simplify apis, split them into smaller one, follow conventions and 
patterns like callbacks and streams. in the end of the day we all depend on 
core libs, so make them as smalles denominator in your api. and we do it 
already.
3: this is the community thing, want to ensure maintanace and progress? 
contribute and give the community something back! you can do it with 
workforce or sponsoring. this is how node evolved. but for sure we need 
more communication at creating of packages. too foten happens that two or 
more libs arise only because the maintainers cant work together, because of 
detail discussion.

Am Samstag, 15. Dezember 2012 22:36:41 UTC+1 schrieb panyasan:
>
> Hi Ben, hi everybody,
>
> while I appreciate all the answers including the critical ones, I think 
> only Ben really understood what I was aiming at. Probably the term 
> "application server" was not appropriate. I didn't ask for a big monolithic 
> system. My claim was that web applications have a certain set of features 
> in common (some of which are in the list in my post), which are really 
> generic ("the boilerplate"). It makes absolutely no sense to implement them 
> again and again, maintain them, write tests, etc. when they could really be 
> bundled together and maintained by a community of people who need this 
> functionality. If you're a professional, full-time developer, you're 
> probably best of with creating this kind of stuff yourself. But my argument 
> was that a lot of potential is lost because of the fragmentation ("the 
> freedom to choose") in the node module ecosystem. Discovering modules is 
> not the problem in my opinion - maintaining them in a longer-term 
> perspective is
>
>
>
>
> Am Samstag, 15. Dezember 2012 20:30:16 UTC+1 schrieb Ben Noordhuis:
>>
>> On Sat, Dec 15, 2012 at 7:52 PM, Mark Hahn  wrote: 
>> > I'm sure many would appreciate such a comprehensive large framework. 
>> > I and many others in the node community would not. 
>> > 
>> > One characteristic of the node "philosophy" is freedom.  The freedom 
>> > to plug existing small modules together like a lego set.  The freedom 
>> > to easily write our own modules.  The freedom to swap out modules for 
>> > others as better ones come along.  The freedom to make our 
>> > architecture unique while not writing code from scratch or even using 
>> > boilerplate. 
>> > 
>> > If I had to live within the constraints of J2EE or ROR or even 
>> > Express, I would find another job.  My architecture migrates quickly 
>> > from project to project with each one more awesome than the last.  Any 
>> > existing framework would be outdated within a year as far as I am 
>> > concerned. 
>> > 
>> > It is a new world.. 
>>
>> A node.js "application server" is something Bert Belder and I have 
>> been discussing. 
>>
>> The proliferation (and wildly varying quality) of modules and 
>> frameworks seems to be holding back node.js to some degree.  I talk to 
>> a lot of developers and it's one of the most common complaints: 
>> "There's too much choice, we don't know what to use." 
>>
>> The idea is to have a curated list of modules with appropriate 
>> stability and support guarantees.  If you find a bug, we'll make sure 
>> it gets fixed in a timely manner; you won't be at the mercy of the 
>> module author. 
>>
>> That gives the developer a stable, known-good base to start out with 
>> while preserving the freedom to use whatever he wants.  It should also 
>> take away the cold feet that some businesses have. 
>>
>

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

Re: [nodejs] describe is not defined

2012-12-25 Thread greelgorke
you need a describe in it to mark it as a test. mocha doesn't simply 
'require' your test files 

Am Dienstag, 25. Dezember 2012 09:29:20 UTC+1 schrieb Artur Vinogradov:
>
> Thank you, Martin. I solved my problems, but there's another question: 
> everything seems to work, test are running, but when i try to implement 
> http.get logic - it doesn't work. the code
>
> var http = require('http');
>
> http.get("http://www.google.com/index.html";, function(res) {
>  console.log("Got response: " + res.statusCode);
> }).on('error', function(e) {
>  console.log("Got error: " + e.message);
> });
>
> when I run "mocha" in console just writes "0 tests complete (0 ms)", 
> without logging anything.
>
> понедельник, 24 декабря 2012 г., 18:32:53 UTC+2 пользователь Martin Cooper 
> написал:
>>
>>
>>
>> On Mon, Dec 24, 2012 at 12:18 AM, Artur Vinogradov 
>> wrote:
>>
>>> I installed mocha with -g parameter, though it's not been working for me 
>>> with other modules: I always had to link them, so that i can require them.
>>>
>>
>> It looks like you're not starting mocha properly. You shouldn't have that 
>> require of 'mocha' in there, and you need to be starting this using 'mocha' 
>> on the command line.
>>
>> The thing with mocha is that it doesn't just require your test module. It 
>> loads it into a special context, which is where global functions like 
>> 'describe' come from. In your case, 'describe' is not defined almost 
>> certainly because mocha was not started properly.
>>
>> --
>> Martin Cooper
>>  
>>
>> This is my code:
>>>
>>> var Mocha = require('mocha');
>>>
>>> var assert = require("assert")
>>> describe('Array', function(){
>>>   describe('#indexOf()', function(){
>>> it('should return -1 when the value is not present', function(){
>>>   assert.equal(-1, [1,2,3].indexOf(5));
>>>   assert.equal(-1, [1,2,3].indexOf(0));
>>> })
>>>   })
>>> })
>>>
>>> ReferenceError: describe is not defined
>>> at Object. (/home/user/mocha/prog.js:3:1)
>>> at Module._compile (module.js:449:26)
>>> at Object.Module._extensions..js (module.js:467:10)
>>> at Module.load (module.js:356:32)
>>> at Function.Module._load (module.js:312:12)
>>> at Module.runMain (module.js:492:10)
>>> at process.startup.processNextTick.process._tickCallback 
>>> (node.js:244:9)
>>>
>>>  -- 
>>> Job Board: http://jobs.nodejs.org/
>>> Posting guidelines: 
>>> https://github.com/joyent/node/wiki/Mailing-List-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


[nodejs] Re: Separation of requests within a node process

2012-12-28 Thread greelgorke
the request+response objects hold links to the related connection, wich is 
linked to the socket opened up on accept. 

all things are kept in the event loop, events and event handlers which have 
links to related objects. this objects are either passed by as params or 
via closure scope (or other qay of bypassing). so the state is kept in the 
current state of the callback chain.

Am Donnerstag, 27. Dezember 2012 23:55:20 UTC+1 schrieb 
martin@education.ky.gov:
>
> Hi,
>
> I expect there is something written on this already, and I'd be happy to 
> be pointed to it.  I haven't figured out what search keywords to use.
>
> As I understand it, a nodejs process may be dealing with multiple requests 
> concurrently.  In an http scenario, user 1's request/response objects may 
> be inactive - perhaps waiting for a DBMS query to complete - when user 2's 
> http request is received.  These are not handled by independent, 
> synchronous threads, but some sort of state/session data/objects/handles 
> are kept separate for user 1's request and user 2's request - otherwise 
> node would not know which TCP connection should get the query results, etc.
>
> So is everything related to each request encapsulated with the 
> request/response objects or object instances?  Or is there other "state" 
> related stuff  that is visible somewhere?  
>
> thanks
>
> Martin
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: new concept for structured asynchronous programming

2012-12-28 Thread greelgorke
just a question: how differs your solution 
from https://github.com/caolan/async#series ?

Am Freitag, 28. Dezember 2012 02:03:11 UTC+1 schrieb Tatumizer:
>
> I'm trying to come up with a better concept for asynchronous programming. 
> My first library (mesh.js) was an attempt to use a promising line of 
> attack, but it introduced a lot of boilerplate, which no one liked (myself 
> included).. 
>
> After a lot of head-scratching, I found the way to eliminate all 
> boilerplate and syntactic noise, and eventually came up with completely new 
> design -much simpler one, and much more powerful: just two functions and 
> their combinations do the job in most practical cases. I renamed the 
> concept to "circuit" - it's a better name for this device.
>
> https://github.com/tatumizer/circuit/blob/master/README.md
>
> At this stage, it's a design doc only, specifically targeting nodejs. I 
> think the concept of circuit could simplify nodejs programming..
> What is equally important that it uses all existing nodejs conventions and 
> interfaces AS IS: no code generation, no wrappers, no conversions of f(x,y) 
> into fubar(f,x,y) or anything - just pure nodejs code.
>
> I would be very interested to know opinions (even negative opinions) to 
> improve design and find  potential flaws. 
>
> 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


[nodejs] Re: How do you work with decimal numbers so that the precision problem of floats is under control?

2012-12-28 Thread greelgorke
the handling as integers is the simple way. but does not always viable with 
different currency etc. this list may help you: 
https://npmjs.org/browse/keyword/money 

Am Freitag, 28. Dezember 2012 21:34:47 UTC+1 schrieb Kevin Purnelle:
>
> Hello, 
>
> I am building my first app with nodeJS and I am very excited about 
> everything I have been learning with nodejs until now.
> My concerns are about numbers, which can't be represented precisely with 
> the current specs for floating point numbers in js (not only js, I know)
> In that application I have to handle money, so calculations and storage of 
> these values must be error free.
>
> The app is built with AngularJS, nodeJS (with express) and Mongodb
>
> Could anybody indicates how to handle numbers: from the time when the user 
> fills the form to the time when the value is stored into the database and 
> then, presented again to the user?
>
> So far, I've read that people advise to store money values as integers 
> (so, stored in cents) but I would like to know if somebody has already 
> faced that problem and how it was solved. 
>
> Thank you :)
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Inconsistent method names?

2012-12-28 Thread greelgorke
psst.. i heard underscore have some cool tools for the typeof pain, 
like http://underscorejs.org/#isArray

Am Donnerstag, 27. Dezember 2012 22:32:03 UTC+1 schrieb Mark Hahn:
>
> >  what sort of program scenarios you've found yourself in where 
> instanceof was the "go to" solution 
>
> I use typeof a lot, but instanceof not so often.  I sometimes use 
> instanceof Array when I don't have a helper around for that. 
>
> I've just started a module for use in node and the client that "fixes" 
> these as much as possible.  It is annoying when I get an error just 
> because of lack of camelCasing.  My mind isn't good at remembering 
> minor things. 
>
> Does anyone know how I could fix typeof in node?  I can see how to do 
> it in the client.  Luckily I'm using coffeescript so making typeOf a 
> function will be used like `typeOf x` and it will look the same as 
> typeof `x`. 
>
> > Completely irrelevant to the discussion... 
>
> What is irrelevant? 
>
> On Thu, Dec 27, 2012 at 1:06 PM, Rick Waldron 
> > 
> wrote: 
> > Inline... 
> > 
> > 
> > On Thursday, December 27, 2012, Mark Hahn wrote: 
> >> 
> >> Why not also allow readDir?  It would cause no harm to do so. 
> >> 
> >> This isn't node, but what also bugs me is typeof and instanceof.  I 
> >> cringe every time I type them. 
> > 
> > 
> > Completely irrelevant to the discussion... but you have my attention 
> now—I'm 
> > curious to know what sort of program scenarios you've found yourself in 
> > where instanceof was the "go to" solution (but painful to use?), aside 
> from 
> > useful type checking (types as in "object types", not as in 
> "data-types"). 
> > If you want to know if x has Foo constructor in its prototype chain, 
> > instanceof has you covered. 
> > 
> > Rick 
> > 
> > 
> >> 
> >> 
> >> 
> >> On Thu, Dec 27, 2012 at 11:47 AM, David Habereder 
> >> > wrote: 
> >> > That clears that up. Thanks. 
> >> > 
> >> > Am Donnerstag, 27. Dezember 2012 20:36:30 UTC+1 schrieb Matt 
> Sergeant: 
> >> >> 
> >> >> I think you'll likely find where it isn't the case (such as readdir) 
> >> >> the 
> >> >> name comes from the POSIX function name. There's no readfile 
> function 
> >> >> in 
> >> >> POSIX, but there is readdir(). The only other case seems to be 
> >> >> readlink, 
> >> >> which is the same issue. 
> >> >> 
> >> >> http://linux.die.net/man/2/readdir 
> >> >> http://linux.die.net/man/2/readlink 
> >> >> 
> >> >> 
> >> >> On Thu, Dec 27, 2012 at 1:02 PM, David Habereder <
> david.h...@gmail.com> 
> >> >> wrote: 
> >> >>> 
> >> >>> Hi, 
> >> >>> 
> >> >>> I am quite new to node.js. 
> >> >>> 
> >> >>> As far as I can see the method names aren't very consistent. Take 
> the 
> >> >>> methods from File System for example: http://nodejs.org/api/fs.html 
> >> >>> It is ".readFile" (Camelcase) 
> >> >>> But it is ".readdir" (all lowercase) 
> >> >>> 
> >> >>> There are a few more such cases where I don't see a pattern when 
> >> >>> camelcase is used and when not. 
> >> >>> 
> >> >>> You could say that this is absolutely irrelevant and you would be 
> >> >>> right. 
> >> >>> But it annoys me :-( 
> >> >>> And it reminds me of PHP syntax garbage. 
> >> >>> 
> >> >>> Is there any interest in getting all method names either camelcase 
> or 
> >> >>> lowercase, or will this just stay as is? 
> >> >>> 
> >> >>> ~dave 
> >> >>> 
> >> >>> -- 
> >> >>> Job Board: http://jobs.nodejs.org/ 
> >> >>> Posting guidelines: 
> >> >>> https://github.com/joyent/node/wiki/Mailing-List-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 
> >> > 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 nod...@googlegroups.com 
> >> To unsubscribe from this group, send email to 
> >> nodejs+unsubscribe@go 
> > 
> > -- 
> > Job Board: http://jobs.nodejs.org/ 
> > Posting guidelines: 
> > https://github.com/joyent/node/wiki/Mailing-Li

Re: [nodejs] Inconsistent method names?

2012-12-28 Thread greelgorke
look further, there is more than just isArray. AND underscore falls back to 
native implementations, if any present. and it's just it: same interface 
for every plattform.

Am Freitag, 28. Dezember 2012 22:31:28 UTC+1 schrieb Rick Waldron:
>
>
>
> On Friday, December 28, 2012, greelgorke wrote:
>
>> psst.. i heard underscore have some cool tools for the typeof pain, like 
>> http://underscorejs.org/#isArray
>
>
> *facepalm*
>
> Really? On a platform that supports Array.isArray built-in?
>
> Rick
>  
>
>>
>> Am Donnerstag, 27. Dezember 2012 22:32:03 UTC+1 schrieb Mark Hahn:
>>>
>>> >  what sort of program scenarios you've found yourself in where 
>>> instanceof was the "go to" solution 
>>>
>>> I use typeof a lot, but instanceof not so often.  I sometimes use 
>>> instanceof Array when I don't have a helper around for that. 
>>>
>>> I've just started a module for use in node and the client that "fixes" 
>>> these as much as possible.  It is annoying when I get an error just 
>>> because of lack of camelCasing.  My mind isn't good at remembering 
>>> minor things. 
>>>
>>> Does anyone know how I could fix typeof in node?  I can see how to do 
>>> it in the client.  Luckily I'm using coffeescript so making typeOf a 
>>> function will be used like `typeOf x` and it will look the same as 
>>> typeof `x`. 
>>>
>>> > Completely irrelevant to the discussion... 
>>>
>>> What is irrelevant? 
>>>
>>> On Thu, Dec 27, 2012 at 1:06 PM, Rick Waldron  
>>> wrote: 
>>> > Inline... 
>>> > 
>>> > 
>>> > On Thursday, December 27, 2012, Mark Hahn wrote: 
>>> >> 
>>> >> Why not also allow readDir?  It would cause no harm to do so. 
>>> >> 
>>> >> This isn't node, but what also bugs me is typeof and instanceof.  I 
>>> >> cringe every time I type them. 
>>> > 
>>> > 
>>> > Completely irrelevant to the discussion... but you have my attention 
>>> now—I'm 
>>> > curious to know what sort of program scenarios you've found yourself 
>>> in 
>>> > where instanceof was the "go to" solution (but painful to use?), aside 
>>> from 
>>> > useful type checking (types as in "object types", not as in 
>>> "data-types"). 
>>> > If you want to know if x has Foo constructor in its prototype chain, 
>>> > instanceof has you covered. 
>>> > 
>>> > Rick 
>>> > 
>>> > 
>>> >> 
>>> >> 
>>> >> 
>>> >> On Thu, Dec 27, 2012 at 11:47 AM, David Habereder 
>>> >>  wrote: 
>>> >> > That clears that up. Thanks. 
>>> >> > 
>>> >> > Am Donnerstag, 27. Dezember 2012 20:36:30 UTC+1 schrieb Matt 
>>> Sergeant: 
>>> >> >> 
>>> >> >> I think you'll likely find where it isn't the case (such as 
>>> readdir) 
>>> >> >> the 
>>> >> >> name comes from the POSIX function name. There's no readfile 
>>> function 
>>> >> >> in 
>>> >> >> POSIX, but there is readdir(). The only other case seems to be 
>>> >> >> readlink, 
>>> >> >> which is the same issue. 
>>> >> >> 
>>> >> >> http://linux.die.net/man/2/**readdir<http://linux.die.net/man/2/readdir>
>>> >> >>  
>>> >> >> http://linux.die.net/man/2/**readlink<http://linux.die.net/man/2/readlink>
>>> >> >>  
>>> >> >> 
>>> >> >> 
>>> >> >> On Thu, Dec 27, 2012 at 1:02 PM, David Habereder <
>>> david.h...@gmail.com> 
>>> >> >> wrote: 
>>> >> >>> 
>>> >> >>> Hi, 
>>> >> >>> 
>>> >> >>> I am quite new to node.js. 
>>> >> >>> 
>>> >> >>> As far as I can see the method names aren't very consistent. Take 
>>> the 
>>> >> >>> methods from File System for example: 
>>> http://nodejs.org/api/fs.html 
>>> >> >>> It is ".readFile" (Camelcase) 
>>> >> >>> But it is ".readdir

Re: [nodejs] Inconsistent method names?

2012-12-28 Thread greelgorke
well, yes, you are right at this point. Mark said, he uses much of typeof 
and sometimes instanceof for Array detection. So, his use case may be a 
good one for underscore. but if you just want this one single function, it 
is an overkill, but even then it's worth to look at its code and just take 
the picks you need, and use them. it's MIT

> Furthermore, underscore has a nasty history of not correctly matching 
native implementations
is this a claim like: "don't use it, because it had bugs earlier"? huh?

Am Freitag, 28. Dezember 2012 23:03:27 UTC+1 schrieb Rick Waldron:
>
>
>
> On Friday, December 28, 2012, greelgorke wrote:
>
>> look further, there is more than just isArray. AND underscore falls back 
>> to native implementations, if any present. and it's just it: same interface 
>> for every plattform.
>
>
> Yes, I'm very aware of underscore, thank you. I don't believe in adding a 
> full on library for the sake of using a single function that language 
> already offers natively. Furthermore, underscore has a nasty history of not 
> correctly matching native implementations, so lucky you: same API, 
> different behaviour.
>
> The only platforms that don't support Array.isArray are old IEs.  
>
>
> Rick
>
>
>
>> Am Freitag, 28. Dezember 2012 22:31:28 UTC+1 schrieb Rick Waldron:
>>
>>
>>
>> On Friday, December 28, 2012, greelgorke wrote:
>>
>> psst.. i heard underscore have some cool tools for the typeof pain, like 
>> http://underscorejs.org/#**isArray <http://underscorejs.org/#isArray>
>>
>>
>> *facepalm*
>>
>> Really? On a platform that supports Array.isArray built-in?
>>
>> Rick
>>  
>>
>>
>> Am Donnerstag, 27. Dezember 2012 22:32:03 UTC+1 schrieb Mark Hahn:
>>
>> >  what sort of program scenarios you've found yourself in where 
>> instanceof was the "go to" solution 
>>
>> I use typeof a lot, but instanceof not so often.  I sometimes use 
>> instanceof Array when I don't have a helper around for that. 
>>
>> I've just started a module for use in node and the client that "fixes" 
>> these as much as possible.  It is annoying when I get an error just 
>> because of lack of camelCasing.  My mind isn't good at remembering 
>> minor things. 
>>
>> Does anyone know how I could fix typeof in node?  I can see how to do 
>> it in the client.  Luckily I'm using coffeescript so making typeOf a 
>> function will be used like `typeOf x` and it will look the same as 
>> typeof `x`. 
>>
>> > Completely irrelevant to the discussion... 
>>
>> What is irrelevant? 
>>
>> On Thu, Dec 27, 2012 at 1:06 PM, Rick Waldron  
>> wrote: 
>> > Inline... 
>> > 
>> > 
>> > On Thursday, December 27, 2012, Mark Hahn wrote: 
>> >> 
>> >> Why not also allow readDir?  It would cause no harm to do so. 
>> >> 
>> >> This isn't node, but what also bugs me is typeof and instanceof.  I 
>> >> cringe every time I type them. 
>> > 
>> > 
>> > Completely irrelevant to the discussion... but you have my attention 
>> now—I'm 
>> > curious to know what sort of program scenarios you've found yourself in 
>> > where instanceof was the "go to" solution (but painful to use?), aside 
>> from 
>> > useful type checking (types as in "object types", not as in 
>> "data-types"). 
>> > If you want to know if x has Foo constructor in its prototype chain, 
>> > instanceof has you covered. 
>> > 
>> > Rick 
>> > 
>> > 
>> >> 
>> >> 
>> >> 
>> >> On Thu, Dec 27, 2012 at 11:47 AM, David Habereder 
>> >>  wrote: 
>> >> > That clears that up. Thanks. 
>> >> > 
>> >> > Am Donnerstag, 27. Dezember 2012 20:36:30 UTC+1 schrieb Matt 
>> Sergeant: 
>> >> >> 
>> >> >> I think you'll likely find where it isn't the case (such as 
>> readdir) 
>> >> >> the 
>> >> >> name comes from the POSIX function name. There's no readfile 
>> function 
>> >> >> in 
>> >> >> POSIX, but there is readdir(). The only other case seems to be 
>> >> >> readlink, 
>> >> >> which is the same issue. 
>> >> >> 
>> >> >> http://linux.die.net/man/2/**rea**ddir<http://linux.die.net/man/2/read

Re: [nodejs] Inconsistent method names?

2012-12-29 Thread greelgorke
ah this. well it's ok, that underscore does not match native API. 
underscore is not a shim, it uses nativ implementations under the hood, if 
any present. this is ok. it uses it's own api and not implement the 
standard. anyway, underscore IS one solution, may be a better in some 
cases, for a bunch of tasks. even if its to big to include, one still could 
copy some implementations for own use.

Am Samstag, 29. Dezember 2012 00:04:36 UTC+1 schrieb Rick Waldron:
>
>
>
> On Friday, December 28, 2012, greelgorke wrote:
>
>> well, yes, you are right at this point. Mark said, he uses much of typeof 
>> and sometimes instanceof for Array detection. So, his use case may be a 
>> good one for underscore. but if you just want this one single function, it 
>> is an overkill, but even then it's worth to look at its code and just take 
>> the picks you need, and use them. it's MIT
>>
>> > Furthermore, underscore has a nasty history of not correctly matching 
>> native implementations
>> is this a claim like: "don't use it, because it had bugs earlier"? huh?
>>
>
> No, because they still exist. Natives have sparse array handling, 
> underscore does not. indexOf has some made up third param that isn't 
> fromIndex. 
>
> Anything else?
>
> Rick
>
>
>
>
>> Am Freitag, 28. Dezember 2012 23:03:27 UTC+1 schrieb Rick Waldron:
>>
>>
>>
>> On Friday, December 28, 2012, greelgorke wrote:
>>
>> look further, there is more than just isArray. AND underscore falls back 
>> to native implementations, if any present. and it's just it: same interface 
>> for every plattform.
>>
>>
>> Yes, I'm very aware of underscore, thank you. I don't believe in adding a 
>> full on library for the sake of using a single function that language 
>> already offers natively. Furthermore, underscore has a nasty history of not 
>> correctly matching native implementations, so lucky you: same API, 
>> different behaviour.
>>
>> The only platforms that don't support Array.isArray are old IEs.  
>>
>>
>> Rick
>>
>>
>>
>> Am Freitag, 28. Dezember 2012 22:31:28 UTC+1 schrieb Rick Waldron:
>>
>>
>>
>> On Friday, December 28, 2012, greelgorke wrote:
>>
>> psst.. i heard underscore have some cool tools for the typeof pain, like 
>> http://underscorejs.org/#isArray <http://underscorejs.org/#isArray>
>>
>>
>> *facepalm*
>>
>> Really? On a platform that supports Array.isArray built-in?
>>
>> Rick
>>  
>>
>>
>> Am Donnerstag, 27. Dezember 2012 22:32:03 UTC+1 schrieb Mark Hahn:
>>
>> >  what sort of program scenarios you've found yourself in where 
>> instanceof was the "go to" solution 
>>
>> I use typeof a lot, but instanceof not so often.  I sometimes use 
>> instanceof Array when I don't have a helper around for that. 
>>
>> I've just started a module for use in node and the client that "fixes" 
>> these as much as possible.  It is annoying when I get an error just 
>> because of lack of camelCasing.  My mind isn't good at remembering 
>> minor things. 
>>
>> Does anyone know how I could fix typeof in node?  I can see how to do 
>> it in the client.  Luckily I'm using coffeescript so making typeOf a 
>> function will be used like `typeOf x` and it will look the same as 
>> typeof `x`. 
>>
>> > Completely irrelevant to the discussion... 
>>
>> What is irrelevant? 
>>
>> On Thu, Dec 27, 2012 at 1:06 PM, Rick Waldron  
>> wrote: 
>> > Inline... 
>> > 
>> > 
>> > On Thursday, December 27, 2012, Mark Hahn wrote: 
>> >> 
>> >> Why not also allow readDir?  It would cause no harm to do so. 
>> >> 
>> >> This isn't node, but what also bugs me is typeof and instanceof.  I 
>> >> cringe every time I type them. 
>> > 
>> > 
>> > Completely irrelevant to the discussion... but you have my attention 
>> now—I'm 
>> > curious to know what sort of program scenarios you've found yourself in 
>> > where instanceof was the "go to" solution (but painful to use?), aside 
>> from 
>> > useful type checking (types as in "object types", not as in 
>> "data-types"). 
>> > If you want to know if x has Foo constructor in its prototype chain, 
>> > instanceof has you covered. 
>> > 
>> > Rick 
>> > 
>

Re: [nodejs] new concept for structured asynchronous programming

2012-12-30 Thread greelgorke
@Mark: kudos for you. totally right. I think, that all the claims about how 
bad async coding style is, just comes because the developers come from 
languages, which do not know this style. its only unfamiliarity with this 
paradigm. i guess subroutines had a hard start too as they appeared.

callback chains can be hard to maintain, but long sequential methods, 
deeply nested control structures, wide-spread call hierarchy also. there 
are built in methods to reduce nesting, EventEmitters + Streams, If you 
design your code to reduce the need of closures, you can just write simple 
functions like Marks example, so your code has a max nesting of 2, the 
function itself and simple if-else or if-return checks. 

i think it's not only good to write own async-lib, it's worth to look into 
functional languages as Haskel, LISP, Scala to understand how functional 
code can be written.  

Am Sonntag, 30. Dezember 2012 06:16:58 UTC+1 schrieb Mark Hahn:
>
> > Imagine writing program consisting of 300 async calls
>
> My app currently has several thousand such calls.  
>  
> >  If nodejs team believes current solutions are optimal
>
> There is no optimal solution.  If there were one everyone would jump on it.
>
> I think it is great that you developed an interesting approach to the 
> async problem.  I think every programmer new to node should write an async 
> library.  I wrote such a library and I learned a lot, not just about 
> programming node, but about the nature of async code.  I used it for a 
> while.
>
> Over the last several years I have found it easier and easier to just use 
> "boilerplate" as you described it.  Here are some examples ...
>
> *Linear code ...
> *
> doThing1 = ->
> blah blah blah
> doThing2()
>
> doThing2 = ->
> blah blah blah
> done()
>
> doThing1()
>
>
> *Looping ...*
>
> angryBirds = [bird1, bird2, bird3]
> do flingOneBird = ->
> if not (bird = angryBirds.shift()) then done(); return
> bird.fling()
> flingOneBird()
>
> I have used this boilerplate so many times that I can type it without 
> thinking.  It has also become very easy to read.  I don't think it is hard 
> for others to read, but I may be wrong.
>
>

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


[nodejs] Re: Revisiting "error" events in EventEmitter

2012-12-30 Thread greelgorke
whats the problem? if you want to change the halting you have option

4. assign a handler to process.on 'unhandledException' and override 
standard 
behaivor: http://nodejs.org/api/all.html#all_event_uncaughtexception
5. run your app in a domain and handle all your "knownly ignored error 
events" here at once: http://nodejs.org/api/all.html#all_domain

:)

Am Samstag, 29. Dezember 2012 21:02:45 UTC+1 schrieb Jeff Lee:
>
> A modest proposal: throwing errors on uncaught 'error' events in 
> EventEmitter should be made optional, rather than mandatory.
>
> Looking back at the original thread that proposed the throwing behavior (
> https://groups.google.com/d/topic/nodejs/7BU_1BB9zeM/discussion), I'm 
> surprised at how little debate there was about adding built-in special-case 
> events to a general library class. The throwing behavior seems like an 
> abstraction flaw. Event handles are an "userspace" concept, and the 
> lib/runtime shouldn't be imposing semantics on that. In particular, 'error' 
> is a very generic term, and useful enough that it ought to be reserved for 
> whatever the app intends for it.
>
> For example, I might have an app that produces "success" or "error" 
> events. The "error" events may even be anticipated and normal within the 
> concept space of the app. They may be being broadcast simply for logging 
> hooks--if I care to log "error" events, I'll listen for them, but if I 
> don't care, I shouldn't be required to install a listener to prevent the 
> app from halting. You might argue that I should rename the "error" event to 
> "failure" or some other term, but that seems awfully heavy-handed. If 
> variable naming truly is one of the hard problems of computer science, then 
> event naming is similarly difficult, and as such it's a little rude for the 
> API to impose any restrictions, especially for such a semantically 
> ambiguous term. 
>
> Of course, it's probably not feasible at this point to remove throwing 
> behavior from the API entirely, but it seems fairly easy to change it to a 
> switchable default. One could imagine a lot of different ways of 
> implementing this using module-level configuration:
>
> 1. A simple on/off boolean property
> 2. A method that lets you set the name of the 'error' event, or blank if 
> you don't want the automatic throwing
> 3. A method that lets you set a common callback for all emitters that 
> aren't handling 'error'.
>
> Personally, I prefer some combination of 2 and 3. In any case, if there's 
> interest from the community, I'd be happy to contribute a pull request for 
> 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


[nodejs] Re: GroupBy

2013-01-01 Thread greelgorke
i guess, you have to put null as second param between conditions and fields

Am Dienstag, 1. Januar 2013 07:35:33 UTC+1 schrieb ayaz ali:
>
> Hello how to use group by in mongoose i have tried this but it displays 
> undefined 
>
> Model.find({}, [], {'group': 'FIELD'}, function(err, logs) {
>
>   // code
>
> });
>
> MessageModel.find({'messageTo':userName, "deliveredStatus":false}, {'group': 
> 'messageFrom'}, (function (err, MessageModel) {
> var returnData;
> if(err){
> return cb(err.message);
> } else
> {
> cb(null, chatMessageModel);
> }
>
> cb(null, returnData);
> }));
> any one please help me 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


[nodejs] Re: Is this a good scenario for using Node.js?

2013-01-07 Thread greelgorke
you mean something like this http://mite.yo.lk/en/ ? 

yes node.js would be a good fit, at least as good as RoR or 
Django+Backbone.js

Am Montag, 7. Januar 2013 16:25:41 UTC+1 schrieb abhpdk:
>
> Hey guys, Please bear with me. This is very much a noob question.
>
> A couple of my friends and me are planning to make a time tracking web 
> application. Between us we have experience in Java, C++, Django and 
> Backbone.js, though we have never made any full fledged commercial 
> application. This is our first real project and we wanted a bit more 
> clarity before learning nodejs.
>
> More about the app:
>
>- Users will use this application through out the day to log various 
>tasks (sort of like a task management application)
>- Track the time spent on these tasks (time tracking)
>- Users do not interact with each other's tasks.
>- We expect users to use this app continuously throughout the day
>
> So we want the app to have high Performance. We also foresee making native 
> mobile applications (ios & Android) in the future, which can work with the 
> same API used for the web. JSON and javascript are very appealing due to 
> this. We also don't want to re-write code on the client and server.
>
> Is node.js a good fit for this scenario? What advantages would it have 
> over, say Django+Backbone.js?
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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 web interface to execute and handle the Perl & Shell backed process.

2013-01-08 Thread greelgorke
the answer is: it depends. Node is a good choice to offer a webinterface to 
a conglomerate of scripts on os level. in fact this is the big strength of 
node to handle much i/o. But the question about rewriting has nothing to do 
with it, it's higher order question:
- are your scripts doing their jobs properly? are they easy to maintain? if 
yes, then let them be. if no and they need a rewrite, then node might be a 
good way here too.
- what tasks are this? node is not good at heavy calculations, usually we 
spin up a new process or call another script for it, i.E. we call 
imagemagick for resizing images in our service via child_process. 

you have to go through your scripts and answer this questions.  

Am Dienstag, 8. Januar 2013 03:39:25 UTC+1 schrieb Suraj Singh Thapa:
>
> Thanks Tim,
>
> Performance wise do you consider having Perl/shell script in back-end and 
> node as front-end is a good architecture? or is it better to re-write task 
> done by Perl in node. I want to have clear idea about, 
>
>  - Is it better to use node just as a bridge between webpage and 
> Perl/Shell.
>
>
> Any kind of suggestion would be appreciated.
>
> Cheers, 
>
>   
>
>
> On Tuesday, January 8, 2013 3:14:38 AM UTC+11, Tim Caswell wrote:
>>
>> Node can easily call other processes and has full control over the stdio 
>> streams if desired. (or there are convenience wrappers if you don't need 
>> full control)  Look at the child_process APIs.
>>
>>
>> On Sun, Jan 6, 2013 at 9:41 PM, Suraj Singh Thapa 
>> wrote:
>>
>>> Hi, I have number of the Perl and shell scripts in server(Linux) to 
>>> automate the software build process. I want to 
>>> create web interface so that other user can easily run my scripts. 
>>> * Have a webpage, user select the field and press button to launch 
>>> corresponding process. 
>>>  * webpage should show progress, Perl/shell script standard output 
>>> running in server.
>>>
>>> Could some one can suggest me if Node can be used as my fronted to 
>>> create web interface?
>>> As I am novice so any suggestion from experience people will 
>>> be appreciated. 
>>>
>>> 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


Re: [nodejs] Re: new concept for structured asynchronous programming

2013-01-10 Thread greelgorke
@Eldar: thank you for the link to this paper. very interesting.

Am Samstag, 29. Dezember 2012 09:16:39 UTC+1 schrieb Eldar:
>
> @Raynos, @greelgorke I would recommend reading Out of the 
> tarpit<http://shaffner.us/cs/papers/tarpit.pdf>. 
> It argues that traditional imperative approach with control flow being 
> messed with logic leads to complex unmaintainable just ugly software. 
>
> On Saturday, December 29, 2012 11:39:28 AM UTC+4, Raynos wrote:
>>
>> You can implement the same idea with two functions
>>
>> Here the code is explicit about how it runs code.
>>
>> ```js
>> var execute = require("execute")
>> , serial = require("serialize") // unimplemented see 
>> https://gist.github.com/4405173
>>
>> var run = serial([
>> function (cb) {
>> execute({
>> sum1: function (cb) { add(1, 2, cb) }
>> , sum2: function (cb) { add(3, 4, cb) }  
>> }, cb)
>> }
>> , function (result, cb) {
>> add(result.sum1, result.sum2, cb)
>> }
>> ])
>>
>> run(printResult)
>>
>> function printResult(err, result) {
>> if (err) {
>> throw err
>> }
>> console.log("result", result) // prints "result=10" 
>> }
>> ```
>>
>> Although your idea is interesting, it's hard to build something that's 
>> cleaner then just being explicit about how you do things.
>>
>> Also notice that because we are using clean functional abstractions they 
>> compose trivially ( http://jsfiddle.net/fvz7N/4/ ) like functions should.
>>
>> Your ideas however are interesting, the problem is that they are far more 
>> complex to grok and require trust on self organizing code. Also it's full 
>> of implicit magic by the very definition of self organizing code.
>>
>> It should be noted substack had a similar idea with disorder ( 
>> https://github.com/substack/node-disorder#disorder )
>>
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: Is it wise to host nodejs apps on third party machines with source code? Can't we compile into machine code before hosting?

2013-01-11 Thread greelgorke
oh my, trust became so old fashioned... 3rd party hosts get money exactly 
because they are trustworthy. if they're not, they will not get any 
customers anyway. so let them secure your credentials, they can do that 
better than you.


Am Freitag, 11. Januar 2013 07:05:56 UTC+1 schrieb Gregg Caines:
>
> You shouldn't look to compilation to solve this problem, because 
> compilation is not encryption.  Even if it was compiled C, anyone who can 
> open a hexeditor can see your username and password in there.  I bet you 
> could even see it from notepad.
>
> An encryption scheme won't be bulletproof either, because you've got to 
> put the decryption logic on the machine as well, or your app won't actually 
> be able to use the decrypted username/password.
>
> Of course you could encrypt anyway; that's at least mildly harder than 
> reading plain text (but still pretty trivial to decrypt -- they just need 
> to console.log(decryptedPassword) before you use it in your code).
>
> I think you've either got to trust your 3rd-party hosts, or stop using 
> 3rd-party hosts.  As with most scenarios, if someone malicious has full 
> access to your machine, there's not much you can do.
>
> G
>
>
>
> On Wednesday, January 9, 2013 2:31:55 AM UTC-8, Koti Kanna wrote:
>>
>> Hi all,
>>
>> I am using npm module imap to fetch emails. where it requires username 
>> and password to fetch mails. This mail client i am hosting on a third party 
>> machine. My worry is, if any body open this file they can actually see my 
>> user name and password. Is there any way to precompile this module into 
>> machine code?
>>
>> Do you have any plans to support executables for nodejs Apps, before it 
>> touches version 1.0?
>>
>> Thanks
>> Koti
>>
>> P.S.: The one and only language right now i know is JavaScript.
>>
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: How do you release memory and control usage

2013-01-11 Thread greelgorke
more details. looks like a memory leak to me at first sight, but depending 
on what your app is doing, you migh just load to much data in a bad way

Am Freitag, 11. Januar 2013 08:31:03 UTC+1 schrieb Ket:
>
> Thanks for suggestion. 
>
> My machine have 2GB of RAM. The app uses it all up and stopped and then 
> released the RAM. It starts at 0 gain. Once the app is running again, my 
> RAM is used up again and again in this circle.
>
> On Friday, January 11, 2013 2:05:04 PM UTC+7, Brian Link wrote:
>>
>> Also, AFAIK V8 (by default) will only eat up 1 GB of RAM, but its 
>> certainly possible your machine does not even have 1 GB.
>>
>> On Thursday, January 10, 2013 11:04:17 PM UTC-8, Brian Link wrote:
>>>
>>> Without knowing more details about your app, all I can say is you have a 
>>> memory leak somewhere.  V8 will garbage-collect unused memory.
>>>
>>> You'll want to survey your app for objects that grow without bounds and 
>>> figure out if/how/why they should be growing like that.
>>>
>>> On Thursday, January 10, 2013 6:17:21 PM UTC-8, Ket wrote:

 Hi,

 I've an experience that my app eat up my web server memory and it stop 
 working.

 How do you release memory when the app is not in use and how do you 
 manage memory allotment so that node.js would not use up all the memory 
 again and again.

 Thank you.

>>>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: Aplication restarter

2013-01-12 Thread greelgorke
forever has a -w --watch flags as well as --watchDir, havent use them yet. 
i use nodemon for development and forever 
or https://github.com/visionmedia/mon in production

Am Samstag, 12. Januar 2013 20:41:40 UTC+1 schrieb nin jin:
>
> Problems:
> 1) When some files changed, needs to restart for applying that.
> 2) When application downed, needs to start it again
>
> I found some external utils:
>
> a) nodemon
> https://github.com/remy/nodemon 
> Transparent node-replacer. This is really cool util for (1) but not for (2)
>
> b) supervisor
> https://github.com/isaacs/node-supervisor
> Node-replacer, but do not transmit cmd arguments to node. This is 
> important for me because i need --harmony flag.
>
> c) forever
> https://github.com/nodejitsu/forever
> Solving (2) problem, but not (1)
>
> d) some modules for hot-swapping, but without native api, it is dangerous.
>
> Of course, i can use nodemon+forever, but this is overkill. Daemon that 
> monitoring daemon that monitoring application.. 
>
> And i invent new one :)
>
> $.jin.persistent - node module that integrates in your application, and 
> keeps it up and up-to-date. Let us write something simple:
>
> 
> require( 'jin' ).persistent( function( $ ){
> // $ is autoloader but you are not required to use it
> 
> console.log( '2 * 2 = ' + 2 * 2 )
> 
> if( Math.random() < 0.3 ) throw new Error( 'Something wrong!' )
> } )
> 
>
> In console you see something like that while you editing the source:
>
> 
> >node --harmony .
> $.jin.persistent: Starting application...
> 2 * 2 =  4
> $.jin.persistent: Some files changed!
> $.jin.persistent: Starting application...
> 2 * 2 = 4
> $.jin.persistent: Some files changed!
> $.jin.persistent: Starting application...
> 2 * 2 = 4
> Error: Something Wrong!
> at \index.js:5:37
> at module.exports.$.jin.proxy.apply.proc 
> (\node_modules\jin\sync2async.js:19:18)
> $.jin.persistent: Application halted (1)
> $.jin.persistent: Some files changed!
> $.jin.persistent: Starting application...
> 2 * 2 = 4
> 
>
> Note, application did not restart after this error, because it fails on 
> statup and strongly needs for changes for starting again. Autorestart 
> enables after 1s timeout.
> Let us write some server. Let it be service that gets domain list and 
> returns json with its ip's as integers.
>
> 
> require( 'jin' ).persistent( function( $ ){
> 
> $.express()
> .use( $.jin.sync2middle( function( req, res ){
> 
> var domains= req.url.replace( /^\/+|\/+$/g, '' ).split( '/' ).map( 
> decodeURIComponent )
> 
> var ips= domains.map( function( domain ){
> return $.dns.lookupSync( domain )
> } )
> 
> var map= {}
> domains.forEach( function( domain, index ){
> try{
> numbers= String( ips[ index ] ).split( '.' ).map( Number )
> map[ domain ]= numbers[ 0 ] * 256 * 256 * 256
>  + numbers[ 1 ] * 256 * 256
>  + numbers[ 2 ] * 256
>  + numbers[ 3 ]
> } catch( error ){
> map[ domain ]= error
> }
> } )
> 
> return map
> 
> } ) )
> .listen( 80 )
> 
> } )
> 
>
> This is implementation of map-reduce pattern. First,simultaneously send 
> requests to dns. Second, gets responses in right sequence, and handle all 
> errors occurring during that.
>
> I run that application by:
>
> npm install jin
> node --harmony dns-er.js
>
> While i write this source, server has automatic restarts. And sometimes 
> server downs with any error. But when i fix bugs it ups automatically.
> All i do after editing is refreshing this page: 
>
> http://localhost/google.com/undefined.host/yandex.com/%D0%BF%D1%80%D0%B5%D0%B7%D0%B8%D0%B4%D0%B5%D0%BD%D1%82.%D1%80%D1%84/
> and getting that in browser:
>
> 
> {
>
>- google.com: 1249765070,
>- undefined.host: 
>{
>   - code: "ENOTFOUND",
>   - errno: "ENOTFOUND",
>   - syscall: "getaddrinfo"
>   },
>- yandex.com: 1680561923,
>- президент.рф: 3285194843
>
> }
> 
>
> $.jin.persistent uses fs-watch-tree and you can setup this watcher by 
> optional second argument that passes as is. By default watched all files 
> and directories that starts with english letter.
> See more about this config: 
> https://github.com/busterjs/fs-watch-tree#watchtreedir-options-callback
>
> And more about jin library: https://github.com/nin-jin/node-jin
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
h

[nodejs] Re: Remove diacritic from text

2013-01-14 Thread greelgorke
try this https://github.com/FGRibreau/node-unidecode

Am Montag, 14. Januar 2013 11:04:43 UTC+1 schrieb Danilo Luiz Rheinheimer 
Danilo:
>
> Hi,
>
>   Someone is aware os a funcion to remove diacritics (accebts) from words 
> on node.js string. In fact what I want is to replace the char with the 
> diacritic with his version without the diacritic.
>
>   If I have a string like :
>
>   Imóvel
>
>   I want the funcion result to be :
>
>   Imovel
>
> 
>
> Danilo.
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: Display Jade file without using Express?

2013-01-15 Thread greelgorke
for other node modules: jade has a public api

https://github.com/visionmedia/jade#a5

for not node, there are ports: https://github.com/visionmedia/jade#a2

for the browser: https://github.com/visionmedia/jade#a4

for the right place for 
questions: https://groups.google.com/forum/?fromgroups=#!forum/jadejs ;)

Am Dienstag, 15. Januar 2013 21:12:44 UTC+1 schrieb Torben Jonas:
>
> Hi there,
> I would like to use the Jade template engine to show content on my website.
> I know that there is an integration of Jade into Express but I would like 
> to use Jade without Express.
>
> Are there any resources/tutorials on how to do this? I just find thousands 
> of websites explaining how to use Jade with Express
>
> 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


[nodejs] Re: node js net module help

2013-01-17 Thread greelgorke
don't know if this has something to do with your problem:

client.on('data', function(data) {  
debugger; 
var dataToPipe = data; 
httpChild.stdin.write(dataToPipe,'utf8'); 
httpsChild.stdin.write(dataToPipe,'utf8');   
 // data = null; tried using this but made no difference. 
  
  
}); 

data is already a Buffer and you don't need to pass the encoding to 
write-calls. After a short look into Writable Stream implementation i think 
it might be even dangerous.


Am Mittwoch, 16. Januar 2013 23:24:22 UTC+1 schrieb preetam pattanashetty:
>
> Hi,
>
> Firstly, what we have is a Windows service (Christened: Aggregator ) 
> written in .Net that processes data in real time and is listening to 
> clients (which are flash based) on a port.. and when a tcp connection is 
> made is starts writing data to the  client at 4 times a second. This data 
> is used by the flash player to plot an almost real time graph.. we use this 
> to get feedback on some event from users using their mobile devices.
>
> Why nodejs? One of the issues we had was the flash clients were not able 
> to connect to the raw tcp socket when the clients were behind a corporate 
> firewall and doing some investigation we found socket.io to solve this 
> issue. We are now able to establish a connection from flash based client to 
> socket.io (nodejs) to the aggregator. 
>
> Now the problem:
>
> When the nodejs app continues running we see a  gradual increase in the 
> memory footprint. I added nodetime profiler to see what was hogging the 
> memory and the objects that are taking up most of the space are of type 
> Buffer (native) and Array and I am not sure if this is something internal 
> or I have to change the way I am accessing the ‘data’ event of then net 
> module.
>
> Source:
>
> The main js file:
>
> https://www.dropbox.com/s/k1u0jg8jl3271m1/mainApp.js 
>
> Js file that had socket.io implementation and is started as child process.
>
> https://www.dropbox.com/s/dq1m294xhae70o7/httpChild.js
>
>  
>
> A dummy app that simulates the aggregator server (sends dummy data to the 
> connected clients on a regular interval): 
>
> https://www.dropbox.com/sh/qtgj9gp0h1g7erz/OeQjp3vBBg 
>
> Even when I comment out all the code in the net module’s ‘data’ event 
> handler of the main js file I still see an increase in the memory. Not sure 
> if there is a way to dispose the data object received by this event. 
>
> Any help / advice is highly appreciated.. I am new to nodejs and do not 
> have any experience in C++.. Thanks again in advance for your time. Please 
> let me know if more information is required.
>
>
> Thanks,
>
> Preetam
>
> screenshots from nodetime
>
> 
>
>
>
> 
>
> 
>
>
>
>
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: Exception handling and concurrency handling (The correct way of handling uncaught exceptions considering multiple users will be sending requests to the server)

2013-01-17 Thread greelgorke
catch exceptions where they appear first, thats the best place to handle 
them. I add the handler for the uncaughtExceptions event only to get 
awareness where the exception comes from, to handle it there. and, yeah, 
domains :)

Am Mittwoch, 16. Januar 2013 19:51:28 UTC+1 schrieb mjosephd:
>
> Hi All,
>
> In node.js the server crashes whenever an exception is thrown, I also read 
> up that it IS possible to catch uncaught exceptions but the best practice 
> is to do any necessary precautions such as logging details and then 
> restarting the server. However if multiple users are performing various 
> actions this would have the system become inconsistent, for example a 
> transaction (multiple db calls for one process) was taking place and the 
> server restarted in the middle, multiple web service call for the same 
> process and again the server restarted in the middle and such similar 
> scenarios.
>
> At the moment we are considering of using node.js for an enterprise 
> solution which involves multiple requests from multiple users very often to 
> the node.js server and it is also critical that no data is saved 
> incorrectly either. This is the only hurdle so far I see and would like to 
> know the best way of handling uncaught exceptions considering that multiple 
> users will be sending many requests regularly to the node.js server.
>
> Regards,
> Mjosephd
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: npm install newline unexpected error

2013-01-17 Thread greelgorke
you can use app-get install npm

Am Donnerstag, 17. Januar 2013 00:13:42 UTC+1 schrieb Mark Hahn:
>
> Oh, it's ubuntu 12.05.
>
>
> On Wed, Jan 16, 2013 at 3:13 PM, Mark Hahn 
> > wrote:
>
>> i'm trying to install the npm package using a command I found several 
>> places and it isn't working.  I looked all over the npmjs.org site for 
>> install instructions with no luck.  Googling doesn't work because I get 
>> nothing but the "npm install" instruction.
>>
>>  curl http://npmjs.org/install.sh | sudo sh
>>   % Total% Received % Xferd  Average Speed   TimeTime Time 
>>  Current
>>  Dload  Upload   Total   SpentLeft 
>>  Speed
>> 100850850 0266  0 --:--:-- --:--:-- --:--:-- 
>>  1062
>> sh: 2: Syntax error: newline unexpected
>>
>> What am I doing wrong?
>>
>
>

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


[nodejs] Re: [ReferenceError: html is not defined]

2013-01-17 Thread greelgorke
inline:

Am Donnerstag, 17. Januar 2013 13:54:54 UTC+1 schrieb Norman Khine:
>
> i have this code:
>
> var server = require('http').createServer(function(req, res){
>   res.end(html);
>
HERE!! what is html? 

> });
> server.listen(process.env.VCAP_APP_PORT || 9080);
>
> var nowjs = require("now");
> var everyone = nowjs.initialize(server);
>
> everyone.now.distributeMessage = function(message){
>   console.log('User '+this.now.name+' added message ' +message);
>   everyone.now.receiveMessage(this.now.name, message);
> };
>
> and am using the now.js from https://github.com/jameskeane/now
>
> when i run
>
> % node app.js and then from my client i have this code:
>
> 
>
>   http://127.0.0.1:9080/nowjs/now.js
> ">
>   
> $(document).ready(function(){
> now.receiveMessage = function(name, message){
> $("#messages").append('
' + '' + name + > '' + ': ' + message); > } > $("#send-button").click(function(){ > now.distributeMessage($("#text-input").val()); > $("#text-input").val(""); > }); > now.name = "${name}"; > }); > > > > this works fine and the mesages are sent, but i get this console errors > > [ReferenceError: html is not defined] > ReferenceError: html is not defined > at Server. > (/Users/khinester/Sandboxes/zeitgeist/zchat/app.js:2:11) > at Server.handleResponse > (/Users/khinester/Sandboxes/zeitgeist/zchat/node_modules/now/lib/fileServer.js:43:31) > at Manager.handleRequest > (/Users/khinester/Sandboxes/zeitgeist/zchat/node_modules/now/node_modules/ > socket.io/lib/manager.js:565:28) > at Server. > (/Users/khinester/Sandboxes/zeitgeist/zchat/node_modules/now/node_modules/ > socket.io/lib/manager.js:119:10) > at Server.EventEmitter.emit (events.js:91:17) > at HTTPParser.parser.onIncoming (http.js:1793:12) > at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] > (http.js:111:23) > at Socket.socket.ondata (http.js:1690:22) > at TCP.onread (net.js:402:27) > > what am i missing? > -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, 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 send email when script js restarted ???

2013-01-17 Thread greelgorke
or mon https://github.com/visionmedia/mon

Am Donnerstag, 17. Januar 2013 21:05:10 UTC+1 schrieb Chad Engler:
>
> Use monit
>
>  
>
> -Chad
>
>  
>
> *From:* nod...@googlegroups.com  [mailto:
> nod...@googlegroups.com ] *On Behalf Of *bodo
> *Sent:* Thursday, January 17, 2013 2:24 PM
> *To:* nod...@googlegroups.com 
> *Subject:* Re: [nodejs] How to send email when script js restarted ???
>
>  
>
> How to do that ? restart is an action, is not event (for ex: forever 
> restart server.js)
>
> On Thursday, January 17, 2013 7:59:19 PM UTC+1, Alan Hoffmeister wrote:
>
> I think you can listen for the "restart" event using forever, this way you 
> can send some e-mail when the script restarts.
>
>
> --
> Att,
> Alan Hoffmeister
>
>  
>
> 2013/1/17 bodo 
>
> I use supervisor and forever to launch script node. When script is 
> crashed, supervisor or forever restart script auto. I want to send mail 
> when script is restarted to know what happened. How to do that ?
>
> Thank you for any help
>
> -- 
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: 
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to 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 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


[nodejs] Re: Waiting for an async operation to end?

2013-01-18 Thread greelgorke
hi,

first of all: in js we don't speak about associative arrays, because we 
dont have any. We have objects, though the name hash is ok to signal that 
the object is meant just as simple key-> value storage. But if you use an 
Array instance then you get disadvantages and not what you're expecting. 
when i see your code, the object is what you might want.

second: the event is called "end" not 
"eof": https://github.com/Gagle/Node-BufferedReader/wiki/Reference

third, yes, use the counter:
===
var fs = require('fs');
var reader = require ("buffered-reader");
var DataReader = reader.DataReader;

function test() {
  var hash = {};
  var files = ["file1", "file2"];
  var fileCounter = 0;
  files.forEach(function(file){
new DataReader (file, { encoding: "utf8" })
  .on ("end", function() {
fileCounter++;
if(fileCounter == files.length) 
  console.log(hash);
  })
  .on ("line", function (line){
var reg= new RegExp(";", "g");
var fields = line.split(reg);
var value  = fields[0];
var key= fields[1];
hash[key]  = value;
console.log(hash[key]);
  })
  .read ();
  } 
}

test();
=

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: [Idea]: npm as a dependancy injector.

2013-01-21 Thread greelgorke
it's a smell, if you have to mock a third party modules in your tests. 
sure, sometimes it's hard to avoid, but for this cases there are mocking 
tools like sinonjs.

Am Sonntag, 20. Januar 2013 05:15:13 UTC+1 schrieb Athan Clark:
>
> Hello everyone. I'd like to make unit testing a practice difficult to 
> evade in Node.js. One of the requirements, though, is that you need to be 
> able to test a module's functionality independently of it's dependencies 
> (say that 10 times fast!). My idea is to make node more flexible in the 
> directories it chooses to look for node modules by providing an alternative 
> "mode" for it to look in - ie if *NODE_MODE* is set to "test", then npm 
> will first try to look in ./test_node_modules for a package before looking 
> in ./node_modules. That way we can provide *alternative *modules for a 
> package - ie mock ones. Or if you were trying to make a package that was 
> compatible with similar modules, you could have a 3rd party testing 
> package, like a simple blog, that uses the similar package in one mode, 
> then your package in another.
>
> Imagine being able to do a *`npm run-scripts test --deep`*, and then see 
> each and every module complete a unit test before progressively walking up 
> the dependance tree making scenario tests along the way. It makes my 
> continuous integration senses salivate.
>
> What do you all think? Could someone could direct me to where/how npm / 
> node implements `require();`? Where should I start?
>
> Thanks in advance!!
>

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


[nodejs] Re: Waiting for an async operation to end?

2013-01-21 Thread greelgorke
just a matter of taste, if you ask me. for me it's not more or less 
readable, just different and requires different reading patterns :) 

and Streams beats promises in this case.

Am Sonntag, 20. Januar 2013 21:54:33 UTC+1 schrieb Brian Link:
>
> I'v been using the async module for this kind of thing.  The above example 
> could be rewritten as:
>
> ```
> var fs = require('fs');
> var reader = require ("buffered-reader");
> var DataReader = reader.DataReader;
> var async = require('async');
>
> // You kinda need to understand map-reduce concept to fully grok this.
> async.reduce(
>   // Source array.
>   ['file1', 'file2', ...],
>   
>   // Initialize your hash object.
>   {},
>
>   // Process each file.
>   function (hash, file, cb) {
> new DataReader (file, { encoding: "utf8" })
>   .on('end', function () {
> cb(null, hash);
>   })
>   .on('error', cb)
>   .on ('line', function (line){
> var reg= new RegExp(";", "g");
> var fields = line.split(reg);
> var value  = fields[0];
> var key= fields[1];
> hash[key]  = value;
>   })
>   .read();
>   },
>
>   // Operate on results.
>   function (err, hash) {
> console.log(hash);
>   }
> );
> ```
>
> The counter example is perfectly fine (and what I started out with), but 
> ever since switching to async I've found my code is a little more readable.
>
> On Friday, January 18, 2013 3:57:30 AM UTC-5, Jean-Michel Hiver wrote:
>>
>> This is what I was looking for : thank you!
>
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: [Idea]: npm as a dependancy injector.

2013-01-22 Thread greelgorke
i thought about suggesting it, but i decided not to do it. test 
are insurance tools, that the cases you've thought about are working and do 
not contain bugs. but tests are software too and may have bugs in it. so 
thats why my testing tools and strategy have to be as simple as it could, 
so i can better assure, that my test infrastructure is safe, or at least 
much more safer than the application i test with it. so to dig into deep of 
nodes Module system (this is where the require magic happens), to rewrite 
it and then hope that no other 1st, 2nd or 3rd party lib we use will 
silently break is not a real solution. as is said, better solution is to 
design your code for testability, where you nearly never have to mock 
something. every time you're mocking the 3rd party tool, you're creating an 
api specification and prove that the lib conforms to it. this is already 
hard with isolated modules like user-land libs, it's even harder with 
platforms essential modules as Module.

Am Dienstag, 22. Januar 2013 06:22:56 UTC+1 schrieb nin jin:
>
> You can implement custom "require". This is easy) 
> http://nodejs.org/api/vm.html
>
> воскресенье, 20 января 2013 г., 8:15:13 UTC+4 пользователь Athan Clark 
> написал:
>>
>> Hello everyone. I'd like to make unit testing a practice difficult to 
>> evade in Node.js. One of the requirements, though, is that you need to be 
>> able to test a module's functionality independently of it's dependencies 
>> (say that 10 times fast!). My idea is to make node more flexible in the 
>> directories it chooses to look for node modules by providing an alternative 
>> "mode" for it to look in - ie if *NODE_MODE* is set to "test", then npm 
>> will first try to look in ./test_node_modules for a package before looking 
>> in ./node_modules. That way we can provide *alternative *modules for a 
>> package - ie mock ones. Or if you were trying to make a package that was 
>> compatible with similar modules, you could have a 3rd party testing 
>> package, like a simple blog, that uses the similar package in one mode, 
>> then your package in another.
>>
>> Imagine being able to do a *`npm run-scripts test --deep`*, and then see 
>> each and every module complete a unit test before progressively walking up 
>> the dependance tree making scenario tests along the way. It makes my 
>> continuous integration senses salivate.
>>
>> What do you all think? Could someone could direct me to where/how npm / 
>> node implements `require();`? Where should I start?
>>
>> Thanks in advance!!
>>
>

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


[nodejs] Re: How to detect if file is text or binary using Nodejs?

2013-01-22 Thread greelgorke
i guess only by try and error. if you want to put the content of the file 
to json, you will use encoding anyway, because json is a text format. so, i 
don't know what kind of data is in the files, but i would just use utf8 and 
see if anything comes out of it.

Am Dienstag, 22. Januar 2013 11:54:14 UTC+1 schrieb Vladimir Starkov:
>
> How to detect if file is text or binary using Nodejs?
>
>
> I need it to put file content in json and if file is text, I will use 
> encoding parameter in fs.readFile, and if the file is binary, I will read 
> it without encoding

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: How to detect if file is text or binary using Nodejs?

2013-01-22 Thread greelgorke
may be this can help you 
too 
http://en.wikipedia.org/wiki/Byte_Order_Mark#Representations_of_byte_order_marks_by_encoding

Am Dienstag, 22. Januar 2013 15:13:31 UTC+1 schrieb greelgorke:
>
> i guess only by try and error. if you want to put the content of the file 
> to json, you will use encoding anyway, because json is a text format. so, i 
> don't know what kind of data is in the files, but i would just use utf8 and 
> see if anything comes out of it.
>
> Am Dienstag, 22. Januar 2013 11:54:14 UTC+1 schrieb Vladimir Starkov:
>>
>> How to detect if file is text or binary using Nodejs?
>>
>>
>> I need it to put file content in json and if file is text, I will use 
>> encoding parameter in fs.readFile, and if the file is binary, I will read 
>> it without encoding
>
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: Node.js Domains help

2013-01-22 Thread greelgorke
what does the error message say?

in line 4: function name: next
and
in line 12: param named: next

is this defined somewhere in scope? if not, then you get a TypeError 
function next is not defined or something like that in your "error"-event 
handler which is outside of the domain

Am Dienstag, 22. Januar 2013 15:24:12 UTC+1 schrieb Ash:
>
> Hi I am trying to isolate a 3rd party type error using domains 
> here is the code (sorry its in coffeescript) 
>
> http://pastie.org/private/iexulds93m8fbfpzdbmtoq 
>
> the d.on "error" catches error fine, but the error still leaks out to 
> my program and crashes it 
> am i doing something wrong here? 
>
> 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


Re: [nodejs] Re: How to detect if file is text or binary using Nodejs?

2013-01-23 Thread greelgorke
it's a kind of magic! cool thing

Am Dienstag, 22. Januar 2013 17:51:19 UTC+1 schrieb Nathan Rajlich:
>
> Perhaps try node-mmmagic: https://github.com/mscdex/mmmagic
>
> On Tue, Jan 22, 2013 at 6:14 AM, greelgorke 
> > wrote:
>
>> may be this can help you too 
>> http://en.wikipedia.org/wiki/Byte_Order_Mark#Representations_of_byte_order_marks_by_encoding
>>
>> Am Dienstag, 22. Januar 2013 15:13:31 UTC+1 schrieb greelgorke:
>>
>>> i guess only by try and error. if you want to put the content of the 
>>> file to json, you will use encoding anyway, because json is a text format. 
>>> so, i don't know what kind of data is in the files, but i would just use 
>>> utf8 and see if anything comes out of it.
>>>
>>> Am Dienstag, 22. Januar 2013 11:54:14 UTC+1 schrieb Vladimir Starkov:
>>>>
>>>> How to detect if file is text or binary using Nodejs?
>>>>
>>>>
>>>> I need it to put file content in json and if file is text, I will use 
>>>> encoding parameter in fs.readFile, and if the file is binary, I will read 
>>>> it without encoding
>>>
>>>  -- 
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines: 
>> https://github.com/joyent/node/wiki/Mailing-List-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


[nodejs] Re: how to end request and retry - after getting response close

2013-01-23 Thread greelgorke
put your oa.get call in your recursive function, then you can call 
recursive function in on "close" handler, this should work. a retry request 
is just another request, at least in http.

Am Mittwoch, 23. Januar 2013 03:11:02 UTC+1 schrieb am_p1:
>
> Node and js noobie here so if there's a simple fix for this... I admit 
> my humiliation in advance...
>
> I'm receiving millions of xml packets a day using node to pull from a 
> streaming api and it's working great using less than 1% of my server!!
>
> But about 0 to 2 times a day "response end" followed by "response close" 
> gets called and then, no more data. Not sure why but I assume it's 
> something outside my server and beyond my control.
>
> Problem is how do I end the request from the "response close" callback and 
> then retry the request to get it going again? I've tried request.abort, 
> end, destroy, return and other things i've forgotten right now... but nada, 
> I can't seem to end the request from within the "response close" callback.
>
> I might have made this more complicated trying to recursively call the 
> function... which works great on another node, but it's a request/response 
> type with a setTimeout, not streaming like this one.
>
> Anyway, the code's below and all I want to do after getting "response 
> close" is to retry the request and get back to receiving the xml packets as 
> fast as possible... like maybe with this:
> setTimeout(recursive,100)
>
> Thanks for the help!!
>
>
> 
> var oa = new 
> oauth.OAuth(null,null,config.consumer_key,config.consumer_secret,"1.0",null,"HMAC-SHA1")
>
> var db = new odbc.Database()
>
> var request = 
> oa.get(config.api_url+'?symbols='+syms,config.access_token,config.access_secret)
>
> var recursive = function () {
>
>   request.on('response',function(response) {
>
> response.on('data',function(data) {
>
>   // ... lots o code, all working great
>
>   })
>
> response.on('end',function() {
>
>   console.log(chld,'response end',Date(),microtime.now())
>
>   })
>
> response.on('close',function() {
>
>   console.log(chld,'response close',Date(),microtime.now())
>
>   // i have tried various code here but nada - function never ends (at 
> least, i think thats whats happening)
>
>   })
>
> })
>
>   // the 4 below have never fired
>
>   request.on('socket',function() {
>
> console.log(chld,'request socket',Date(),microtime.now())
>
> })
>
>   request.on('connect',function() {
>
> console.log(chld,'request connect',Date(),microtime.now())
>
> })
>
>   request.on('upgrade',function() {
>
> console.log(chld,'request upgrade',Date(),microtime.now())
>
> })
>
>   request.on('continue',function() {
>
> console.log(chld,'request continue',Date(),microtime.now())
>
> })
>
>   request.end()
>
>   // also tried code here but nada
>
> }
>
> db.open("DRIVER={DB2};DATABASE=..",function(err) {
>
>   if(err) {
> console.log(chld,err)
> db.close(function() {
> })
>
>   } else {  
>
> recursive()
>
>   }
>
> })
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: Tips on testing internals w/ mocha

2013-01-23 Thread greelgorke
depending on what you actually test you might try sinonjs. its a 
stub/spy/mock framework. you could mock your internals and preprogram 
expected behavior. i.E. function A, then function B then function C 3 times 
etc. 

http://sinonjs.org/docs/#mocks 

Am Mittwoch, 23. Januar 2013 05:34:18 UTC+1 schrieb taterbase:
>
> I've been trying to gear my development to be more test oriented and one 
> thing I've run into was not being able to test the going-ons of my app that 
> happen internally without effect to the outside world. When a request comes 
> in I would like to make sure certain things happen within the server but I 
> have no real way to check on that. Custom middlewares come to mind but 
> there are other instances as well. I've resorted to setting custom headers 
> when in testing environments that only get sent if what I wanted happened 
> but this is not ideal. I feel like I may be missing something obvious with 
> testing stuff like this, any tips?

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


Re: [nodejs] Re: Data validation

2013-01-23 Thread greelgorke
just 2 cents:

guys, please don't mix up validity and conformity to business rules. 
sometimes it's hard to not to mix them up, but it is important 
doe distinguish. That a form field should be an email address is the first 
one, that this address should be unique in the system, is the other thing. 
Validation proves the format and type of the data, Businessrules proves 
integrity of the data model. first is made by simple sync functions, the 
second one needs interaction with the business model layer including 
db-access. 

Am Mittwoch, 23. Januar 2013 09:38:22 UTC+1 schrieb Raynos:
>
> validation and ensuring global constraints are met at the database layer 
> are two completely seperate things.
>
> One validates that a piece of data is valid and sanitized by some local 
> constraint. The other checks global constraints across your entire system.
>
> Why would you want to split these up? Because validation without global 
> constraint checks is a very simple pure function, take input, return 
> boolean or errors.
>
>
> On Tue, Jan 22, 2013 at 3:06 AM, Alan Hoffmeister 
> 
> > wrote:
>
>> So how do you validate duplicated username, e-mail, etc..? As far as I 
>> could see I need to split the validation process for this, and I think that 
>> this is fucking up with the validation.
>>
>> --
>> Att,
>> Alan Hoffmeister
>>
>>
>> 2013/1/22 Jake Verbaten >
>>
>>> Your validating logic is only async if it does IO. 
>>>
>>> If your validation does IO you fucked up. You don't need async support.
>>>
>>>
>>> On Mon, Jan 21, 2013 at 10:11 AM, Alan Hoffmeister 
>>> 
>>> > wrote:
>>>
 Katsumoto, thats a nice well known package, but I think that lacks 
 async support.

 --
 Att,
 Alan Hoffmeister


 2013/1/21 Katsumoto >

> take a look at https://github.com/chriso/node-validator
>
> пятница, 18 января 2013 г., 13:07:13 UTC+2 пользователь Alan 
> Hoffmeister написал:
>  
>> Hello fellows!
>>
>> How are you doing data validation like forms and other user inputs? I 
>> know that there is some modules to do that but my intention is to do a 
>> brainstorm to gather ideas for a new module that I'm developing.
>>
>> Thanks.
>>
>> --
>> Att,
>> Alan Hoffmeister
>>  
>  -- 
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: 
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to 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 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 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 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


[nodejs] Re: HTTP Response pause/resume

2013-01-23 Thread greelgorke
http://nodejs.org/api/stream.html#stream_stream_pause second paragraph. did 
you tried to wait longer before resume? 5 seconds might be not really much

Am Mittwoch, 23. Januar 2013 19:24:27 UTC+1 schrieb Katsumoto:
>
> The gist: https://gist.github.com/4611134
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Managing physical distributed clusters

2013-01-24 Thread greelgorke
Hi folks,

im searching for tools, which help me with this task. we have several 
modules out there for managing nodes clusters, but i haven't found much 
about managing application nodes based on different machines. I tried 
substacks fleet, and it's working ok, but it have several flaws in it. i 
searched fo some alternatives but haven't found any yet. another 
alternatives are using technics borrowed from other ecosystems like 
capistrano-based deployment etc. i just don't want to install tools based 
on other plattforms, wanna stay minimalistic in system requirements, so 
node + native shell/ubuntu tools would make me happy. the requirements:

- deployment from a git repo, configurable branch (fleet does it, but works 
only from master)
- rewinding to previous state with a single command (fleet versions 
deployments, fall back to previos state is done by spawn a specific commit)
- starting, stopping, monitoring and keep alive all application nodes in 
the server-cluster from a single machine, no need to login to other servers
- notifications about restarts, crashes and further health messages

what are your strategies there? any known tools?

cheers

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: Managing physical distributed clusters

2013-01-25 Thread greelgorke
@Brian: that looks awesome. i'll try it out next week. 

@Jacob:  i guess i wasn't exact in my explanation. what i want in fact is a 
notification-based mechanism. like fleet or amino deploy/drone. fleet uses 
git under the hood. amino seems to use npm to package and request to 
deployment.

Am Donnerstag, 24. Januar 2013 23:31:46 UTC+1 schrieb Brian Link:
>
> Published my slides to http://cpsubrian.github.com/amino-nodedc
>
> On Thursday, January 24, 2013 4:51:52 PM UTC-5, Brian Link wrote:
>>
>> I just did a presentation at Node.DC on this very topic, so you can 
>> checkout my demos and slides.  Demo-2 shows you how to launch a few drones 
>> and deploy to them.
>>
>> https://github.com/cpsubrian/amino-nodedc/tree/master/demos/demo-2
>>
>> On Thursday, January 24, 2013 4:49:13 PM UTC-5, Brian Link wrote:
>>>
>>> We build and use a toolkit call Amino that satisfies a number of your 
>>> requirements.  We also used fleet and seaport for a while, but eventually 
>>> progressed towards our new approach.
>>>
>>> http://github.com/amino
>>>
>>> You'll want to look at amino-drone and amino-deploy, which can get you 
>>> started deploying code to multiple physical machines.
>>>
>>> The docs aren't totally finished yet, but if you're serious about giving 
>>> it a go, let me know and I'll help however I can.
>>>
>>> On Thursday, January 24, 2013 8:01:20 AM UTC-5, greelgorke wrote:
>>>>
>>>> Hi folks,
>>>>
>>>> im searching for tools, which help me with this task. we have several 
>>>> modules out there for managing nodes clusters, but i haven't found much 
>>>> about managing application nodes based on different machines. I tried 
>>>> substacks fleet, and it's working ok, but it have several flaws in it. i 
>>>> searched fo some alternatives but haven't found any yet. another 
>>>> alternatives are using technics borrowed from other ecosystems like 
>>>> capistrano-based deployment etc. i just don't want to install tools based 
>>>> on other plattforms, wanna stay minimalistic in system requirements, so 
>>>> node + native shell/ubuntu tools would make me happy. the requirements:
>>>>
>>>> - deployment from a git repo, configurable branch (fleet does it, but 
>>>> works only from master)
>>>> - rewinding to previous state with a single command (fleet versions 
>>>> deployments, fall back to previos state is done by spawn a specific commit)
>>>> - starting, stopping, monitoring and keep alive all application nodes 
>>>> in the server-cluster from a single machine, no need to login to other 
>>>> servers
>>>> - notifications about restarts, crashes and further health messages
>>>>
>>>> what are your strategies there? any known tools?
>>>>
>>>> cheers
>>>>
>>>

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





Re: [nodejs] Socket.io and expressJs slow on connecting to server

2013-01-25 Thread greelgorke
in this case you could use engine.io too

Am Freitag, 25. Januar 2013 01:50:51 UTC+1 schrieb Lars Jacob:
>
> Hi Ayaz,
>
> Probably it's falling back to xhr-polling because you have some firewall 
> or proxy somewhere between your client and your server. Socket.io 
> unfortunately first tries websockets and than falls back to other methods 
> by default which takes some time. The fallback timeout can be configured 
> (see here: 
> https://github.com/LearnBoost/Socket.IO/wiki/Configuring-Socket.IO under 
> "adviced production settings"). If you already know that websockets wont 
> work you also can remove them from the transports list so you wont have to 
> wait for the fallback.
>
> bests,
> lars
>
>
> On Tue, Jan 22, 2013 at 2:06 AM, ayaz ali 
> > wrote:
>
>> hello @Glenn Block Thanks for response yes it falls back to xhr poling 
>>
>> -- 
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines: 
>> https://github.com/joyent/node/wiki/Mailing-List-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





[nodejs] Re: Node 0.9 breaking JavaScript change! + operator to negative hex string

2013-01-28 Thread greelgorke
nice case for being more explicit and use parse* instead of conversion 
magic sometimes :D 

Am Sonntag, 27. Januar 2013 03:31:21 UTC+1 schrieb Aseem Kishore:
>
> Found the issue -- indeed a bug fix:
>
> http://code.google.com/p/v8/issues/detail?id=2240
>
> Sorry for the false alarm! But hopefully a useful heads-up for the Node 
> community.
>
> Aseem
>
>
>
> On Sat, Jan 26, 2013 at 9:28 PM, Aseem Kishore 
> 
> > wrote:
>
>> Safari and Firefox also seem to return NaN for this. So perhaps the bug 
>> in V8 was *not* returning them in the first place, and this is just a 
>> (breaking) bug *fix*.
>>
>> It's interesting that -0xC8 is a valid number in all this JS engines 
>> (equivalent to -200), but converting a *string* of that number returns NaN. 
>> Anyone have any idea why?
>>
>> Thanks!
>>
>> Aseem
>>
>>
>> On Sat, Jan 26, 2013 at 9:25 PM, Aseem Kishore 
>> 
>> > wrote:
>>
>>> Hi guys,
>>>
>>> It seems that converting a negative hexadecimal string to a number, 
>>> using the unary + operator, has broken in Node 0.9.
>>>
>>> Node 0.4, 0.6, and 0.8:
>>>
>>> > +'-0xC8'
>>> -200
>>>
>>> Node 0.9:
>>>
>>> > +'-0xC8'
>>> NaN
>>>
>>> Converting positive hexadecimal strings like this continues to work 
>>> properly.
>>>
>>> Chrome stable also behaves like this (returning NaN for negative 
>>> strings), so I'm guessing this is a V8 issue, but just wanted to share it 
>>> here too in case this is known. Is this a by-design change?
>>>
>>> Thanks much!
>>>
>>> Aseem
>>>
>>>
>>
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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, send email to 
nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




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

2013-01-30 Thread greelgorke
hum... js is fully object-oriented and does not need classes. don't see the 
point in reducing a powerful and flexible multi-paradigm language to 
java... 


Am Mittwoch, 30. Januar 2013 12:15:20 UTC+1 schrieb fengchu...@gmail.com:
>
> Hi, Senior JS fans
>
> I am a senior Java/JS developer about 12 year+. I recently wrote a 
> specification named JCS. The goal of this specification is replace the 
> currently popular of CommonJS or RequireJS for building the next generation 
> of full object-oriented class system. The first implementation of the 
> specification is JSDK1.0: https://github.com/fch415/jtdk 
>
>
> The specification is still evolving, welcome you suggest improvements!
>
> JCS 1.0 document: 
> https://github.com/fch415/jss/blob/master/%231/jss%231_jcs_en.md
>
> Sincerely,
> FengChun

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

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




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

2013-01-31 Thread greelgorke
*> xxx.addListenner ('dom', new ClickListener () {...});*

You can do this already in the DOM - Api. EventListener interface is there 
in the spec. nearly nobody use it, instead functional style is preferred. i 
don't know why, but may because it shines more...
 
Am Donnerstag, 31. Januar 2013 08:19:51 UTC+1 schrieb fengchu...@gmail.com:
>
> In the previous post, I wrote these:
> "The function style shouldn't be used in open JS class libraries."
>
> Someone replied me with email, he did not agree this.
> *"I respectfully disagree. I think that as a functional language, 
> function style should be embraced."*
>
> I think the reason maybe my english is poor, can not express all of my 
> views.So I replied his mail and wrote:
> *"In fact, the functional programming style has long been used in those 
> JS OO frameworks.
> xxx.on ('dom', 'click', function () {...});
> Almost all JS framework will such design. This is advantage of the easy 
> style of JS anonymous function.
>
> If in Java, the code should like this:
> xxx.addListenner ('dom', new ClickListener () {...});
>
> In class-based system architecture design, the functional programming 
> style will be more shine."*
>
> I'm planing to write a "Javascrpt Bundle Specification".
> In addition, I would want to put "Jsdocx Specification" on github I wrote 
> a few years ago.
>
> FengChun

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

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




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

2013-01-31 Thread greelgorke
oh, Rick, don't give me that :) suddenly there is no "functional style" dom 
system. the point is that almost everybody just passes a function instead 
of an object to listen. and you know that, for sure. 

Am Donnerstag, 31. Januar 2013 19:04:26 UTC+1 schrieb Rick Waldron:
>
>
>
>
> On Thu, Jan 31, 2013 at 4:05 AM, greelgorke 
> > wrote:
>
>> *> xxx.addListenner ('dom', new ClickListener () {...});*
>>
>> You can do this already in the DOM - Api. EventListener interface is 
>> there in the spec. nearly nobody use it, instead functional style is 
>> preferred. i don't know why, but may because it shines more...
>
>
> Did you mean to say "instead functional style is preferred"? If so, I've 
> love to see some examples of a "functional style" DOM event system that is 
> "preferred".
>
> Rick
>
>  
>
>>  
>> Am Donnerstag, 31. Januar 2013 08:19:51 UTC+1 schrieb 
>> fengchu...@gmail.com:
>>
>>> In the previous post, I wrote these:
>>> "The function style shouldn't be used in open JS class libraries."
>>>
>>> Someone replied me with email, he did not agree this.
>>> *"I respectfully disagree. I think that as a functional language, 
>>> function style should be embraced."*
>>>
>>> I think the reason maybe my english is poor, can not express all of my 
>>> views.So I replied his mail and wrote:
>>> *"In fact, the functional programming style has long been used in those 
>>> JS OO frameworks.
>>> xxx.on ('dom', 'click', function () {...});
>>> Almost all JS framework will such design. This is advantage of the easy 
>>> style of JS anonymous function.
>>>
>>> If in Java, the code should like this:
>>> xxx.addListenner ('dom', new ClickListener () {...});
>>>
>>> In class-based system architecture design, the functional programming 
>>> style will be more shine."*
>>>
>>> I'm planing to write a "Javascrpt Bundle Specification".
>>> In addition, I would want to put "Jsdocx Specification" on github I 
>>> wrote a few years ago.
>>>
>>> FengChun
>>
>>  -- 
>> -- 
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines: 
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to nod...@googlegroups.com
>> To unsubscribe from this group, send email to
>> nodejs+un...@googlegroups.com 
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>  
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "nodejs" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to nodejs+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

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

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




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

2013-01-31 Thread greelgorke
oh gosh... yes it is an object. and i know what functional programming is, 
thanks. as far as your're right, you're off topic anyway. but you're right. 

bye bye topic 

Am Donnerstag, 31. Januar 2013 22:34:13 UTC+1 schrieb Rick Waldron:
>
>
>
>
> On Thu, Jan 31, 2013 at 4:07 PM, greelgorke 
> > wrote:
>
>> oh, Rick, don't give me that :) suddenly there is no "functional style" 
>> dom system. the point is that almost everybody just passes a function 
>> instead of an object to listen. and you know that, for sure. 
>>
>
> The function is an object.
>
> ...And that's not "functional" programming. 
>
> http://en.wikipedia.org/wiki/Lisp_(programming_language)
> http://en.wikipedia.org/wiki/Scheme_(programming_language)
> http://en.wikipedia.org/wiki/Functional_programming
>
>
> Rick
>
>
>
>
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: Breaking away from the procedural structure of method calling

2013-02-01 Thread greelgorke
its quite simple: as long as you utilize closure scoped references, you'll 
need nesting functions. sometimes it's better to handle it with a good 
coding style, sometimes it's better to use a flow control lib like 
async/do/step/whatever. most of the time it is a good idea reduce usage of 
closure scope to a minimum and pass around the variables you need, with 
params or bind. but on v8 closure references are better optimized than 
dynamic bound this-reference.


Am Freitag, 1. Februar 2013 17:10:35 UTC+1 schrieb Thomas Gray:
>
> Hi guys
>
> Let me start out here with a disclaimer. I am a newbie to programming in 
> Javascript. It's syntax is acceptable, so I have no problem with that - 
> it's just on the structuring of Javascript especially within the Async 
> context of nodeJS.
>
> I am at the moment trying to write a really simple RESTful API in NodeJS 
> using Mongo as a data source. I'm using express to handle the HTTP 
> component and the MongoDB library (via NPM) to handle my interaction with 
> Mongo. I am having some real troubles with how to properly structure my 
> application. You can view it as it stands here: http://pastie.org/6013517
>
> As you will see, I am calling the user collection, then finding a user, 
> then creating a new login token, then updating the user with that login 
> token, then sending that login token back to the browser. All within one 
> crazy nested method. I've been programming in non-async languages for a 
> while, and I guess I am failing to understand the concept of how to program 
> asynchronously. The best I can come up with is to have a User object that 
> just has methods that are called within the callback of each component.
>
> Looking at the code I have given above - how would I better structure this 
> to remove the levels of nesting, but still not have it as a procedural 
> object (ie. one method calls the next which calls the next and so on).
>
> Maybe i'm just not understanding how to program in this environment?
>
> Tom
>
>
>

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

--- 
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] Re: Breaking away from the procedural structure of method calling

2013-02-02 Thread greelgorke
very right.

but there is another option: at the very end of the day you have to decide, 
works this out for oyu or not? node.js is not the only thing which is doing 
async io. it's not the only thing which supports js code. so if you don't 
like it, go on and find your luck somewhere else ;) 

good luck 

Am Samstag, 2. Februar 2013 09:24:07 UTC+1 schrieb Stephen Bartell:
>
>
>
> On Friday, February 1, 2013 8:10:35 AM UTC-8, Thomas Gray wrote:
>>
>> Hi guys
>>
>> Let me start out here with a disclaimer. I am a newbie to programming in 
>> Javascript. It's syntax is acceptable, so I have no problem with that - 
>> it's just on the structuring of Javascript especially within the Async 
>> context of nodeJS.
>>
>> I am at the moment trying to write a really simple RESTful API in NodeJS 
>> using Mongo as a data source. I'm using express to handle the HTTP 
>> component and the MongoDB library (via NPM) to handle my interaction with 
>> Mongo. I am having some real troubles with how to properly structure my 
>> application. You can view it as it stands here: http://pastie.org/6013517
>>
>> As you will see, I am calling the user collection, then finding a user, 
>> then creating a new login token, then updating the user with that login 
>> token, then sending that login token back to the browser. All within one 
>> crazy nested method. I've been programming in non-async languages for a 
>> while, and I guess I am failing to understand the concept of how to program 
>> asynchronously. The best I can come up with is to have a User object that 
>> just has methods that are called within the callback of each component.
>>
>> Looking at the code I have given above - how would I better structure 
>> this to remove the levels of nesting, but still not have it as a procedural 
>> object (ie. one method calls the next which calls the next and so on).
>>
>> Maybe i'm just not understanding how to program in this environment?
>>
>
> I think you're totally getting it.  JS is callback driven.  You just need 
> to find a method of organizing the code that makes most sense to you. 
>  Maybe you'll adopt one of the libs that are proposed in this post, maybe 
> you'll use events, maybe you'll make your own lib.  Maybe you wont give a 
> damn and just use nested callbacks.
>
> Theres no perfect style to all of this. And to be honest, if what you have 
> gets the job done and makes the client happy, then you have a win. 
>
> Personally, I think that struggling through all this async shit on your 
> own without using  helper library is the only way you're going to grok 
> whats really going on beneath the covers.  Once you really get comfortable 
> with how it works, then you can give into being lazy (in a non-insulting 
> sense) and just use a lib, or write your own.
>
> I believe in learning by immersion. Read code, lots of code.  Especially 
> the parts where objects are initiallizing themselves. Off the top of my 
> head, look at node_redis and follow. There are so many others too.  I 
> usually dig through the package.json dependencies and learn how those work. 
>  It a never ending rabbit hole of code to learn from.
>
> One thing i did notice in your pastie is that you're requiring crypto 
> every time you call hashpassword.  Just call it once at the top of your 
> file.
>
> good luck grasshopper ;)
>  
>
>>
>> Tom
>>
>>
>>

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

--- 
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] Re: which is the best way to run tests?

2013-02-11 Thread greelgorke
npm run-script test*

package.json:

{
"blablabla":"moreblabla",
"scripts":{
  "test": "mocha tests/unit",
  "integration": "mocha tests/integration",
  "spec": "mocha tests/spec",
  "alltests": "mocha tests",
 }
}

layout of tests directory:
tests/unit  -> unit tests, test run immediately and fast 
tests/integration -> integration tests, which need at least to mock or 
setup some infrastructure i.E. in-memory-db or so
tests/spec -> acceptance tests -> tests usually involving the whole app 
including the ui, driven by Fit/Watir/Selenium and/or a (headless) Browser
tests/data -> static data for testcases i.E. json data, DB-population 
scripts/sql, config files
tests/util -> shared things i.E. chai-plugin configuration etc.

this is what i do. 

 
Am Montag, 11. Februar 2013 13:14:56 UTC+1 schrieb Jorge Ferrando:
>
> hi, everybody.
>
>How do you run your tests in your projects? We want to run separately 
> unit tests, integration tests and acceptance (service) tests.
> By now we are using "npm test" to run all together and "make test-unit", 
> "make test-integration", "make test-acceptance" to run it separatly.
> We wonder if there is a way to do it all with npm but what we really want 
> is to do it the best way.
>
> Thank you!
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: nodejs module.js:340 throw err; using WebSocket-Node

2013-02-11 Thread greelgorke
i asume that D:\dev\html5\books\bumper\ is your project root.

the stacktrace says that the string in your require-call is 
"/path/to/websocket". change it to 'websocket' and it should do.

> also the module is installed in the project root did not in the nodejs 
dir , is it ok?
this is how it should be. global installs are for cli-tools. simple rule: 
if you require() it, install in to project, if you're using the 
cli-interface install it globally with -g flag.


Am Montag, 11. Februar 2013 11:13:31 UTC+1 schrieb umen:
>
> im new to this , i installed the nodejs with the installer in windows.
> then i installed the WebSocket-Node 
> module with this command:
> npm install websocket , looks like successful install . 
>
> npm http GET https://registry.npmjs.org/websocket
> npm http 200 https://registry.npmjs.org/websocket
> npm http GET 
> https://registry.npmjs.org/websocket/-/websocket-1.0.8.tgz
> npm http 200 
> https://registry.npmjs.org/websocket/-/websocket-1.0.8.tgz
> 
> > websocket@1.0.8 install 
> D:\dev\html5\books\bumper\node_modules\websocket
> > node install.js
> 
> [websocket v1.0.8] Attempting to compile native extensions.
> [websocket v1.0.8] Native extension compilation successful!
> websocket@1.0.8 node_modules\websocket
>
>
> it installed the nodejs in this location :
>
> > c:\Program Files (x86)\nodejs\
>
> now i try to execute the server.js example from [
> https://github.com/Worlize/WebSocket-Node][1]
> im getting this error:
>
> D:\dev\html5\books\bumper>node server.js
> 
> module.js:340
> throw err;
>   ^
> Error: Cannot find module '/path/to/websocket'
> at Function.Module._resolveFilename (module.js:338:15)
> at Function.Module._load (module.js:280:25)
> at Module.require (module.js:362:17)
> at require (module.js:378:17)
> at Object. (D:\dev\html5\books\bumper\server.js:3:23)
> at Module._compile (module.js:449:26)
> at Object.Module._extensions..js (module.js:467:10)
> at Module.load (module.js:356:32)
> at Function.Module._load (module.js:312:12)
> at Module.runMain (module.js:492:10)
>
>   
> also the module is installed in the project root did not in the nodejs dir 
> , is it ok?
>
>   
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: EADDRINUSE when connecting to Memcached service from node.js

2013-02-11 Thread greelgorke
you're on the wrong path.

use net.connect to create a client-connection (you know, your code is 
client-code for memcached). what you are doing with createServer is to 
create a server, which just listen on the given port and handles connections

Am Dienstag, 12. Februar 2013 05:54:43 UTC+1 schrieb Sudhir Bastakoti:
>
> New to Node.js. Searched lots of answers in SO, but could not find 
> appropriate solution for this issue. I'm using custom memcache server code 
> for node.js for getting data from memcached service (stored using php), 
> added only relevant code below:
>
> var net = require("net");
> net.createServer(function(socket) {
>  socket.setEncoding('utf8');
> 
>  var cmd = {};
>  var incoming = '';
>  socket.addListener('receive', function(data) {
>  incoming += data;
>  // in the mid of receiving some data, so we can't
>  // parse it yet.
>  if(data.substring(data.length - 2) != '\r\n')
> return;
> 
>  data = incoming;
>  incoming = '';
> 
>  var parts = data.split(/ /);
>  if(parts[0].match(/^(add|set|delete|get|gets)$/i)) {
>  switch(parts[0]) {
>  case 'add':
>  var message = JSON.parse(data.split('\r\n')[1]);
>  self._add.call(socket, parts[1].replace('\r\n', 
> ''), message);
>  break;
> 
>  case 'set':
>  var message = data.split('\r\n')[1];
>  try {
> message = JSON.parse(message);
>  } catch(e) {}
> var subparts = parts[1].replace('\r\n', 
> '').split('/');
> self._set.call(socket, subparts.slice(0, 2), 
> subparts.slice(2).join('/'), message);
>  break;
> 
>  case 'delete':
>  self._delete.call(socket, 
> parts[1].replace('\r\n', ''));
>  break;
> 
>  case 'get':
>  self._get.call(socket, parts[1].replace('\r\n', 
> ''));
>  break;
> 
>  case 'gets':
>  var getsparts = parts.slice(1);
>  getsparts[getsparts.length - 1] =
>  getsparts[getsparts.length - 1].replace('\r\n', 
> '');
>  self._gets.call(socket, getsparts);
>  break;
> }
>  }
>  });
> }).listen(11211, "localhost");
>
> But whenever i try to start the node server, it says `EADDRINUSE`, as this 
> is due to the reason that memcached service is already running on port 
> `11211`. If i change the port to something else such as (51242) then the 
> error does not show up, but no data is retrieved from memcached.
>
> So is there any way i can connect to memcached service using same port 
> `11211` from this node.js memcache server code..?
> I'm new to Node.js, so could not figure out any posible solution. So, how 
> can i fix this issue **without using any node.js memcached modules**, or am 
> i completely on the wrong path..? As a side note I'm running memcached 
> service and nodejs on windows 7.  Please suggest
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: Synchronous http client

2013-02-12 Thread greelgorke
you don't need synchronous requests for pipelining:

http.request('url1', function(res){
  res.on('data',function(data){/*collect it*/})
  res.on('end',function(){/*eval your data and do next request*/ 
http.request('url2', func...)}
}

of course you can use async lib aswell.

Am Dienstag, 12. Februar 2013 08:51:16 UTC+1 schrieb vikram patil:
>
> Hello All,
>  
>   I am looking for HTTP client  module in node.js which can help me to 
> create  GET, POST, multipart request very simply and also that request 
> should be synchronous.
> My goal is to develop testing framework so that we can pipeline various 
> http requests to server and evaluate results . For pipelining purpose I 
> can't use asynchronous http requests.
>
> Regards,
> Vikram
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: Query on ImageMagick

2013-02-12 Thread greelgorke
check the err object in your callback for im and check the third param 
which is stderr. if stdout is null then probably an error is occurred 

Am Dienstag, 12. Februar 2013 09:46:02 UTC+1 schrieb Rakesh Kumar:
>
> I am using image urls in my nodejs server directly to fetch images. what i 
> want is to create thumbnails of the images and show it in the browser. The 
> problem i am facing is with imagemagick. stdout is showing null values. How 
> to get data of resized image?
> Below is the code i am implementing. urls are defined in an global array.
>
> http.createServer(function(req,res){
> var i=1;
> var buf='';
> request({url:url[i], encoding: null}, function (err, response, body) {
> if (!err && response.statusCode == 200) {
> im.resize({
> srcData: body,
> width: 50,
> }, function(err, stdout) {
> res.writeHead(200,{"Content-type":"text/html"});
> res.write(stdout.toString('base64'));
> res.write('');
> });
> }
> });
> }).listen(1337,'127.0.0.1');
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Elegant way to require('some-app-component')

2013-02-12 Thread greelgorke
you can put a tar-ball as dependency too, this is what we do with our 
private packages.

another approach is to npm link the packages locally 

Am Dienstag, 12. Februar 2013 20:21:14 UTC+1 schrieb George Snelling:
>
> Never mind, I think I figured it out.  In NPM I think all the modules you 
> need are themselves visible to the public npm repository,  which does 
> simplify everything as ryanos points out.  However, putting closed source 
> code in the public npm repository, even marked as private, makes us pretty 
> nervous.  We will probably check in some sort of stub redirector as Martin 
> suggests in his second post, which acts like a symlink but works on 
> windows. 
>
> I think we could also split our utils out into separate private git 
> repositories and pull them in with giturl dependencies, but at the moment 
> that seems a little heavyweight.  If npm supported file system paths as 
> dependencies I think we'd be super happy.   Just feature request.  We can 
> make the current system work.
>
> -g
>
> On Tuesday, February 12, 2013 10:43:41 AM UTC-8, George Snelling wrote:
>>
>> Isaac, 
>>
>> We have this issue too.  We thought symlinks in node_modules would work, 
>> but we've got some windows folks, so no luck there.  I was looking at npm, 
>> and as far as i can tell, it looks like your pattern is to check most of 
>> node_modules into git, and then pull in almost all modules, yours and 
>> third-parties, using 
>>
>>  "repository": {
>>
>> "type": "git",
>> "url": "git://github.com/TooTallNate/node-gyp.git"
>>   },
>>
>>
>> in hand-edited package.json files.  Is that right?  We are not used to 
>> checking in node_modules, but I'm willing to try out your pattern. 
>>  However, I'm confused about the relationship between the package.json 
>> files checked into node_modules, vs the package.json files at the root of 
>> the modules in their home repros, for example:
>>
>>
>> https://github.com/isaacs/npm/blob/master/node_modules/node-gyp/package.json
>>
>> vs
>>
>> https://github.com/TooTallNate/node-gyp/blob/master/package.json
>>
>> How are the dependencies kept in sync between the two if Nate changes 
>> his?  Sorry if this is obvious...
>>
>> Thanks,  
>>
>> -George 
>>
>> On Saturday, February 9, 2013 6:17:09 PM UTC-8, Isaac Schlueter wrote:
>>>
>>> > The best NPM packages are small and focused 
>>>
>>> 100% agree. 
>>>
>>> > having lots of internal dependencies is probably a smell. 
>>>
>>> Less agree. 
>>>
>>> Having lots of internal dependencies is normal for things that are 
>>> doing complicated things.  However, it's ideal for them to take a 
>>> relatively small number of things, and turn it into one thing.  Then 
>>> you'll tend to end up with lots of meta-deps, but still a small number 
>>> of 1st-order deps. 
>>>
>>> Module dependency trees ought to be bushy - ie, not a narrow deep 
>>> tree, and not a flat long tree.  Then, you cna use `npm dedupe` to 
>>> remove duplicates, and simplify things before checking into git and/or 
>>> deploying. 
>>>
>>>
>>> > There is really no functional difference between using this vs 
>>> relative requires, it's psychological. It makes me focus on keeping lib 
>>> pure, and the lack of ../ gives me the warm fuzzies. 
>>>
>>> This is so very telling!  Thank you for this fascinating bit of 
>>> insight.  You captured it so perfectly. 
>>>
>>> I'd argue that your "warm fuzzies" reaction is 100% valid: a lot of 
>>> ../ in your require paths tends to indicate some inappropriate 
>>> intimacy and merging of concerns.  However, you haven't actually 
>>> solved the problem!  You've only removed the surface manifestation, to 
>>> make it *look* like you're using nicely abstracted components.  But 
>>> those components are not, in fact, nicely abstracted.  They're still 
>>> doing a ../ require into a bag-o-stuff lib folder, but just without 
>>> the ".." in the string. 
>>>
>>> Why not just put your "emerging utility stuff" in 
>>> node_modules/some-util/ and node_modules/some-other-util/, and do 
>>> require('some-util') in your app code?  List each util as a 
>>> "bundledDependency", and check it into git.  If you ever decide to 
>>> split it out, it's super trivial to do so. 
>>>
>>> This way, you'll notice right away if you have too much cross-talk 
>>> between them.  Because, if "util-a" is pulling in "util-b", but 
>>> doesn't list "util-b" as a dependency, then that's an easily spotted 
>>> error.  If it DOES list util-b as a dependency, you'll force yourself 
>>> to think, "Wait a second... why does it *actually* have to depend on 
>>> that other thing?", and then wonder if they should be merged (ie, if 
>>> they are tightly bound, and probably not a good abstraction 
>>> independently), or more fully separated.  The smells will be right in 
>>> your face, instead of hidden behind a magic folder. 
>>>
>>> Over the last year, I've been retroactively doing this with npm, or at 
>>> least, trying to find time to do so, and since thi

[nodejs] Re: which is the best way to run tests?

2013-02-13 Thread greelgorke
here: https://npmjs.org/doc/scripts.html

Am Mittwoch, 13. Februar 2013 09:56:51 UTC+1 schrieb Jorge Ferrando:
>
> Thanks everybody! 
>
> I thought the commands you can run with npm are prefixed. 
>
> I try some of the ways you say. 
>
>
>  
>
> Thank you very much! :)
>
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: which is the best way to run tests?

2013-02-13 Thread greelgorke
earlier i thought about of using grunt for build and deployment, but it 
came out, that npm + small node-only scripts are better way for us, since 
we do not have buildsteps for precompilation. only tasks we need are 
automated test execution and npm pack

Am Mittwoch, 13. Februar 2013 10:31:34 UTC+1 schrieb greelgorke:
>
> here: https://npmjs.org/doc/scripts.html
>
> Am Mittwoch, 13. Februar 2013 09:56:51 UTC+1 schrieb Jorge Ferrando:
>>
>> Thanks everybody! 
>>
>> I thought the commands you can run with npm are prefixed. 
>>
>> I try some of the ways you say. 
>>
>>
>>  
>>
>> Thank you very much! :)
>>
>>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Proxy server with authentication

2013-02-15 Thread greelgorke
yes, passportjs is a good choice. the examples on passportjs.org use 
express routes, but the important parts are passport.authenticate calls. 
it's agnostic enough.

Am Freitag, 15. Februar 2013 01:02:26 UTC+1 schrieb José F. Romaniello:
>
> Ob sorry, i nver used passport other than as a connect middleware, and as 
> I said he probabily needs some kind of sessions to store at least the user 
> is logged in. So, i think connect will be easier. But if you know any other 
> way please go ahead
>
> i know also you could use connect and http proxy on the same instance of 
> the http server
>
> El jueves, 14 de febrero de 2013, Bradley Meck escribió:
>
>> Any reason not to use http-proxy and passport without express?
>>
>> --
>> --
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines: 
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to nodejs@googlegroups.com
>> To unsubscribe from this group, 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] NodeJS analysis for suitability

2013-02-15 Thread greelgorke
threads-a-gogo and node cluster are only 2 possible solutions. also you can 
put your heavy calculating routine in a separate module which runs in a 
separate process and handles a queue and a worker pool. fork it and 
comunicate via process#send. it's a system-internal service process.

Am Freitag, 15. Februar 2013 07:08:44 UTC+1 schrieb Jorge:
>
> On 14/02/2013, at 20:28, Jacob Groundwater wrote: 
> > 
> > I think the solution to any CPU intensive task is a work queue. Do not 
> mix your IO-bound processes with your CPU-bound processes. Node doesn't 
> suck at CPU-bound tasks, it just can't do IO at the same time. 
>
> But a node with -javascript- threads *can* do IO *and* CPU-bound tasks at 
> the same time. 
>
> > It's not like a threaded app will magically have more CPU to compute 
> with. 
>
> Yes it will, in an N cores machine, a node with N threads has ~ N times 
> more CPU to compute with. 
>
> Even in a single core machine, a node with threads-a-gogo can do any 
> amount of -javascript- CPU-bound tasks *and* any IO in parallel, easily and 
> without sttutering, something that no node can do without threads-a-gogo. 
>
>  
> -- 
> Jorge.

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

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




[nodejs] Re: Using NodeJs with through $.get method of jQuery

2013-02-15 Thread greelgorke
you can do $.json with jsonp calls. you server then have to return 
something like this:

response.end(req.query.callback + '('+JSON.stringify(rows) + ');');

other approach is to configure a forwarding from localhost:81/api -> 
localhost:8081

Am Freitag, 15. Februar 2013 09:21:29 UTC+1 schrieb kanitkar...@gmail.com:
>
> Hi,
>
> I have installed NodeJs through windows installer.
> I have this following program for connecting to MySql db to return records
>
> ===
> // Include http module,
> var http = require('http'),
> // And mysql module you've just installed.
>mysql = require("mysql");
> // Create the connection.
> // Data is default to new mysql installation and should be changed 
> according to your configuration.
> var connection = mysql.createConnection({
>user: "root",
>password: "",
>database: "books"
> });
> // Create the http server.
> http.createServer(function (request, response) {
>// Attach listener on end event.
>request.on('end', function () {
>   // Query the database.
>   connection.query('SELECT * FROM authors;', function (error, rows, 
> fields) {
>  response.writeHead(200, {
> 'Content-Type': 'x-application/json'
>  });
>  // Send data as JSON string.
>  // Rows variable holds the result of the query.
>  response.end(JSON.stringify(rows));
>   });
>});
> // Listen on the 8080 port.
> }).listen(8081);
> ===
>
> As you can see on last line this program will listen to port 8081.
> I have WAMP server in which I have created a project and have an 
> index.html page in it.
> From index.html page I am hitting Node.js program above through $.get of 
> jQuery ajax.
>
> But WAMP is running on port 81, so Chrome is not allowing me to access 
> Cross Origin resources.
>
> What can I do to hit Node JS server mentioned above through the index.html 
> page hosted on WAMP server.
> (FYI : WAMP is a PHP server)
>
> Please let me know.
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: Using NodeJs with through $.get method of jQuery

2013-02-15 Thread greelgorke
yes, yuo can just deliver the html page via node, and get rid of cross-cite 
issues this way. but node is often used side by side with more traditional 
systems like php, rails or even java webapps, so it's useful to know how to 
handle it.

so what is exactly your question? i can't tell you much about wamp and 
configuration of mod_rewrite, but google is your friend here.

jsonp solution is just not affected by same-origin-policy. look here 
http://en.wikipedia.org/wiki/JSONP 

Am Freitag, 15. Februar 2013 12:21:20 UTC+1 schrieb kanitkar...@gmail.com:
>
> You know it's hard to digest the fact that NodeJS is itself a Web Server, 
> so it can contain HTML in it & we don't necessarily need a WAMP server :)
>
> On Friday, February 15, 2013 3:33:24 PM UTC+5:30, kanitkar...@gmail.comwrote:
>>
>> Can you please explain in detail how can I achieve that ?
>> I have index.html running on WAMP server & NodeJS is installed in 
>> different folder on my machine & also listens to different port.
>>
>> Here is jQuery code
>>
>> $(document).ready(function(){
>>   $("button").click(function(){
>> $.get("http://localhost:8081",function(data,status){
>> console.log(data);
>>   });
>>   });
>> });
>>
>> On Friday, February 15, 2013 2:39:04 PM UTC+5:30, greelgorke wrote:
>>>
>>> you can do $.json with jsonp calls. you server then have to return 
>>> something like this:
>>>
>>> response.end(req.query.callback + '('+JSON.stringify(rows) + ');');
>>>
>>> other approach is to configure a forwarding from localhost:81/api -> 
>>> localhost:8081
>>>
>>> Am Freitag, 15. Februar 2013 09:21:29 UTC+1 schrieb 
>>> kanitkar...@gmail.com:
>>>>
>>>> Hi,
>>>>
>>>> I have installed NodeJs through windows installer.
>>>> I have this following program for connecting to MySql db to return 
>>>> records
>>>>
>>>> ===
>>>> // Include http module,
>>>> var http = require('http'),
>>>> // And mysql module you've just installed.
>>>>mysql = require("mysql");
>>>> // Create the connection.
>>>> // Data is default to new mysql installation and should be changed 
>>>> according to your configuration.
>>>> var connection = mysql.createConnection({
>>>>user: "root",
>>>>password: "",
>>>>database: "books"
>>>> });
>>>> // Create the http server.
>>>> http.createServer(function (request, response) {
>>>>// Attach listener on end event.
>>>>request.on('end', function () {
>>>>   // Query the database.
>>>>   connection.query('SELECT * FROM authors;', function (error, rows, 
>>>> fields) {
>>>>  response.writeHead(200, {
>>>> 'Content-Type': 'x-application/json'
>>>>  });
>>>>  // Send data as JSON string.
>>>>  // Rows variable holds the result of the query.
>>>>  response.end(JSON.stringify(rows));
>>>>   });
>>>>});
>>>> // Listen on the 8080 port.
>>>> }).listen(8081);
>>>> ===
>>>>
>>>> As you can see on last line this program will listen to port 8081.
>>>> I have WAMP server in which I have created a project and have an 
>>>> index.html page in it.
>>>> From index.html page I am hitting Node.js program above through $.get 
>>>> of jQuery ajax.
>>>>
>>>> But WAMP is running on port 81, so Chrome is not allowing me to access 
>>>> Cross Origin resources.
>>>>
>>>> What can I do to hit Node JS server mentioned above through the 
>>>> index.html page hosted on WAMP server.
>>>> (FYI : WAMP is a PHP server)
>>>>
>>>> Please let me know.
>>>>
>>>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] NodeJS analysis for suitability

2013-02-15 Thread greelgorke
all 3 solutions have their caveats.

of course you can get a node_cluster to block, no, prob.

the service process is a different kind. it's master-worker system where 
master just recieves messages and queues them up and respondes to clients, 
and workers are fetching job requests from master, calculate and notify 
when done. the master is still responsive, because it just handles IPC I/O 
and manges the queue-based dispatching. the works block their own 
eventloop, but it's ok because they are detached from the rest of the app. 
it's similar idea like threads, but better to distribute over physical 
machines and the creation cost is paid on startup once. in fact you can use 
threads to implement the worker, but as fully detached process you can 
distribute even the worker.

to be honest, IF i have an app with high traffic, then i don't want the 
whole machine doing anything else but to handle this traffic, that's the 
case where threaded solution may reach it's limits. of course you can scale 
the whole thing horizontally. it's a decision to make depending on the 
requirements.

PS: i didn't say threads are bad, or threads-a-gogo. i just say there are 
cases, and they aren't rare, where threads are not good (enough). thats 
all. 

Am Freitag, 15. Februar 2013 11:29:03 UTC+1 schrieb Jorge:
>
> On 15/02/2013, at 10:02, greelgorke wrote: 
> > 
> > Am Freitag, 15. Februar 2013 07:08:44 UTC+1 schrieb Jorge: 
> >> On 14/02/2013, at 20:28, Jacob Groundwater wrote: 
> >> > 
> >> > I think the solution to any CPU intensive task is a work queue. Do 
> not mix your IO-bound processes with your CPU-bound processes. Node doesn't 
> suck at CPU-bound tasks, it just can't do IO at the same time. 
> >> 
> >> But a node with -javascript- threads *can* do IO *and* CPU-bound tasks 
> at the same time. 
> >> 
> >> > It's not like a threaded app will magically have more CPU to compute 
> with. 
> >> 
> >> Yes it will, in an N cores machine, a node with N threads has ~ N times 
> more CPU to compute with. 
> >> 
> >> Even in a single core machine, a node with threads-a-gogo can do any 
> amount of -javascript- CPU-bound tasks *and* any IO in parallel, easily and 
> without sttutering, something that no node can do without threads-a-gogo. 
> >> 
> >> <https://github.com/xk/node-threads-a-gogo> 
> > 
> > threads-a-gogo and node cluster are only 2 possible solutions. 
>
> Node cluster is a completely different thing because a node with any 
> number of heavy cpu-bound tasks running in threads-a-gogo will keep 
> processing any IO requests *IN*PARALLEL* just fine, but in a node-cluster, 
> any node that happens to be running a heavy cpu-bound task will be 
> completelly stalled and unable to do *ANY* IO until the task has finished. 
>
> For example, say you're serving a page A which is computationally heavy 
> and  takes 10 seconds to process, and a page B which isn't: 
>
> -with threads-a-gogo: no matter what, page B will always be served fast. 
> -with a node cluster: page B will only be served fast IF there's not any 
> pending request for a page A. If there's any previous request for a page A, 
> page B *and* any other pending IO will have to wait until page A is 
> finished. 
>
> Say you make a node-cluster with 4 nodes, and you get these requests in 
> this order: 
>
> a-a-a-a-a-a-a-a-b 
>
> B will take ~ 20 seconds! 
>
> Now say you instead .create() 4 threads with threads-a-gogo: B won't have 
> to wait for any As, it will be served immediately! 
>
> IOW: node-cluster does NOT give node the ability to run your code in 
> parallel with the event loop and thus as soon as your code blocks it stalls 
> node completely, UNLIKE the case of a node with threads_a_gogo. 
>
> > also you can put your heavy calculating routine in a separate module 
> which runs in a separate process and handles a queue and a worker pool. 
> fork it and comunicate via process#send. it's a system-internal service 
> process. 
>
> The thing is that when your code blocks the event loop the node process 
> stalls so you can't communicate with it. 
>
> To run blocking code and NOT stall node, the only sane solution is 
> threads-a-gogo, not node-cluster. 
>
> <https://github.com/xk/node-threads-a-gogo> 
> -- 
> Jorge.

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

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




Re: [nodejs] Proxy server with authentication

2013-02-15 Thread greelgorke
in your gist: you dopn't need express here. look at examples 
here: http://passportjs.org/guide/authenticate/ you can just use 
passport.authenticate in your request handler after checking the methods

Am Freitag, 15. Februar 2013 15:45:48 UTC+1 schrieb jal...@algotree.com:
>
> Thanks,
>
> This is the gist link to the simple proxy server code that i wrote using 
> express and node-http-proxy
>
> https://gist.github.com/jalaluddeen/4960691
>
> what i wanna do is add authentication and session management to this so 
> that only requests from authenticated users are passed to apache or 
> elasticsearch.
>
>
> On Friday, February 15, 2013 2:17:19 PM UTC+5:30, greelgorke wrote:
>>
>> yes, passportjs is a good choice. the examples on passportjs.org use 
>> express routes, but the important parts are passport.authenticate calls. 
>> it's agnostic enough.
>>
>> Am Freitag, 15. Februar 2013 01:02:26 UTC+1 schrieb José F. Romaniello:
>>>
>>> Ob sorry, i nver used passport other than as a connect middleware, and 
>>> as I said he probabily needs some kind of sessions to store at least the 
>>> user is logged in. So, i think connect will be easier. But if you know any 
>>> other way please go ahead
>>>
>>> i know also you could use connect and http proxy on the same instance of 
>>> the http server
>>>
>>> El jueves, 14 de febrero de 2013, Bradley Meck escribió:
>>>
>>>> Any reason not to use http-proxy and passport without express?
>>>>
>>>> --
>>>> --
>>>> Job Board: http://jobs.nodejs.org/
>>>> Posting guidelines: 
>>>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>>>> You received this message because you are subscribed to the Google
>>>> Groups "nodejs" group.
>>>> To post to this group, send email to nodejs@googlegroups.com
>>>> To unsubscribe from this group, 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] Proxy server with authentication

2013-02-15 Thread greelgorke
passport handles sessions by default, so you have to disable them if you 
dont want sessions. see here http://passportjs.org/guide/configure/ how to 
handle sessions. you could throw in a memory db like memcached or redis, or 
just hold it in memory by yourself. for distributed proxy i'd suggest redis 
or even a rdbms.

Am Freitag, 15. Februar 2013 17:07:53 UTC+1 schrieb José F. Romaniello:
>
> @greelgorke and what do you suggest for session management as @jalalm 
> suggest he wants to authenticate the user in one route and then have the 
> information available in other routes?
>
>
> 2013/2/15 greelgorke >
>
>> in your gist: you dopn't need express here. look at examples here: 
>> http://passportjs.org/guide/authenticate/ you can just use 
>> passport.authenticate in your request handler after checking the methods
>>
>> Am Freitag, 15. Februar 2013 15:45:48 UTC+1 schrieb jal...@algotree.com:
>>
>>> Thanks,
>>>
>>> This is the gist link to the simple proxy server code that i wrote using 
>>> express and node-http-proxy
>>>
>>> https://gist.github.com/**jalaluddeen/4960691<https://gist.github.com/jalaluddeen/4960691>
>>>
>>> what i wanna do is add authentication and session management to this so 
>>> that only requests from authenticated users are passed to apache or 
>>> elasticsearch.
>>>
>>>
>>> On Friday, February 15, 2013 2:17:19 PM UTC+5:30, greelgorke wrote:
>>>>
>>>> yes, passportjs is a good choice. the examples on passportjs.org use 
>>>> express routes, but the important parts are passport.authenticate calls. 
>>>> it's agnostic enough.
>>>>
>>>> Am Freitag, 15. Februar 2013 01:02:26 UTC+1 schrieb José F. Romaniello:
>>>>>
>>>>> Ob sorry, i nver used passport other than as a connect middleware, and 
>>>>> as I said he probabily needs some kind of sessions to store at least the 
>>>>> user is logged in. So, i think connect will be easier. But if you know 
>>>>> any 
>>>>> other way please go ahead
>>>>>
>>>>> i know also you could use connect and http proxy on the same instance 
>>>>> of the http server
>>>>>
>>>>> El jueves, 14 de febrero de 2013, Bradley Meck escribió:
>>>>>
>>>>>> Any reason not to use http-proxy and passport without express?
>>>>>>
>>>>>> --
>>>>>> --
>>>>>> Job Board: http://jobs.nodejs.org/
>>>>>> Posting guidelines: https://github.com/joyent/**
>>>>>> node/wiki/Mailing-List-**Posting-Guidelines<https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines>
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "nodejs" group.
>>>>>> To post to this group, send email to nodejs@googlegroups.com
>>>>>> To unsubscribe from this group, send email to
>>>>>> nodejs+unsubscribe@**googlegroups.com
>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/**group/nodejs?hl=en?hl=en<http://groups.google.com/group/nodejs?hl=en?hl=en>
>>>>>>
>>>>>> ---
>>>>>> 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+unsubscribe@**googlegroups.com.
>>>>>> For more options, visit 
>>>>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>>>>> .
>>>>>>
>>>>>>
>>>>>>   -- 
>> -- 
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines: 
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to nod...@googlegroups.com
>> To unsubscribe from this group, send email to
>> nodejs+un...@googlegroups.com 
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>  
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "nodejs" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to nodejs+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

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

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




Re: [nodejs] NodeJS analysis for suitability

2013-02-15 Thread greelgorke
> Multi-process + IPC is sooo 70's.

well i speak about processes distributed over a network and today we call 
that webservices, but it still the same idea, application which holds it's 
parts in different processes doing IPC. a REST request is IPC over HTTP :)

again, threads are ok for a single application, and as long you do not 
share in-memory-state for communication, thats cool. TAGG utilizes events 
so its cool too. but if you have to distribute your applications modules 
over a network, you have to design it different. Just to say something is 
so 70s is a way to be blind ;) 

Am Freitag, 15. Februar 2013 17:18:36 UTC+1 schrieb Jorge:
>
> On 15/02/2013, at 13:14, greelgorke wrote: 
>
> > all 3 solutions have their caveats. 
> > 
> > of course you can get a node_cluster to block, no, prob. 
> > 
> > the service process is a different kind. it's master-worker system where 
> master just recieves messages and queues them up and respondes to clients, 
> and workers are fetching job requests from master, calculate and notify 
> when done. the master is still responsive, because it just handles IPC I/O 
> and manges the queue-based dispatching. the works block their own 
> eventloop, but it's ok because they are detached from the rest of the app. 
> it's similar idea like threads, but better to distribute over physical 
> machines and the creation cost is paid on startup once. in fact you can use 
> threads to implement the worker, but as fully detached process you can 
> distribute even the worker. 
> > 
> > to be honest, IF i have an app with high traffic, then i don't want the 
> whole machine doing anything else but to handle this traffic, that's the 
> case where threaded solution may reach it's limits. of course you can scale 
> the whole thing horizontally. it's a decision to make depending on the 
> requirements. 
> > 
> > PS: i didn't say threads are bad, or threads-a-gogo. i just say there 
> are cases, and they aren't rare, where threads are not good (enough). thats 
> all. 
>
> Multi-process + IPC is sooo 70's. One should only have to suffer it to 
> scale across machines, but, within the boundaries of a single machine, just 
> to exploit multi-cores? No way. 
>
> Take a look at your computer's activity monitor: several hundreds of 
> threads but just tens of processes... how can it be? How so if the way to 
> go multi-core were multi-process, there are hundreds of threads? 
>
> On mine right now: 54 processes, 293 threads. Mail:13 threads, Safari:15 
> threads, pid 0: 64 threads... Why not 15 Mail processes? Because it would 
> be silly. 
>
> Also, when you have a single instance of your app programming becomes 
> easier, because you don't have to go re-creating the app's context, nor 
> cloning it, nor keeping it synchronized across a bunch of separate 
> processes. 
>
> To keep node ticking, you just need an API to move blocking code out of 
> its main/event loop thread, to a worker thread if you like to call it so, 
> yes, and that's what TAGG lets you do, within a single process, without the 
> hassles of multiple processes + IPC + lost app's contexts to re-create. 
> -- 
> Jorge.

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

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




Re: [nodejs] NodeJS analysis for suitability

2013-02-15 Thread greelgorke
btw. we're off topic :D

Am Freitag, 15. Februar 2013 20:22:10 UTC+1 schrieb greelgorke:
>
> > Multi-process + IPC is sooo 70's.
>
> well i speak about processes distributed over a network and today we call 
> that webservices, but it still the same idea, application which holds it's 
> parts in different processes doing IPC. a REST request is IPC over HTTP :)
>
> again, threads are ok for a single application, and as long you do not 
> share in-memory-state for communication, thats cool. TAGG utilizes events 
> so its cool too. but if you have to distribute your applications modules 
> over a network, you have to design it different. Just to say something is 
> so 70s is a way to be blind ;) 
>
> Am Freitag, 15. Februar 2013 17:18:36 UTC+1 schrieb Jorge:
>>
>> On 15/02/2013, at 13:14, greelgorke wrote: 
>>
>> > all 3 solutions have their caveats. 
>> > 
>> > of course you can get a node_cluster to block, no, prob. 
>> > 
>> > the service process is a different kind. it's master-worker system 
>> where master just recieves messages and queues them up and respondes to 
>> clients, and workers are fetching job requests from master, calculate and 
>> notify when done. the master is still responsive, because it just handles 
>> IPC I/O and manges the queue-based dispatching. the works block their own 
>> eventloop, but it's ok because they are detached from the rest of the app. 
>> it's similar idea like threads, but better to distribute over physical 
>> machines and the creation cost is paid on startup once. in fact you can use 
>> threads to implement the worker, but as fully detached process you can 
>> distribute even the worker. 
>> > 
>> > to be honest, IF i have an app with high traffic, then i don't want the 
>> whole machine doing anything else but to handle this traffic, that's the 
>> case where threaded solution may reach it's limits. of course you can scale 
>> the whole thing horizontally. it's a decision to make depending on the 
>> requirements. 
>> > 
>> > PS: i didn't say threads are bad, or threads-a-gogo. i just say there 
>> are cases, and they aren't rare, where threads are not good (enough). thats 
>> all. 
>>
>> Multi-process + IPC is sooo 70's. One should only have to suffer it to 
>> scale across machines, but, within the boundaries of a single machine, just 
>> to exploit multi-cores? No way. 
>>
>> Take a look at your computer's activity monitor: several hundreds of 
>> threads but just tens of processes... how can it be? How so if the way to 
>> go multi-core were multi-process, there are hundreds of threads? 
>>
>> On mine right now: 54 processes, 293 threads. Mail:13 threads, Safari:15 
>> threads, pid 0: 64 threads... Why not 15 Mail processes? Because it would 
>> be silly. 
>>
>> Also, when you have a single instance of your app programming becomes 
>> easier, because you don't have to go re-creating the app's context, nor 
>> cloning it, nor keeping it synchronized across a bunch of separate 
>> processes. 
>>
>> To keep node ticking, you just need an API to move blocking code out of 
>> its main/event loop thread, to a worker thread if you like to call it so, 
>> yes, and that's what TAGG lets you do, within a single process, without the 
>> hassles of multiple processes + IPC + lost app's contexts to re-create. 
>> -- 
>> Jorge.
>
>

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

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




[nodejs] Re: Multi-threaded Node.js

2013-02-18 Thread greelgorke
threads-a-gogo for small but cpu-heavy tasks.
child_process.fork for permanently running worker-like services (or use 
tools like mongroup)
cluster for horizontal scaling on a single machine to use all CPU-cores

Node is designed mainly for I/O intensive Use Cases, in fact it was born 
out of the idea to build up a web server, which can handle many concurrent 
connections and can scale horizontal w/o pain. easy integration of 
websockets support is on top of it. this is it, what node is for. 

as much as i like the idea to do almost all in node, i admit, there are 
tasks, that are not good to solve in node. They are rare, but they are 
there. And node have no thready for a reason: the complexity. classic 
threads are able to share state. this is the root of evil in multithreading 
:) other solutions on thread basis are better i.E. erlang has threads with 
message passing only, other platforms uses other technics for thread 
communication.

Node provides no multithreading to the developer, but it uses threads under 
the hood, so it is still efficient, at least as efficient as your longest 
computation.

"true parallelism"  !== threading. threads is one possible solution to 
implement parallel tasks. Node provides you with child_process and cluster 
to process-based solutions, web-services are another one, that distribute 
your app over network. and you have the ability to pass the task to 
completely other platform/tool/app if it suites it. a simple example here 
is to provide image scaling in your node app via passing the scaling work 
itself to imagemagick, which is a better tool for this kind of tasks. 

before i start to use threads in node i'd first look if i can delegate the 
task to some other tool or service. node is good at communication and 
streaming, and as such it also good as a dispatcher or commander in a 
cluster of services. 

Am Montag, 18. Februar 2013 01:15:48 UTC+1 schrieb RF:
>
> Hi,
>
> I'm CS student who is new to Node, and I have two questions:
>
>1. Is there currently an existing mechanism (e.g. module, core 
>functionality) that allows Node applications to spawn multiple threads (to 
>take advantage of multiple cores for true parallelism) ?
>2. If not, would this be a desirable feature?
>
> My understanding is that Node applications use a single thread to handle 
> everything by queuing events on an event loop to be processed sequentially.
> I also understand that this is the core feature that allows Node to grant 
> efficiency gains for specific types of applications, and is the (main?) 
> source of Node's popularity.
>
> Given this fact then (and assuming that it's correct), it would seem 
> counter-intuitive to enable multi-threaded functionality in Node when there 
> are other languages/frameworks available potentially more suited to 
> multi-threaded behavior. 
> However, an example use case that I'm thinking of is a situation whereby 
> an existing Node application needs to be adapted or extended with some 
> functionality that would benefit from true parallelism.
> So, maybe 3 or 4 threads could be created that would handle 3 or 4 tasks 
> more efficiently than Node's existing sequential behavior, while still 
> taking advantage of Node's established execution model in other areas of 
> the application.
>
> I was thinking along the lines of creating a Node module that exposes an 
> interface for creating threads and supplying them with the necessary 
> function (and also some mechanisms for dealing with shared data concurrency 
> and consensus issues).
> I have searched unsuccessfully through available resources in an attempt 
> to answer the above questions, so I'm hoping that someone can help me out.
>
> Regards,
> -Rob
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Proxy server with authentication

2013-02-18 Thread greelgorke
now i understand the requirement. i consider a proxy-server as something 
transparent to the user. what you are talking about is a kind of a web-ui 
to your services. in this case you of course totally can use 
connect/express. it would be an overkill to use it for a transparent proxy. 

Am Freitag, 15. Februar 2013 22:19:27 UTC+1 schrieb jal...@algotree.com:
>
> Hi,
>
> I used express here because i thought it will be easier to create login 
> pages and like @Jose F Romaniello said it would be easier to handle 
> sessions and cookies. I am actualy new to javascript ,nodejs and html, I 
> used nginx proxy till now,(being a sys admin) but then this requirement 
> came up and i thought about moving to node js.
>
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: Wanted: federated-event/message-emitting platform?

2013-02-19 Thread greelgorke
looks like a peer-to-peer network to me. here are some libs:

https://github.com/Raynos/peer-connection-network

or you can develop it as a grid (read p2p network with predefined peers) 
using https://github.com/substack/dnode

Am Montag, 18. Februar 2013 18:33:47 UTC+1 schrieb MikeB_2012:
>
> Hi all.  I'm an experienced data mining/machine learning algorithm 
> developer redirecting from programming/prototyping in Matlab (past decade) 
> to programming in js/node.js. I'm looking for guidance as to what node 
> packages I should be considering to achieve a certain functionality.  
>
> The functionality I'm looking for is approximately as follows:
>
>   a)  an assortment of sensors puts data on a network.  Each sensor has a 
> dedicated process that pre-processes sensor data.  The processed data is 
> then transmitted to other processes;
>   b)  there are several virtual 'layers' or 'groups'.  Each layer has a 
> specific purpose or goal that is attained through the asynchronous 
> processing of the processed sensor data by one or more processes;
>   c)  should any process fail/crash, the remaining processes are 
> unaffected;
>   d)  similarly, processes can be added to the system as required without 
> affecting other processes; and
>   e)  processes take input from other processes.  For example, some 
> processes obviously will use the output of sensor pre-processing 
> processes.  But some processes will simply be taking the output of other 
> processes.
>
> So you can picture this network of processes (a 'mesh' ?) with some 
> subsets of the mesh working towards common goals.  The idea is vaguely 
> comparable to neural networks but with large amounts of feedback say, a 
> liquid state NN vice multi-layer feed forward NN, complex processes vice 
> simple transfer functions at the mesh nodes, and asynchrony.
> Within the mesh, processes are born and die, but the whole operation 
> remains largely unaffected in the sense that other processes will only 
> lose/gain information but they won't fail (cease trying to process).  The 
> latter is important because a nuance is that a given process will decide 
> for itself what information it will use, what other processes it will 
> 'listen' to and will have to adapt when changes occur.  So processes must 
> be aware of each other.
>
> Anyways, I can fake portions of all this using Matlab (in un-real-time) 
> but node.js seems to offer the potential to actually implement the idea in 
> real-time, kind of, maybe.  (I'm still learning so some of you may know 
> better.)  I was optimistic with one node package, hook.io, but it has 
> shut down.  I'm happy to fork it but would need lots of help and guidance.  
> Several others were suggested including: kue, rabbitmq, zero-mq, nssocket, 
> dnode, amino, and federation. But whereas I'd found a clear explanation 
> of hook.io (with illustrations to confirm it seemed like what I 
> wanted)most
>  other packages need knowledge (eg. - reddis) that I don't yet have 
> ('federation' 
> being the exception ).
>
> So that's what I'm trying to do and it looks like js/node.js can help me 
> do it.  Is that a correct conclusion?  If so, are there any packages or 
> approaches that you might suggest?  As always, any constructive guidance or 
> advice would be appreciated.
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: Return value from callback

2013-02-19 Thread greelgorke
as far as i now ejs (as most of other template engines) does not support 
asynchronous helper. you have to fetch the comments first and then pass 
them to your template rendering

in your controller:

function(req, res, params){
var debate = //resolve the debate
*
debate.getComments(function(err,comments){
*
*
console.log(comments.length);
self.respond({comments: comments, debate: debate})
});
*
}

in view
*<%= comments.length; %>*

Am Montag, 18. Februar 2013 20:16:51 UTC+1 schrieb Eric Ponce:
>
> Hi guys!
>
> I'm working in a Geddy.JS application and I have one problem with one 
> function.
>
> In my view(in EJS) I have the next:
>
> *<%= h.comments(debate); %>*
> *
> *
> My problem: When we go to the "comments" function, we have:
> *
> *
> *
> exports.comments = function (debate) {
> debate.getComments(function(err,comments){
> console.log(comments.length);
> return comments.length;
> });
> };
>
> My app doesn't print anything, but CONSOLE.LOG prints all perfect.
> How can I return the value and print it into the view?
>
> Thanks to 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

--- 
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] Re: jsonobject not replaces \n character with new line .

2013-02-19 Thread greelgorke
\n is a new line 

here are to few infos to help. the db may encode the new lines wrong, the 
ui may render it wrong, the conversion of java to json may go wrong etc.

Am Dienstag, 19. Februar 2013 07:46:24 UTC+1 schrieb mkg:
>
> hi
> following is the process i do.
> i create jsonobject  in javascript
> then in java i use that json object and putted that string data in DB.
> db doent' store \n but it directly stores it in new lines.
> while reteriving time i gets string with \n but now when i convert java 
> obj to jsonobject \n is not replace with new lines 
> and i render that json object on UI. and ui also not showing \n .
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: jsonobject not replaces \n character with new line .

2013-02-19 Thread greelgorke
btw. it's not a node.js question, right? :D

Am Dienstag, 19. Februar 2013 15:49:48 UTC+1 schrieb greelgorke:
>
> \n is a new line 
>
> here are to few infos to help. the db may encode the new lines wrong, the 
> ui may render it wrong, the conversion of java to json may go wrong etc.
>
> Am Dienstag, 19. Februar 2013 07:46:24 UTC+1 schrieb mkg:
>>
>> hi
>> following is the process i do.
>> i create jsonobject  in javascript
>> then in java i use that json object and putted that string data in DB.
>> db doent' store \n but it directly stores it in new lines.
>> while reteriving time i gets string with \n but now when i convert java 
>> obj to jsonobject \n is not replace with new lines 
>> and i render that json object on UI. and ui also not showing \n .
>>
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: Best way to reload?

2013-02-19 Thread greelgorke
look at this https://github.com/LearnBoost/up

it in fact spinns new worker processes and let the old ones live for 
defined amount of time, so they have the chance to end their work 
gracefully before they die. and you have a cluster and simple keep-alive 
monitoring for free.

Am Dienstag, 19. Februar 2013 01:05:55 UTC+1 schrieb Federico Kereki:
>
> Hi!
>
> What's the best way to reload a node.js website? I mean, working with 
> Apache/PHP if you just upload a new PHP file, all newcomers will use that 
> file, without needing to restart/reload Apache. However, if you simply 
> "kill" a node.js process and restart it, currently connected users will be 
> in trouble, processes may be aborted in the middle, updates could be lost, 
> etc.
>
> I'm guessing that you could have a process running periodically, which 
> would monitor loaded modules for updates and, if needed, "require(...)" 
> them again after having done a "delete require.cache[...]".
>
> I've also found recommendations for "node-supervisor" and "nodemon", and 
> I'm sure there must be some more out there. 
>
> My only hard-and-fast requirement is that no connection is lost because of 
> the restart -- connected users shouldn't notice any change at all, though I 
> could stand a certain delay.
>
> What's the best way?
>
> Thanks, and best regards,
> Federico Kereki
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: Dynamic Web app in Node JS without Jade and Stylus

2013-02-19 Thread greelgorke
use express with it's static middleware. it's totally for dynamic webapps.

as well  as java servlets (tomcat) as wamp (php) using some kind of 
templating mechanism to transform dynamic data into html. if you mean with 
"as i am using wamp" that you want develop it like in php, then ejs 
templating engine could help your here, since it's the closest to plain 
html and default php-style templating. and you can skip stylus totally. use 
the static middleware to deliver static html and css, use ejs for views and 
setup request handlers for your ajax endpoints.

Am Dienstag, 19. Februar 2013 15:37:54 UTC+1 schrieb kanitkar...@gmail.com:
>
> I would like to repeat here that both html, css & js files & Node server 
> files are in the same domain.
>
> On Tuesday, February 19, 2013 8:05:53 PM UTC+5:30, kanitkar...@gmail.comwrote:
>>
>> Hi,
>>
>> I would like to do the following,
>>
>> 1) Have regular .html .css & .js files just like a normal web app
>>
>> 2) Interact with Node Js only through Ajax calls
>>
>> 3) But All files mentioned in 1) are also hosted on the same Node Http 
>> server.
>>
>> So when I say http://localhost:3000/index.html, Node Js server should 
>> give me index.html along with all css & js files included in it.
>>
>> Then my Javascript & Ajax code should drive the functionality with Node 
>> program getting called by ajax request.
>>
>> Can anyone please please suggest me the best way to do this ?
>>
>> I don't want to use Jade or Stylus. I want to develop as if I am using 
>> tomcat or wamp server & use power of Node where ever needed only.
>>
>> I am aware of express js framework but don't know how it will be useful 
>> for above scenario.
>>
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: Dynamic Web app in Node JS without Jade and Stylus

2013-02-20 Thread greelgorke
@Geerten well express is just a higher abstraction level than connect and 
provides some defaults around your project, provides some handy shortcuts 
etc. version of express past 3.0 allow you to build your app in a high 
modular way as mounted apps without much work. at the end it's a matter of 
taste and use of abstraction. 

@abhi:
1. use ejs, just replace the dynamic parts with serverside js. thats the 
simplest step. or deliver just plain html (with response.sendfile() ) and 
do clientside dom manipulation with ajax-delivered data as now

2. handlebars wrapper for express https://github.com/donpark/hbs. or just 
use handlbars.js directly in plain node/connect. just install and require 
it.

3. use connect (or express) with static middleware (as @Geerten suggested), 
port your php code into js functions with the signature function(request, 
response). register the function to the apropriate route. you do not have 
to use any template engine (jade) or css transpiler (stylus).

4. dont know. i use the web, there are so many tutorials, but i doubt, 
you'll find some which covers all the topics at once.
5. at last it's more a matter of taste, again. but key advantages of jade 
are: it abstracts html into a haml-like syntax, it offers you very rich set 
of how you can separate and structure your templates: partials, mixins, 
inheritance, layouts. if you are used to do logic in templates, then jade 
is ok too, but it's not really an advantage in my opinion.

6. connect static middleware, or https://github.com/cloudhead/node-static , 
or even more such module. just search on npm
in express a simple example:

var express = require('express')
var app = express()
//serves html, js and css files from the path, automagicaly setting headers 
suitable for caching et al
app.use(express.static('path/to/your/static/files'));


Am Mittwoch, 20. Februar 2013 01:19:23 UTC+1 schrieb kanitkar...@gmail.com:
>
> Thanks a lot Gregor & Geerten for your replies !!!
>
> I have following scenarios or situations
>
>
>1. In my projects, HTML designers create mockups in plane HTML & CSS 
>with dummy data where dynamically generated data will be placed and HTML 
>templates can be used by JavaScript developer later. Heavy use of CSS and 
>complex nested Html gets created with supporting jQuery or Javascript code 
>of jQuery plugins used sometimes. So a bit difficult to imagine doing same 
>in Jade.
>2. I don't know about Jade, but I am fond of HandleBars, so I want to 
>know how to use it in Node JS project ? 
>3. The scenario is like this ->> If I have an existing project with 
>this technology stack ->> HTML + CSS + JS + jQuery +  PHP(only for 
> database 
>calls and not for .php pages, php is connected to .html pages only through 
>Ajax). And now I just want "port" this Dynamic Web App to NodeJS by 
>replacing business logic written in PHP with Node JS and also have Node JS 
>as http web server. So no more PHP or WAMP in picture now. How can I 
>achieve this without Jade & Stylus ? Any pointers/ links to github repos 
> or 
>jsFiddles are welcome.
>4. What is an excellent ebook that I can buy which teaches how to do 
>end to end development of HTML + CSS + jQuery + HandleBars + Backbone/ 
>KnockoutJS + NodeJS kind of web apps without Jade
>5. Can any one of you experienced people elaborate on what are key 
>advantages of using Jade over HandleBars ? I just don't want to learn new 
>thing for the sake of it without a good reason :)
>6. How to achieve same thing mentioned in link(
>
> http://thecodinghumanist.com/blog/archives/2011/5/6/serving-static-files-from-node-js)
>  
>in a better & abstract way ? 
>
>
> On Tuesday, February 19, 2013 11:49:13 PM UTC+5:30, Geerten van Meel wrote:
>>
>> Great, someone who doesn't want to use express! I myself find this 
>> framework too specific as well. However, there are true advantages in using 
>> existing projects instead of re-inventing the wheel. Since the node http 
>> server is a bit rough around the edges though, some sort of http framework 
>> is recommended. Here's my pick:
>>
>>  - Use connect (on which express is based) for the basic functionality ( 
>> http://www.senchalabs.org/connect/ ) as the webserver framework.
>>
>>  - Use bodyparser middleware for POST request bodies.
>>
>>  - Write your own middleware for API access.
>>
>>  - Use static middleware for static file serving from a directory
>>
>>  - You can copy&paste this gist: https://gist.github.com/klovadis/4988305
>>
>> Connect basically allows you to execute so called middleware functions on 
>> a http request in a linear order. Whenever a request comes in, each 
>> function does something (i

[nodejs] Re: Dynamic Web app in Node JS without Jade and Stylus

2013-02-20 Thread greelgorke
> Still, don't let express be the next rails.

it won't, in fact with mounted apps it goes right in to opposite direction, 
you can configure every piece of your app different and split them on 
different nodes w/o changing much. there are several frameworks built on 
top of express, that want to be the next rails, but i don't like them much. 
if i want rails, i'd rather use the original. express/connect are inspired 
by sinatara, but they do not hide nodes nature away so it's a good way for 
me.

> Truth be told, judging from the questions you ask and thus the views I 
expect you have, you might want to take a step backwards and try and grasp 
what node.js really is, what it can do and what it is good at. Almost 
anything is possible, but if you keep seeing node the same way as your wamp 
installation, this will stop you from understanding node. Sure, with a few 
lines of code node can act like a static file server, but thats really not 
all there is. 

+ gazilion to this.


Am Mittwoch, 20. Februar 2013 12:14:11 UTC+1 schrieb Geerten van Meel:
>
> Lets say this again: With the setup above, you have the skeletton of your 
> own webserver that behaves exactly like you want it to. With that setup, it 
> acts like a static file server and can serve anything that is in your 
> assets folder ("/static"). You start your node server instead of wamp. It 
> acts roughly the same, except that it really does serve all files in that 
> folder as-is, no php preprocessing or the like. 
>
> Also,* there is no Jade or Stylus involved*. At all.
>
> If you have a webpage that runs on wamp, and does not rely on backend 
> logic (no php files),* you can copy&paste it into your static file folder*and 
> it works right out of the box. Your webserver acts like a plain static 
> file server. The setup mentioned above is what you asked for in #6.
>
> Note that .htaccess shenanigans are not supported, but you can do this 
> more elegantly in node anyways. To expose your api as you did using php, 
> you will need to get your hands dirty with node in the form of your own 
> route logic. express does make custom routing a bit easier on you, maybe 
> thats a better fit after all when you're starting out. You can still use it 
> without much of the extra features.
>
> Truth be told, judging from the questions you ask and thus the views I 
> expect you have, you might want to take a step backwards and try and grasp 
> what node.js really is, what it can do and what it is good at. Almost 
> anything is possible, but if you keep seeing node the same way as your wamp 
> installation, this will stop you from understanding node. Sure, with a few 
> lines of code node can act like a static file server, but thats really not 
> all there is.
>
> @Gregor: express does indeed evolve in the right direction; My initial 
> distaste when I first used it was based on its api inconsistencies and 
> conventions at a point when documentation was scarce and configuration 
> possibilities were very limited. This probably has improved by now and my 
> views in this regard are outdated. Still, don't let express be the next 
> rails.
>
> All the best,
>
> Geerten
>
> On Tuesday, February 19, 2013 3:35:53 PM UTC+1, kanitkar...@gmail.comwrote:
>>
>> Hi,
>>
>> I would like to do the following,
>>
>> 1) Have regular .html .css & .js files just like a normal web app
>>
>> 2) Interact with Node Js only through Ajax calls
>>
>> 3) But All files mentioned in 1) are also hosted on the same Node Http 
>> server.
>>
>> So when I say http://localhost:3000/index.html, Node Js server should 
>> give me index.html along with all css & js files included in it.
>>
>> Then my Javascript & Ajax code should drive the functionality with Node 
>> program getting called by ajax request.
>>
>> Can anyone please please suggest me the best way to do this ?
>>
>> I don't want to use Jade or Stylus. I want to develop as if I am using 
>> tomcat or wamp server & use power of Node where ever needed only.
>>
>> I am aware of express js framework but don't know how it will be useful 
>> for above scenario.
>>
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: Dynamic Web app in Node JS without Jade and Stylus

2013-02-20 Thread greelgorke
the article shows nothing more than a first approach.

for you, as a beginner, express is a better start to get results. follow 
this guide a bit http://expressjs.com/guide.html

your possible app.js:
var express = require('express')
var app = express()
var db = require('mysql').createConnection()
//serves html, js and css files from the path, automagicaly setting headers 
suitable for caching et al
app.use(express.static('path/to/your/static/files'));

app.get('/users/:id', function(req,res){
  db.query('SELECT * FROM users WHERE id = ' + 
connection.escape(req.params.id), function(err,user){
if(!err) res.json(user)
else res.send(500)
  })
})

try to start at the beginning. reade the guide, look at some reading 
resource on http://nodetoolbox.com/ , here on the mailinglist there are 
some topics gathering infos for beginners


Am Mittwoch, 20. Februar 2013 15:05:52 UTC+1 schrieb kanitkar...@gmail.com:
>
> I went through the comments given by both of you.
> I am certainly at initial stage of learning Node & thus have such 
> questions, but I will try to learn as much as I can and use your comments 
> as well.
> BTW : what do you think of below link ?
> (
> http://thecodinghumanist.com/blog/archives/2011/5/6/serving-static-files-from-node-js<https://mex07a.emailsrvr.com/owa/redir.aspx?C=0XUOyGttuk-E178ujGwQ4PWeAPyW4s9Ic5T8XNiO6uB0y_vWS3p3hQueay6fxh98syLG2dS89qU.&URL=http%3a%2f%2fthecodinghumanist.com%2fblog%2farchives%2f2011%2f5%2f6%2fserving-static-files-from-node-js>
> ) 
>
 

>
> Is it a good way to code in Node & if not can you point me to a better 
> abstraction ?
> Can you please provide a working example of sample web application done in 
> Node which has Html + CSS + jQuery + Node script files ?
>
 

>
> It can be just hello world in which jQuery is used in some way & the 
> jQuery script tag is included in index.html file.
> So Node server will serve index.html file & user can interact with jQuery 
> code.
>
 

>
> If you can please provide the above to me it will be of help. Thanks again.
>
> On Wednesday, February 20, 2013 5:05:28 PM UTC+5:30, greelgorke wrote:
>>
>> > Still, don't let express be the next rails.
>>
>> it won't, in fact with mounted apps it goes right in to opposite 
>> direction, you can configure every piece of your app different and split 
>> them on different nodes w/o changing much. there are several frameworks 
>> built on top of express, that want to be the next rails, but i don't like 
>> them much. if i want rails, i'd rather use the original. express/connect 
>> are inspired by sinatara, but they do not hide nodes nature away so it's a 
>> good way for me.
>>
>> > Truth be told, judging from the questions you ask and thus the views I 
>> expect you have, you might want to take a step backwards and try and grasp 
>> what node.js really is, what it can do and what it is good at. Almost 
>> anything is possible, but if you keep seeing node the same way as your wamp 
>> installation, this will stop you from understanding node. Sure, with a few 
>> lines of code node can act like a static file server, but thats really not 
>> all there is. 
>>
>> + gazilion to this.
>>
>>
>> Am Mittwoch, 20. Februar 2013 12:14:11 UTC+1 schrieb Geerten van Meel:
>>>
>>> Lets say this again: With the setup above, you have the skeletton of 
>>> your own webserver that behaves exactly like you want it to. With that 
>>> setup, it acts like a static file server and can serve anything that is in 
>>> your assets folder ("/static"). You start your node server instead of wamp. 
>>> It acts roughly the same, except that it really does serve all files in 
>>> that folder as-is, no php preprocessing or the like. 
>>>
>>> Also,* there is no Jade or Stylus involved*. At all.
>>>
>>> If you have a webpage that runs on wamp, and does not rely on backend 
>>> logic (no php files),* you can copy&paste it into your static file 
>>> folder* and it works right out of the box. Your webserver acts like a 
>>> plain static file server. The setup mentioned above is what you asked for 
>>> in #6.
>>>
>>> Note that .htaccess shenanigans are not supported, but you can do this 
>>> more elegantly in node anyways. To expose your api as you did using php, 
>>> you will need to get your hands dirty with node in the form of your own 
>>> route logic. express does make custom routing a bit easier on you, maybe 
>>> thats a better fit after all when you're starting out. You can still use it 
&

[nodejs] Re: Any way to wrap http.serverResponse?

2013-02-20 Thread greelgorke
what exactly are you trying to do? of course you can always wrap anything 
and observe actions etc., but it's not the problem you're trying to solve 
in first place, right?

Am Mittwoch, 20. Februar 2013 16:46:31 UTC+1 schrieb deitch:
>
> Is there any way to wrap http.serverResponse?
>
> E.g. I am using a module that takes as its input http.serverRequest and 
> http.serverResponse. I want to be able to transparently catch any actions 
> that the module performs on http.serverResponse so I can cache the 
> statusCode, header and response.
>
> Do I have to override each and every major function - write, writeHead, 
> end, setHeader, removeHeader - to do so? Is there a simpler way? I thought 
> about looking for some 'end' type event, but that would miss all of the 
> streaming data.
>
>
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: Return value from callback

2013-02-20 Thread greelgorke
this version will just return the result of getComments, which seem to be 
 an async function. so anything that might be returned from it will be not 
the comments.

Am Mittwoch, 20. Februar 2013 19:00:45 UTC+1 schrieb Sergey Jamy:
>
> As i see you exports function "comments" which doesn't have self "return". 
> Maybe this work:
>
> exports.comments = function (debate) {
> *return* debate.getComments(function(err,comments){
> console.log(comments.length);
> return comments.length;
> });
> };
>
> понедельник, 18 февраля 2013 г., 21:16:51 UTC+2 пользователь Eric Ponce 
> написал:
>>
>> Hi guys!
>>
>> I'm working in a Geddy.JS application and I have one problem with one 
>> function.
>>
>> In my view(in EJS) I have the next:
>>
>> *<%= h.comments(debate); %>*
>> *
>> *
>> My problem: When we go to the "comments" function, we have:
>> *
>> *
>> *
>> exports.comments = function (debate) {
>> debate.getComments(function(err,comments){
>> console.log(comments.length);
>> return comments.length;
>> });
>> };
>>
>> My app doesn't print anything, but CONSOLE.LOG prints all perfect.
>> How can I return the value and print it into the view?
>>
>> Thanks to 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

--- 
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] Re: Any way to wrap http.serverResponse?

2013-02-20 Thread greelgorke
it's not clear how/what for you want to utilize the response. 
introspection? manipulation? 

Am Mittwoch, 20. Februar 2013 21:05:35 UTC+1 schrieb deitch:
>
> Yeah, I should have been more clear, shouldn't I?
>
> Adding handling to node-http-proxy. It takes as its input the 
> (request,response) pair from an http server callback handler. I want to 
> wrap it so I can cache as well as some other processing.
>
> Normal http operation looks like this: 
>
> Client > Node
>
> Proxy operation looks like this
>
> Client > Node (running node-http-proxy) > Remote service
>
> What I am trying to do:
>
>
> Client > Node (running my handler, passes to node-http-proxy) > 
> Remote service
>
> It is easier to get in front of the request; I want to be able to 
> instrument the response.
>
> Is that clearer?
>
>
>
> On Wednesday, February 20, 2013 9:24:21 PM UTC+2, greelgorke wrote:
>>
>> what exactly are you trying to do? of course you can always wrap anything 
>> and observe actions etc., but it's not the problem you're trying to solve 
>> in first place, right?
>>
>> Am Mittwoch, 20. Februar 2013 16:46:31 UTC+1 schrieb deitch:
>>>
>>> Is there any way to wrap http.serverResponse?
>>>
>>> E.g. I am using a module that takes as its input http.serverRequest and 
>>> http.serverResponse. I want to be able to transparently catch any actions 
>>> that the module performs on http.serverResponse so I can cache the 
>>> statusCode, header and response.
>>>
>>> Do I have to override each and every major function - write, writeHead, 
>>> end, setHeader, removeHeader - to do so? Is there a simpler way? I thought 
>>> about looking for some 'end' type event, but that would miss all of the 
>>> streaming data.
>>>
>>>
>>>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: Any way to wrap http.serverResponse?

2013-02-21 Thread greelgorke
you can use gists and link to them.

i remember, that underscore has a wrap function, you could use it or copy 
it's implementation. 

Am Donnerstag, 21. Februar 2013 09:37:53 UTC+1 schrieb deitch:
>
> So I did something like this (pseudocode), works pretty well. I am 
> currently using it to transparently cache requests. This would be *so* much 
> easier if google groups supported markdown like github. 


> // config includes what to call next in the chain, ttl for my cache, and a 
> secret key to flush the cache remotely, etc. In one instance, I have a list 
> of regex for which to invoke on the URL
> module.exports = function(config) {
>   return function(req,res,next) {
> wrapResponse(res);
> // do the next thing
>   };
> };
>
> wrapResponse looks like:
>
> wrapResponse = function(res) {
>   write = res.write, writeHead = res.writeHead, setHeader = res.setHeader, 
> removeHeader = res.removeHeader, end = res.end;
>   res.write = function(chunk,encoding) {
> // do what you want with it, like caching
> write.apply(this,arguments);
>   };
> };
>
> The above is generic, but I turned it into a nice performant in-memory 
> caching module to wrap node-http-proxy. Variable ttl, and external 
> flushable. 
>
> On Wednesday, February 20, 2013 10:50:12 PM UTC+2, deitch wrote:
>>
>> Just introspection. I am happy to let it go along its way in both 
>> directions, as long as I can peek in and see what data passes.
>>
>> On Wednesday, February 20, 2013 10:42:59 PM UTC+2, greelgorke wrote:
>>>
>>> it's not clear how/what for you want to utilize the response. 
>>> introspection? manipulation? 
>>>
>>> Am Mittwoch, 20. Februar 2013 21:05:35 UTC+1 schrieb deitch:
>>>>
>>>> Yeah, I should have been more clear, shouldn't I?
>>>>
>>>> Adding handling to node-http-proxy. It takes as its input the 
>>>> (request,response) pair from an http server callback handler. I want to 
>>>> wrap it so I can cache as well as some other processing.
>>>>
>>>> Normal http operation looks like this: 
>>>>
>>>> Client > Node
>>>>
>>>> Proxy operation looks like this
>>>>
>>>> Client > Node (running node-http-proxy) > Remote service
>>>>
>>>> What I am trying to do:
>>>>
>>>>
>>>> Client > Node (running my handler, passes to node-http-proxy) > 
>>>> Remote service
>>>>
>>>> It is easier to get in front of the request; I want to be able to 
>>>> instrument the response.
>>>>
>>>> Is that clearer?
>>>>
>>>>
>>>>
>>>> On Wednesday, February 20, 2013 9:24:21 PM UTC+2, greelgorke wrote:
>>>>>
>>>>> what exactly are you trying to do? of course you can always wrap 
>>>>> anything and observe actions etc., but it's not the problem you're trying 
>>>>> to solve in first place, right?
>>>>>
>>>>> Am Mittwoch, 20. Februar 2013 16:46:31 UTC+1 schrieb deitch:
>>>>>>
>>>>>> Is there any way to wrap http.serverResponse?
>>>>>>
>>>>>> E.g. I am using a module that takes as its input http.serverRequest 
>>>>>> and http.serverResponse. I want to be able to transparently catch any 
>>>>>> actions that the module performs on http.serverResponse so I can cache 
>>>>>> the 
>>>>>> statusCode, header and response.
>>>>>>
>>>>>> Do I have to override each and every major function - write, 
>>>>>> writeHead, end, setHeader, removeHeader - to do so? Is there a simpler 
>>>>>> way? 
>>>>>> I thought about looking for some 'end' type event, but that would miss 
>>>>>> all 
>>>>>> of the streaming data.
>>>>>>
>>>>>>
>>>>>>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: Suggestion for the implementation of util.inherits()

2013-03-05 Thread greelgorke
Your version makes the prototype chain longer, which may have a performance 
impact on some important parts of the lib. Please Correct me if i'm wrong, 
but this could produce chains:
CustomStream->(ReadableStream->) Stream->EventEmitter->Object.prototype
vs new one:
CustomStream->CustomStream.prototype->(ReadableStream->ReadableStream.prototype->)
 
Stream->Stream.prototype->EventEmitter->EventEmitter.prototype->Object.prototype

in your particular example you create a singleton. this can be done in this 
way too:

varAsLinker = require("./AsLinker");

module.exports = {}

module.exports.__proto__ = new AsLinker()

module.exports.link = function(){ // override the parent method };


or even like this:

varAsLinker = require("./AsLinker"), linker = new AsLinker();

module.exports = linker;

//if you want to do super.link prepare for it:
var superLink = linker.link;

module.exports.link = function(){ // override the parent method
  var superResult = superLink.apply(this,arguments);
  //do more with superResult
 };

other usecases? i don't think the change would make any better than current 
solution. the only feature, to be flexible with the position of 
module.exports seems not important to me. it's less important where it is, 
but more important that all modules put this line in the same position (i 
do on the bottom). and if you write one-function-modules, you never have to 
bother about the position anyway.



Am Dienstag, 5. März 2013 06:24:07 UTC+1 schrieb benp...@tacol.biz:
>
>   Post reply
> [image: More message actions]
>  1:19 PM (1 minute ago) 
>   Hi...wondering if this is possible for the method.
>
> I know util.inherits() might be implemented in this way.
>
> function inherits(constructor, super){
>
> constructor.prototype = Object.create(super.prototype);
> constructor.prototype.constructor = constructor;
> constructor.super_ = super;
> }
>
> I am wondering if it could be changed to the following way:
>
> function inherits(constructor, super){
>
> constructor.prototype.__proto__ = super.prototype;
> constructor.super_ = super;
> }
>
> The main difference is the second implementation won't change the 
> constructor.prototype, and the benefit is we can use module.exports more 
> flexible, e.g.
>
> varutil = require("util"),
> AsLinker = require("./AsLinker");
>
> module.exports = new SomeLinker(); // put the module.exports line in the 
> beginning of the script
>
> function SomeLinker(){ 
>
> AsLinker.call(this);
> }
>
> util.inherits(SomeLinker, AsLinker);
>
> SomeLinker.prototype.link = function(){ // override the parent method };
>
> Since the SomeLinker.prototype is the original one, we can still update 
> the SomeLinker.prototype after module.exports = new SomeLinker();
> In the current implementation of util.inherits(), we must move the 
> module.exports = new SomeLinker() to the bottom of the script after the 
> method is added to the SomeLinker.prototype.
> Or the instance of SomeLinker will have no chance to get the new prototype.
>
> Just a thought to improve the convenience of Node.js coding, apologized if 
> I am wrong, since I know it's been locked status. But the interface is the 
> same, maybe it could be changed :)
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: learning NodeJS and looking for something similar to Apache Wicket (or similar component framework)

2013-03-07 Thread greelgorke
you may be find this interesting http://component.io/

Am Donnerstag, 7. März 2013 10:42:57 UTC+1 schrieb Ernesto Reinaldo 
Barreiro:
>
> Hi,
>
> I have been learning NodeJS for a couple of days and exploring around... 
>  I have a question regarding the "view" layers that can be used in 
> combination with NodeJS. I have read about Express (http://expressjs.com
> ), https://github.com/visionmedia/consolidate.js, Jade, EmberJS, and even 
> played a bit with Jade + AngularJS. But none of the above has anything to 
> offer that compares to what Wicket offers for "server side" in JAVA (i.e 
> componentization-templating+state management). From the little I have seen 
> AngularJS is what resembles more to Wicket...  I know my question might be 
> stupid and originated out of my ignorance but... Is there a components 
> framework similar to Wicket (at least on the componentization+templating 
> part)  on NodeJS ecosystem?
>
> P.S. I have no intention of creating a "frameworks war" as I'm a 
> contributor to OpenSource myself and  I have the highest respect for 
> anything you can use for "free". I'm just someone trying to learn and 
> seeking the advice of more experienced NodeJS users/developers.
>
> Best Regards,
>
> Ernesto
>
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] Re: RFC: Looking for guidance on NPM

2013-03-07 Thread greelgorke
it's for both. better say, it's for apps and libs. A Module is just a file 
in the Common.js style. there are many packages in npm that are both, lib 
and app (mostly CLI). so the right name is package, that is just:
A folder containing a package.json file


Am Donnerstag, 7. März 2013 14:07:56 UTC+1 schrieb Justin Novack:
>
> Hello World!
>
> Is the npm registry for modules or applications?  There's conflicting 
> words in the documentation.
>
> Long story short (too late!), upon seeing LIFX, and inspired by the NodeJS 
> Socket Lights video on Vimeo, I figured NodeJS would be a perfect minimal 
> app to control the lights.  So, I have my first proof of concept working 
> with protocol buffers without the SDK being released, and I put it up on 
> npm (lifx.js) to both dip my feet in and encourage more development.
>
> But it's currently NOT a module you can call do to something, currently, 
> it's just an app.  Eventually, I see it both as a front (app) and back 
> (module) end, but I'm not there yet.  Am I executing poor form by putting 
> it up on npm?  I am really just trying to get a feel for the community and 
> learn best practices. I'm only a week in, be gentle.
>
> Thank you for your consideration.
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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.




  1   2   3   4   5   >