Re: [nodejs] how to create a singleton

2013-11-18 Thread Jose G. Quenum
Please check Addy Osmani book, Learning Javascript design patterns. 
http://addyosmani.com/resources/essentialjsdesignpatterns/book/
It has a correct version of singleton implementation

On Nov 19, 2013, at 1:38 AM, Reza Razavipour reza.razavip...@gmail.com wrote:

 A newbie question...
 
 I have an app that connects and reuses the same connection to a remote 
 database and a connection to a remote soap server.
 I want to implement a singleton pattern for each of these. I am used to doing 
 that in C++ and Java but want to know what the standard 
 implementation for a Singleton pattern is in node.js.
 
 Any recommendations or references.
 
 
 
 -- 
 -- 
 Job Board: http://jobs.nodejs.org/
 Posting guidelines: 
 https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
 You received this message because you are subscribed to the Google
 Groups nodejs group.
 To post to this group, send email to nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/nodejs?hl=en?hl=en
  
 --- 
 You received this message because you are subscribed to the Google Groups 
 nodejs group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to nodejs+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.

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

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


Re: [nodejs] Re: how to create a singleton

2013-11-18 Thread Jose G. Quenum
yeah that's right. You just need to add the line 
module.exports = mySingleton
and in the caller file require as follows
var singleton = require('./single').mySingleton

Hope that helps
José

On Nov 19, 2013, at 2:40 AM, Reza Razavipour reza.razavip...@gmail.com wrote:

 Wonderful book, thank you.
 
 So reading the book, if I put the code for the mySingleton class into a file 
 on its own, call it single.js. 
 In my main.js, I add that with a require statement, such as var singleton = 
 require('./.single);
 when I say, singleton.getInstance(), I get a compile error saying singleton 
 does not have a getInstance function...
 
 Do I have to add an export to the single.js file I created or what am I 
 missing...
 
 The code is as follows:
 
 var mySingleton = (function() {
 
 var instance;
 
 
 
 function init() {
 
 
 
 var privateRandomNumber = Math.random();
 
 
 
 return {
 
 
 
 publicMethod : function() {
 
 
 
 console.log(The public can see me!);
 
 
 
 },
 
 
 
 publicProperty : I am also public,
 
 
 
 getRandomNumber : function() {
 
 
 
 return privateRandomNumber;
 
 
 
 },
 
 
 
 getInstance : function() {
 
 if (!instance) {
 
 
 
 instance = init();
 
 
 
 }
 
 return instance;
 
 
 
 }
 
 };
 
 };
 
 return {
 
 getInstance : function() {
 
 
 
 if (!instance) {
 
 
 
 instance = init();
 
 
 
 }
 
 return instance;
 
 }
 
 };
 
 })();
 
 
 
 
 
 Thanks for the help.
 
 Reza
 
 
 
 
 On Monday, November 18, 2013 3:38:09 PM UTC-8, Reza Razavipour wrote:
 A newbie question...
 
 I have an app that connects and reuses the same connection to a remote 
 database and a connection to a remote soap server.
 I want to implement a singleton pattern for each of these. I am used to doing 
 that in C++ and Java but want to know what the standard 
 implementation for a Singleton pattern is in node.js.
 
 Any recommendations or references.
 
 
 
 -- 
 -- 
 Job Board: http://jobs.nodejs.org/
 Posting guidelines: 
 https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
 You received this message because you are subscribed to the Google
 Groups nodejs group.
 To post to this group, send email to nodejs@googlegroups.com
 To unsubscribe from this group, 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] git server built with node

2013-04-20 Thread Jose G. Quenum
Hi Quinton,
Took a look at gitserver. Interesting. I'd love to see some comparisons to 
gitolite, especially how flexible it is to manage permissions and add hooks.
good job anyway
On Apr 18, 2013, at 10:51 PM, Quinton Pike qrp...@gmail.com wrote:

 I am building a NodeJS multi-tenant git server based on pushover. 
 
 If you would like, I can put it on github and we can work on it together.
 
 Let me know - Thanks.
 
 On Monday, March 18, 2013 8:14:58 PM UTC-4, Tim Dickinson wrote:
 Hey all, I'm looking for a git server or a module to build a git server with 
 node.js.
 
 I have looked at pushover and from what I can tell I could build a git server 
 with it.
 
 Can anyone tell me more?
 
 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
  
 --- 
 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] Node.js under OSX

2012-08-03 Thread Jose G. Quenum
Hi Bodo,
choosing Homebrew over Mac Ports was the right thing to do as far as I can 
tell. I made the change about two years ago and have never regretted it. 
Anyway, node.js on os x works just fine for me
José
On 3 Aug 2012, at 10:56, kyogron kyog...@googlemail.com wrote:

 Hi,
 
 I have now switched from GNU/Linux to Mac OSX.
 
 I am quite uncertain about managing dev-packages but I also may have to say 
 that I am archlinux spoilt.
 
 However I finally managed installing node, mongodb and redis through Homebrew.
 As editor I use sublime text2. 
 
 I would now like to know if choosing Homebrew over MacPorts was a good 
 decision and if there are other things to mention about using node under OSX
 
 In the meantime I will try to use automator to start mongodb and redis on 
 boot up.
 
 Best Regards,
 Bodo
 
 -- 
 Job Board: http://jobs.nodejs.org/
 Posting guidelines: 
 https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
 You received this message because you are subscribed to the Google
 Groups nodejs group.
 To post to this group, send email to nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/nodejs?hl=en?hl=en

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


[nodejs] - Github Followers Thread

2012-07-15 Thread Jose G. Quenum
Hi all,
below is the github link to a project I have been working on on and off for a 
few months now. Unfortunately I haven't deployed it yet because (a) there still 
are a few use cases to complete, (2) the deployment is kinda tricky in that I 
need both an account to host git repositories and a server to host the riak db. 
I am still thinking about the best option. Any suggestion is welcome.
https://github.com/joques/the_fellow_ship
José

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