Re: [nodejs] Help with JWT implementation

2015-08-06 Thread josh
got it. so i only need to access the DB (or access an endpoint that verify 
the existence of the user) at the login. from that moment, the JWT token is 
self sufficient and I no longer need any DB (for 
authentication/authorization purposes).

Thanks!

On Wednesday, August 5, 2015 at 2:17:51 PM UTC-7, Alexander Behrens wrote:

 You have your user accounts in a db. When a users logs in, you verify his 
 account. You store every information you might need in the future in the 
 claim of the JWT. You create the JWT and send it back to the user. With 
 this JWT the user can now log in from anywhere, anytime until the JWT 
 expires. You verify the user by decoding the JWT. The whole point of having 
 JWT is to not store them in a db.

 On Wed, Aug 5, 2015 at 7:40 AM, josh macmilla...@gmail.com javascript: 
 wrote:

 Thank you Alexander!

 so maybe I don't even need to store anything in a DB? 

 On Tuesday, August 4, 2015 at 6:13:51 AM UTC-7, Alexander Behrens wrote:

  JWT token is created with user id, stored in a DB and JWT is returned 
 to the app.

 Do you mean that user id stored in a DB or do you store the JWT in a DB? 
 If you are storing the JWT, there is no point of using JWT :)

  The app will store the JWT in the localStorage

 I always thought this was a good approach. But that way you will never 
 get the JWT when the user initially loads the web app. You always have to 
 render some boilerplate HTML and then let the client-side Javascript do the 
 authentication call for you.

 On Tue, Aug 4, 2015 at 4:01 AM, josh macmilla...@gmail.com wrote:

 We use OneLogIn for SSO and also SalesForce. We would like to have a 
 single auth service that will take care of authentication and 
 authorization 
 to all our apps. 
 Is this diagram looks like a good approach? 
 http://i.imgur.com/Ji1I1P4.png -

 Here is the suggested flow: 
 email/password form - auth service - onelogin reply yes or no - 
 salesforce reply with user id. JWT token is created with user id, stored 
 in 
 a DB and JWT is returned to the app. The app will store the JWT in the 
 localStorage (or in case of cordova is some other storage) and sends it in 
 the HTTP header to every other serivce. 

 BTW, I read conflicting article about localStorage as a place to store 
 JWT:

 https://stormpath.com/blog/where-to-store-your-jwts-cookies-vs-html5-web-storage/

 http://stackoverflow.com/questions/27067251/where-to-store-jwt-in-browser-how-to-protect-against-csrf

 Opinions, links and suggestions are all welcome!

 -- 
 Job board: http://jobs.nodejs.org/
 New group rules: 
 https://gist.github.com/othiym23/9886289#file-moderation-policy-md
 Old group rules: 
 https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
 --- 
 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.
 To post to this group, send email to nod...@googlegroups.com.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/nodejs/7568b93c-9635-4615-b0c0-a541cb51b2dd%40googlegroups.com
  
 https://groups.google.com/d/msgid/nodejs/7568b93c-9635-4615-b0c0-a541cb51b2dd%40googlegroups.com?utm_medium=emailutm_source=footer
 .
 For more options, visit https://groups.google.com/d/optout.


 -- 
 Job board: http://jobs.nodejs.org/
 New group rules: 
 https://gist.github.com/othiym23/9886289#file-moderation-policy-md
 Old group rules: 
 https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
 --- 
 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 javascript:.
 To post to this group, send email to nod...@googlegroups.com 
 javascript:.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/nodejs/d552ecee-570f-4c36-8f83-bad78f1edbbc%40googlegroups.com
  
 https://groups.google.com/d/msgid/nodejs/d552ecee-570f-4c36-8f83-bad78f1edbbc%40googlegroups.com?utm_medium=emailutm_source=footer
 .

 For more options, visit https://groups.google.com/d/optout.




-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
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.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/84d2d6d5-4572-4da0-9125-eb67e5e05f9c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [nodejs] Help with JWT implementation

2015-08-05 Thread josh
Thank you Alexander!

so maybe I don't even need to store anything in a DB? 

On Tuesday, August 4, 2015 at 6:13:51 AM UTC-7, Alexander Behrens wrote:

  JWT token is created with user id, stored in a DB and JWT is returned 
 to the app.

 Do you mean that user id stored in a DB or do you store the JWT in a DB? 
 If you are storing the JWT, there is no point of using JWT :)

  The app will store the JWT in the localStorage

 I always thought this was a good approach. But that way you will never get 
 the JWT when the user initially loads the web app. You always have to 
 render some boilerplate HTML and then let the client-side Javascript do the 
 authentication call for you.

 On Tue, Aug 4, 2015 at 4:01 AM, josh macmilla...@gmail.com javascript: 
 wrote:

 We use OneLogIn for SSO and also SalesForce. We would like to have a 
 single auth service that will take care of authentication and authorization 
 to all our apps. 
 Is this diagram looks like a good approach? 
 http://i.imgur.com/Ji1I1P4.png -

 Here is the suggested flow: 
 email/password form - auth service - onelogin reply yes or no - 
 salesforce reply with user id. JWT token is created with user id, stored in 
 a DB and JWT is returned to the app. The app will store the JWT in the 
 localStorage (or in case of cordova is some other storage) and sends it in 
 the HTTP header to every other serivce. 

 BTW, I read conflicting article about localStorage as a place to store 
 JWT:

 https://stormpath.com/blog/where-to-store-your-jwts-cookies-vs-html5-web-storage/

 http://stackoverflow.com/questions/27067251/where-to-store-jwt-in-browser-how-to-protect-against-csrf

 Opinions, links and suggestions are all welcome!

 -- 
 Job board: http://jobs.nodejs.org/
 New group rules: 
 https://gist.github.com/othiym23/9886289#file-moderation-policy-md
 Old group rules: 
 https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
 --- 
 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 javascript:.
 To post to this group, send email to nod...@googlegroups.com 
 javascript:.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/nodejs/7568b93c-9635-4615-b0c0-a541cb51b2dd%40googlegroups.com
  
 https://groups.google.com/d/msgid/nodejs/7568b93c-9635-4615-b0c0-a541cb51b2dd%40googlegroups.com?utm_medium=emailutm_source=footer
 .
 For more options, visit https://groups.google.com/d/optout.




-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
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.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/d552ecee-570f-4c36-8f83-bad78f1edbbc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[nodejs] Help with JWT implementation

2015-08-03 Thread josh
We use OneLogIn for SSO and also SalesForce. We would like to have a single 
auth service that will take care of authentication and authorization to all 
our apps. 
Is this diagram looks like a good approach? http://i.imgur.com/Ji1I1P4.png -

Here is the suggested flow: 
email/password form - auth service - onelogin reply yes or no - 
salesforce reply with user id. JWT token is created with user id, stored in 
a DB and JWT is returned to the app. The app will store the JWT in the 
localStorage (or in case of cordova is some other storage) and sends it in 
the HTTP header to every other serivce. 

BTW, I read conflicting article about localStorage as a place to store JWT:
https://stormpath.com/blog/where-to-store-your-jwts-cookies-vs-html5-web-storage/
http://stackoverflow.com/questions/27067251/where-to-store-jwt-in-browser-how-to-protect-against-csrf

Opinions, links and suggestions are all welcome!

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
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.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/7568b93c-9635-4615-b0c0-a541cb51b2dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [nodejs] Re: Unable to complete a PUT request of AngularJS data via a factory and node.js

2014-03-03 Thread Josh Longbrake
Thanks for the info.  The pending is showing in my angular put, as the node
request is never returned.  Does the res.send come within client.put?

client.put(https://hostsite.com;, args, function (req, res) {
   // res.send like this?
});

//like this?
app.put('/api/provisions/', function (req, res) {
On Mar 3, 2014 2:08 AM, greelgorke greelgo...@gmail.com wrote:

 what is pending? the request from angular to your route handler? or the
 rest-client.put request?

 1. there is no alert() in node. try console.log
 2. you have to do something with your reoute handler. i assume you are
 using express on server side. your route handler gets 2 params: request and
 response. (the thing you named data is the reqeust object.) when you are
 done with anything in your route handler you have to do something to
 respond to the client: res.send or something like that.

 Am Freitag, 28. Februar 2014 22:58:06 UTC+1 schrieb Josh Longbrake:

 I have been unable to complete this request, using a few different
 options, none of which are working as I believe implementation is
 incorrect.  How do I get the request through?

 my request:

 http{
 host: 'hostsite.com',
 port: 443,
 data: data.body.prov,
 path: '/api/3/mdm/devices/'+ data.body.id,
 method: 'PUT',
 headers: {'Authorization': 'Bearer x'}
 }


 It is constructed as such:


 AngularJS controller:

 $scope.provisionRule = function (rule) {
 var dataToPass = {prov: rule.newProvisions, id:
 $scope.deviceId};

 Rules.provision(dataToPass)
 .success(function (data) {
 console.log('provision success')
 console.log(data);
 });
 }

 AngularJS factory:

 angular.module('ruleService', [])

 .factory('Rules', function($http) {
 return {
 provision : function(data) {
 console.log('provision: ' + data)
 return $http.put('/api/provisions/', data);
 }
 }
 });

 node.js:

 module.exports = function (app) {
 //this is not correct syntax but what I am needing to accomplish

 app.put('/api/provisions/', function (data) {

 console.log(provisions prov: + JSON.stringify(data.body.prov))
 console.log(provisions id: + JSON.stringify(data.body.id))

 http{
 host: 'hostsite.com',
 port: 443,
 data: data.body.prov,
 path: '/api/+ data.body.id,
 method: 'PUT',
 headers: {'Authorization': 'Bearer x'}
 }
 }


 using this method below I get:

1. Status Code:
503 Service Unavailable


 node.js:
 module.exports = function (app) {

 var Client = require('node-rest-client').Client;

 app.put('/api/provisions/', function (data) {

 console.log(provisions prov: + JSON.stringify(data.body.prov))
 console.log(provisions id: + JSON.stringify(data.body.id))

 var client = new Client();

 var args = {
 path: '/api/'+ data.body.id,
 port: 443,
 headers: {'Authorization': 'Bearer  x'},
 data: {'restrictions': data.body.prov}
 };

 console.log('args.data:' + JSON.stringify(args.data))

 client.put(https://hostsite.com;, args, function (data,
 response) {
 alert(data);
 });

 });
 }




 I have been provided the host, port, path and headers Bearer.  While the
 above is not the actual provided info, it is a representation of such.  My
 status just hangs in pending.
 Any and all help is greatly appreciated as Im banging my head 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

 ---
 You received this message because you are subscribed to a topic in the
 Google Groups nodejs group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/nodejs/vuyCAeMFIyE/unsubscribe.
 To unsubscribe from this group and all its topics, 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

Re: [nodejs] node.js and node-rest-client TypeError: Cannot read property 'tunnel' of undefined

2014-02-28 Thread Josh Longbrake
Just wanted to confirm that the github fixed version is working.

On Thursday, February 27, 2014 4:07:22 PM UTC-6, // ravi wrote:

 On Feb 27, 2014, at 4:57 PM, Josh Longbrake 
 jo...@studiobrainchild.comjavascript: 
 wrote:

 Hmm.  Its the installed package from homebrew but it may be an older 
 version of homebrew / NPM. 


 Josh, it’s not Homebrew or NPM themselves, but the version of 
 node-rest-client that’s in the NPM repository (assuming you installed the 
 module using ’nom install node-rest-client’ or equivalent). The 
 node-rest-client (in the NPM repository) has the bug that you hit. The code 
 on GitHub does not. Here’s the relevant bug report:

 https://github.com/aacerox/node-rest-client/issues/22

 Here’s the fix commit:


 https://github.com/aacerox/node-rest-client/commit/316231ee476f5a3039dbf1940615c78925e73072

 You can contact the author to see when he plans to publish it to NPM. In 
 the meantime, if you are in a hurry, you could (factoring risks) copy the 
 fixed file from GitHub.

 Good catch, ill update and try again.  From your view does anything else 
 look inherently wrong?


 Not related to the issue you report, no.

 Thanks for the fresh eyes!


 Glad to help,

 —ravi





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

2014-02-28 Thread Josh Longbrake
I have been unable to complete this request, using a few different options, 
none of which are working as I believe implementation is incorrect.  How do 
I get the request through?

my request:

http{
host: 'hostsite.com',
port: 443, 
data: data.body.prov,
path: '/api/3/mdm/devices/'+ data.body.id,
method: 'PUT',
headers: {'Authorization': 'Bearer x'}
}


It is constructed as such:


AngularJS controller:

$scope.provisionRule = function (rule) {
var dataToPass = {prov: rule.newProvisions, id: 
$scope.deviceId};

Rules.provision(dataToPass)
.success(function (data) {
console.log('provision success')
console.log(data);
});
}

AngularJS factory:

angular.module('ruleService', [])

.factory('Rules', function($http) {
return {
provision : function(data) {
console.log('provision: ' + data)
return $http.put('/api/provisions/', data);
}
}
});

node.js:

module.exports = function (app) {
//this is not correct syntax but what I am needing to accomplish

app.put('/api/provisions/', function (data) {

console.log(provisions prov: + JSON.stringify(data.body.prov))
console.log(provisions id: + JSON.stringify(data.body.id))

http{
host: 'hostsite.com',
port: 443, 
data: data.body.prov,
path: '/api/+ data.body.id,
method: 'PUT',
headers: {'Authorization': 'Bearer x'}
}
}


using this method below I get: 

   1. Status Code:
   503 Service Unavailable
   

node.js:
module.exports = function (app) {

var Client = require('node-rest-client').Client;

app.put('/api/provisions/', function (data) {

console.log(provisions prov: + JSON.stringify(data.body.prov))
console.log(provisions id: + JSON.stringify(data.body.id))

var client = new Client();

var args = {
path: '/api/'+ data.body.id,
port: 443,
headers: {'Authorization': 'Bearer  x'},
data: {'restrictions': data.body.prov}
};

console.log('args.data:' + JSON.stringify(args.data))

client.put(https://hostsite.com;, args, function (data, response) {
alert(data);
});

});
}




I have been provided the host, port, path and headers Bearer.  While the 
above is not the actual provided info, it is a representation of such.  My 
status just hangs in pending.
Any and all help is greatly appreciated as Im banging my head 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

--- 
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] node.js and node-rest-client TypeError: Cannot read property 'tunnel' of undefined

2014-02-27 Thread Josh Longbrake
 
   
I am getting the error listed in the title when using the code posted 
below. This is based off of: https://www.npmjs.org/package/node-rest-client

fyi: the Bearer, path and client url have been masked as they are client 
sensitive items.

middleware:

angular.module('ruleService', [])

.factory('Rules', function($http) {
return {

provision : function(data) {
console.log('provision: ' + data)
return $http.put('/api/provisions/', data);
}}

service:

module.exports = function (app) {
var Client = require('node-rest-client').Client;
console.log('mdmController:');

app.put('/api/provisions/', function (data) {

console.log(provisions prov: + JSON.stringify(data.body.prov))
console.log(provisions id: + JSON.stringify(data.body.id))

var client = new Client();

var args = {
path: '/api/path/to/url/'+ data.body.id,
port: 443,
headers: {'Authorization': 'Bearer 
0c92f5177d5e818fcc680681f1e9b6895bd5491153'},
data: data.body.prov
};

console.log('args:' + args)

client.put(https://notTheActualSite.com;, args, function (data, 
response) {
console.log('put data:' + data);
console.log('put response:' + response);
});

});}


What is being handled incorrectly? As always any and all assistance is 
greatly appreciated, so 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

--- 
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 and node-rest-client TypeError: Cannot read property 'tunnel' of undefined

2014-02-27 Thread Josh Longbrake
Sure here it is:

TypeError: Cannot read property 'tunnel' of undefined
at new exports.Client 
(/Users/jlongbrake/Desktop/sitename/node_modules/node-rest-client/lib/node-rest-client.js:14:42)
at /Users/jlongbrake/Desktop/sitename/controller/mdmController.js:10:22
at callbacks 
(/Users/jlongbrake/Desktop/sitename/node_modules/express/lib/router/index.js:164:37)
at param 
(/Users/jlongbrake/Desktop/sitename/node_modules/express/lib/router/index.js:138:11)
at pass 
(/Users/jlongbrake/Desktop/sitename/node_modules/express/lib/router/index.js:145:5)
at Router._dispatch 
(/Users/jlongbrake/Desktop/sitename/node_modules/express/lib/router/index.js:173:5)
at Object.router 
(/Users/jlongbrake/Desktop/sitename/node_modules/express/lib/router/index.js:33:10)
at next 
(/Users/jlongbrake/Desktop/sitename/node_modules/express/node_modules/connect/lib/proto.js:193:15)
at Object.allowCrossDomain [as handle] 
(/Users/jlongbrake/Desktop/sitename/server.js:21:9)
at next 
(/Users/jlongbrake/Desktop/sitename/node_modules/express/node_modules/connect/lib/proto.js:193:15)


sitename is not the actual app name (to protect the innocent...)

Thanks for getting eyes on it!  Its baffeling to me that Im having such 
difficulty in making a single PUT request...
my goal here:

https.request({ 
host: 'sitename.com http://appblade.com', 
port: 443, 
data: {'restrictions':data.body.prov},
path: '/api/3/' + data.body.id, 
method: 'PUT', 
headers: {'Authorization': 'Bearer 
0c92f5177d5e818fcc680681f1e9b6895bd5491153'}})



On Thursday, February 27, 2014 11:01:43 AM UTC-6, // ravi wrote:

 On Feb 27, 2014, at 10:43 AM, Josh Longbrake 
 jo...@studiobrainchild.comjavascript: 
 wrote: 
  
  I am getting the error listed in the title when using the code posted 
 below. This is based off of: 
 https://www.npmjs.org/package/node-rest-client 
  

 Can you send us the full stack trace? 

 —ravi 



  fyi: the Bearer, path and client url have been masked as they are client 
 sensitive items. 
  
  middleware: 
  
  angular.module('ruleService', []) 
  
  
  
  .factory('Rules', function($http) { 
  
  
  return { 
  
  
  provision 
  : function(data) { 
  
  console 
  .log('provision: ' + data) 
  
  
  return $http.put('/api/provisions/', data); 
  
  
  } 
  } 
  service: 
  
  module.exports = function (app) { 
  
  
  var Client = require('node-rest-client').Client; 
  
  console 
  .log('mdmController:'); 
  
  
  app 
  .put('/api/provisions/', function (data) { 
  
  
  console 
  .log(provisions prov: + JSON.stringify(data.body.prov)) 
  
  console 
  .log(provisions id: + JSON.stringify(data.body.id)) 
  
  
  
  var client = new Client(); 
  
  
  
  var args = { 
  
  path 
  : '/api/path/to/url/'+ data.body.id, 
  
  port 
  : 443, 
  
  headers 
  : {'Authorization': 'Bearer 
 0c92f5177d5e818fcc680681f1e9b6895bd5491153'}, 
  
  data 
  : data.body. 
  prov 
  
  }; 
  
  
  console 
  .log('args:' + args) 
  
  
  client 
  .put(https://notTheActualSite.com;, args, function (data, response) { 
  
  console 
  .log('put data:' + data); 
  
  console 
  .log('put response:' + response); 
  
  
  }); 
  
  
  
  }); 
  } 
  
  
  What is being handled incorrectly? As always any and all assistance is 
 greatly appreciated, so 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 nod...@googlegroups.comjavascript: 
  To unsubscribe from this group, send email to 
  nodejs+un...@googlegroups.com javascript: 
  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 javascript:. 
  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

Re: [nodejs] node.js and node-rest-client TypeError: Cannot read property 'tunnel' of undefined

2014-02-27 Thread Josh Longbrake
at /Users/jlongbrake/Desktop/sitename/controller/mdmController.js:10:22 
would be this line from the code above:   var client = new Client();

On Thursday, February 27, 2014 12:19:46 PM UTC-6, Josh Longbrake wrote:

 Sure here it is:

 TypeError: Cannot read property 'tunnel' of undefined
 at new exports.Client 
 (/Users/jlongbrake/Desktop/sitename/node_modules/node-rest-client/lib/node-rest-client.js:14:42)
 at /Users/jlongbrake/Desktop/sitename/controller/mdmController.js:10:22
 at callbacks 
 (/Users/jlongbrake/Desktop/sitename/node_modules/express/lib/router/index.js:164:37)
 at param 
 (/Users/jlongbrake/Desktop/sitename/node_modules/express/lib/router/index.js:138:11)
 at pass 
 (/Users/jlongbrake/Desktop/sitename/node_modules/express/lib/router/index.js:145:5)
 at Router._dispatch 
 (/Users/jlongbrake/Desktop/sitename/node_modules/express/lib/router/index.js:173:5)
 at Object.router 
 (/Users/jlongbrake/Desktop/sitename/node_modules/express/lib/router/index.js:33:10)
 at next 
 (/Users/jlongbrake/Desktop/sitename/node_modules/express/node_modules/connect/lib/proto.js:193:15)
 at Object.allowCrossDomain [as handle] 
 (/Users/jlongbrake/Desktop/sitename/server.js:21:9)
 at next 
 (/Users/jlongbrake/Desktop/sitename/node_modules/express/node_modules/connect/lib/proto.js:193:15)


 sitename is not the actual app name (to protect the innocent...)

 Thanks for getting eyes on it!  Its baffeling to me that Im having such 
 difficulty in making a single PUT request...
 my goal here:

 https.request({ 
 host: 'sitename.com http://appblade.com', 
 port: 443, 
 data: {'restrictions':data.body.prov},
 path: '/api/3/' + data.body.id, 
 method: 'PUT', 
 headers: {'Authorization': 'Bearer 
 0c92f5177d5e818fcc680681f1e9b6895bd5491153'}})



 On Thursday, February 27, 2014 11:01:43 AM UTC-6, // ravi wrote:

 On Feb 27, 2014, at 10:43 AM, Josh Longbrake jo...@studiobrainchild.com 
 wrote: 
  
  I am getting the error listed in the title when using the code posted 
 below. This is based off of: 
 https://www.npmjs.org/package/node-rest-client 
  

 Can you send us the full stack trace? 

 —ravi 



  fyi: the Bearer, path and client url have been masked as they are 
 client sensitive items. 
  
  middleware: 
  
  angular.module('ruleService', []) 
  
  
  
  .factory('Rules', function($http) { 
  
  
  return { 
  
  
  provision 
  : function(data) { 
  
  console 
  .log('provision: ' + data) 
  
  
  return $http.put('/api/provisions/', data); 
  
  
  } 
  } 
  service: 
  
  module.exports = function (app) { 
  
  
  var Client = require('node-rest-client').Client; 
  
  console 
  .log('mdmController:'); 
  
  
  app 
  .put('/api/provisions/', function (data) { 
  
  
  console 
  .log(provisions prov: + JSON.stringify(data.body.prov)) 
  
  console 
  .log(provisions id: + JSON.stringify(data.body.id)) 
  
  
  
  var client = new Client(); 
  
  
  
  var args = { 
  
  path 
  : '/api/path/to/url/'+ data.body.id, 
  
  port 
  : 443, 
  
  headers 
  : {'Authorization': 'Bearer 
 0c92f5177d5e818fcc680681f1e9b6895bd5491153'}, 
  
  data 
  : data.body. 
  prov 
  
  }; 
  
  
  console 
  .log('args:' + args) 
  
  
  client 
  .put(https://notTheActualSite.com;, args, function (data, response) { 
  
  console 
  .log('put data:' + data); 
  
  console 
  .log('put response:' + response); 
  
  
  }); 
  
  
  
  }); 
  } 
  
  
  What is being handled incorrectly? As always any and all assistance is 
 greatly appreciated, so 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 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

Re: [nodejs] node.js and node-rest-client TypeError: Cannot read property 'tunnel' of undefined

2014-02-27 Thread Josh Longbrake
Hmm.  Its the installed package from homebrew but it may be an older
version of homebrew / NPM.  Good catch, ill update and try again.  From
your view does anything else look inherently wrong?

Thanks for the fresh eyes!
On Feb 27, 2014 3:34 PM, // ravi ravi-li...@g8o.net wrote:

 On Feb 27, 2014, at 1:19 PM, Josh Longbrake j...@studiobrainchild.com
 wrote:

 Sure here it is:

 TypeError: Cannot read property 'tunnel' of undefined
 at new exports.Client
 (/Users/jlongbrake/Desktop/sitename/node_modules/node-rest-client/lib/node-rest-client.js:14:42)
 at /Users/jlongbrake/Desktop/sitename/controller/mdmController.js:10:22
 at callbacks
 (/Users/jlongbrake/Desktop/sitename/node_modules/express/lib/router/index.js:164:37)
 at param
 (/Users/jlongbrake/Desktop/sitename/node_modules/express/lib/router/index.js:138:11)
 at pass
 (/Users/jlongbrake/Desktop/sitename/node_modules/express/lib/router/index.js:145:5)
 at Router._dispatch
 (/Users/jlongbrake/Desktop/sitename/node_modules/express/lib/router/index.js:173:5)
 at Object.router
 (/Users/jlongbrake/Desktop/sitename/node_modules/express/lib/router/index.js:33:10)
 at next
 (/Users/jlongbrake/Desktop/sitename/node_modules/express/node_modules/connect/lib/proto.js:193:15)
 at Object.allowCrossDomain [as handle]
 (/Users/jlongbrake/Desktop/sitename/server.js:21:9)
 at next
 (/Users/jlongbrake/Desktop/sitename/node_modules/express/node_modules/connect/lib/proto.js:193:15)


 The trouble is with the module. I notice the offending line of code is
 different in the NPM installed module in comparison to the correct/bug-free
 version on GitHub.

 The buggy line in the NPM installed node module:

 self.useProxyTunnel =
 self.options.proxy.tunnel===undefined?true:self.options.proxy.tunnel,

 The line on GitHub (
 https://github.com/aacerox/node-rest-client/blob/master/lib/node-rest-client.js
 ):


   self.useProxyTunnel = (!self.useProxy || 
 self.options.proxy.tunnel===undefined)?false:self.options.proxy.tunnel,

 --ravi


  --
 --
 Job Board: http://jobs.nodejs.org/
 Posting guidelines:
 https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
 You received this message because you are subscribed to the Google
 Groups nodejs group.
 To post to this group, send email to nodejs@googlegroups.com
 To unsubscribe from this group, 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 a topic in the
 Google Groups nodejs group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/nodejs/g4ch8Z9c4cg/unsubscribe.
 To unsubscribe from this group and all its topics, 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: Australian Node.js developers wanted (up to $110k) - Western Sydney

2014-01-24 Thread Josh Ellis
Hi mate,

Primarily a node posititon. Considering most node devs have come from
another scripting language previously, I know there's a fair chunk that
were previously PHP devs. Hopefully that answers your question regarding
the same.

Foreigners living in Sydney are welcome to apply. Their visa status is the
main concerning factor, though. The company is not willing to consider
sponsorship at this stage.

Thanks for your email.

Josh
On 24/01/2014 7:45 PM, alessioalex alessio.ijoo...@gmail.com wrote:

 Do you also accept rockstars and samurais?

 Also from what I understand this position is not addressed to foreigners
 living in Sydney, just Australian folks.

 P.S. In all seriousness, if you need a PHP dev why post here?

 On Friday, January 24, 2014 4:12:14 AM UTC+2, jos...@codemonkeys.com.auwrote:

 You only want to work with the best, and here's an opportunity hot off
 the presses.

 The team consists of mostly young, energetic developers in a fun, funky
 environment. The office is modern and fresh. You don't need to wear a suit
 and tie, just semi-casual.*We know you've got to be comfortable to get
 your work done!*

 These guys are based out of Seven Hills, and they're offering Sydney
 rates! We're excited to have them on board and they're doing some wonderful
 things on the Net with the newest technologies; using Node.js, PHP, HTML5,
 CSS3 and Linux-based servers. They're also moving into mobile app
 development and are happy to give you the opportunity to grow your skills
 in that area. (self high five!)

 *The requirements*

 We really want people who: -

- Are a bit of a Node.js ninja (experience with front-end JS
frameworks is also a huge plus; think Backbone or Angular)
- Have worked extensively with PHP (ninja-spec)
- Have worked with API's
- Love getting applications released into the wild as soon as possible
- Are a HUGE fan of lean development and agile methodologies
- Understand and have used object-oriented development
- Can aim for best practice, but know this isn't always best for
project timelines
- Know Wordpress (don't need to be a ninja, though)
- Love a good, shiny, usable HTML/CSS interface (and know how to make
it so)
- Have experience in responsive web interfaces

 *Team Lead ($110k)*

 We want a Team Lead with a positive personality and some pretty awesome
 technical skills to boot. The job will involve leading a team of 3-4
 developers on a range of projects for commercial clients (and some
 not-for-profits).

 This position means you'll be able to take ownership of projects, looking
 back on their completion with a sense of pride. You're going to be
 communicating with designers, executives and juniors (with the occasional
 customer thrown in), so you need to be able to string a sentence together.
 Communication is key!

 *The Devs (x2 - $90k)*

 You'll be packing a whole bag of awesome. Using your 1337 skills in
 Node.js development, you get to build out the applications and systems
 you've designed as part of the team. Your prowess for testing and ensuring
 quality code is churned out will be highly valued, and you get to have fun
 while you work.

 Everybody gets a shiny new Mac to work on... unless you want a Windows
 machine, which is also okay (no judgement here folks).

 Get in contact via this thread or via our Facebook page at
 http://www.facebook.com/aucodemonkeys

 Many thanks,

 Joshua Ellis

  --
 --
 Job Board: http://jobs.nodejs.org/
 Posting guidelines:
 https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
 You received this message because you are subscribed to the Google
 Groups nodejs group.
 To post to this group, send email to nodejs@googlegroups.com
 To unsubscribe from this group, 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 a topic in the
 Google Groups nodejs group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/nodejs/UO1RrHDSAT4/unsubscribe.
 To unsubscribe from this group and all its topics, 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

Re: [nodejs] Australian Node.js developers wanted (up to $110k) - Western Sydney

2014-01-24 Thread josh . e
Genius.  Good for you.  Tell me ALL about how your ACTUAL 1337 skillz are 
earning you millions in some other language like Java, Ruby, C++, Python... 
:-P

On Friday, January 24, 2014 9:21:45 PM UTC+11, Alex Kocharin wrote:

  
 Yeah, PHP/Wordpress and 1337 skills aren't really fit in one message. 
 :P
  
  
 24.01.2014, 13:47, Arnout Kazemier in...@3rd-eden.com javascript::

 FYI: Nobody will take you serious when you put 1337 in job description. 
 According to news reported by various of news outlets, the ninja’s are 
 becoming extinct. I suggest you start looking for developers or engineers 
 instead of reach a greater group of potential candidates. 
  
 KTNXILUBAI.

 On Friday 24 January 2014 at 03:12, 
 jos...@codemonkeys.com.aujavascript:wrote:

 You only want to work with the best, and here's an opportunity hot off the 
 presses.

 The team consists of mostly young, energetic developers in a fun, funky 
 environment. The office is modern and fresh. You don't need to wear a suit 
 and tie, just semi-casual.*We know you've got to be comfortable to get 
 your work done!*

 These guys are based out of Seven Hills, and they're offering Sydney 
 rates! We're excited to have them on board and they're doing some wonderful 
 things on the Net with the newest technologies; using Node.js, PHP, HTML5, 
 CSS3 and Linux-based servers. They're also moving into mobile app 
 development and are happy to give you the opportunity to grow your skills 
 in that area. (self high five!)

 *The requirements*

 We really want people who: -

- Are a bit of a Node.js ninja (experience with front-end JS 
frameworks is also a huge plus; think Backbone or Angular)
- Have worked extensively with PHP (ninja-spec)
- Have worked with API's
- Love getting applications released into the wild as soon as possible
- Are a HUGE fan of lean development and agile methodologies
- Understand and have used object-oriented development
- Can aim for best practice, but know this isn't always best for 
project timelines
- Know Wordpress (don't need to be a ninja, though)
- Love a good, shiny, usable HTML/CSS interface (and know how to make 
it so)
- Have experience in responsive web interfaces

 *Team Lead ($110k)*

 We want a Team Lead with a positive personality and some pretty awesome 
 technical skills to boot. The job will involve leading a team of 3-4 
 developers on a range of projects for commercial clients (and some 
 not-for-profits).

 This position means you'll be able to take ownership of projects, looking 
 back on their completion with a sense of pride. You're going to be 
 communicating with designers, executives and juniors (with the occasional 
 customer thrown in), so you need to be able to string a sentence together. 
 Communication is key!

 *The Devs (x2 - $90k)*

 You'll be packing a whole bag of awesome. Using your 1337 skills in 
 Node.js development, you get to build out the applications and systems 
 you've designed as part of the team. Your prowess for testing and ensuring 
 quality code is churned out will be highly valued, and you get to have fun 
 while you work.

 Everybody gets a shiny new Mac to work on... unless you want a Windows 
 machine, which is also okay (no judgement here folks).

 Get in contact via this thread or via our Facebook page at 
 http://www.facebook.com/aucodemonkeys

 Many thanks,

 Joshua Ellis

  
 -- 
 -- 
 Job Board: http://jobs.nodejs.org/
 Posting guidelines: 
 https://github.com/joyent/node/wiki/Mailing-List-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 javascript:
 To unsubscribe from this group, send email to
 nodejs+un...@googlegroups.com javascript:
 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 javascript:.
 For more options, visit https://groups.google.com/groups/opt_out.

  

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



-- 
-- 

Re: [nodejs] Australian Node.js developers wanted (up to $110k) - Western Sydney

2014-01-24 Thread josh . e
FYI:  That's fantastic feedback.  I'm more than happy to take that info on 
board.  Just send me a couple of those news reports on the ninjas becoming 
extinct (should be easy; there are various, right?).

For future reference I'll make sure I submit an advertisement that says.

Looking for a software analyst/engineer with 5 years minimum experience 
and blah, blah, blah...

Must have 4 years commercial experience
Good communication skills
3 solid references from on-the-job managers
... 

Blah, blah, blah.

Must have Masters Degree in IT (because we all know everybody with a 
Masters is an expert programmer... right?)

I've put 1337 in my job description, and I will continue to... because it 
captures something about development that people have long forgotten... 
FUN!!!  Excitement!!!  Doing something that the average guy cannot... 
starting with an empty text document and creating a masterpiece of coding 
wizardry.  Encompassing the irony and satire that is embodied by the 
creative logic we developers employ in our lives on a daily basis.

We're able to break down a real-world problem into simple machine code... 
that in itself is something to behold.  Turning the illogical into logic at 
the behest or irrational managers and executives; under tight deadlines and 
unreasonable expectations... we make the impossible possible.

So, while I take your feedback on board and will probably mentally 
reference it next time I'm writing a job advertisement, I refuse to accept 
your blanket statement as being indicative of the majority of developers 
around the world.  If you've lost your sense of humour, that's okay; plenty 
of others still have one.

May you have a wondrous and fantastic day.  I hope the next job description 
is more fitting to your critical positioning.

Many thanks,

Josh

On Friday, January 24, 2014 8:47:49 PM UTC+11, 3rdEden wrote:

 FYI: Nobody will take you serious when you put 1337 in job description. 
 According to news reported by various of news outlets, the ninja’s are 
 becoming extinct. I suggest you start looking for developers or engineers 
 instead of reach a greater group of potential candidates. 

 KTNXILUBAI.

 On Friday 24 January 2014 at 03:12, 
 jos...@codemonkeys.com.aujavascript:wrote:

 You only want to work with the best, and here's an opportunity hot off the 
 presses.

 The team consists of mostly young, energetic developers in a fun, funky 
 environment. The office is modern and fresh. You don't need to wear a suit 
 and tie, just semi-casual.*We know you've got to be comfortable to get 
 your work done!*

 These guys are based out of Seven Hills, and they're offering Sydney 
 rates! We're excited to have them on board and they're doing some wonderful 
 things on the Net with the newest technologies; using Node.js, PHP, HTML5, 
 CSS3 and Linux-based servers. They're also moving into mobile app 
 development and are happy to give you the opportunity to grow your skills 
 in that area. (self high five!)

 *The requirements*

 We really want people who: -

- Are a bit of a Node.js ninja (experience with front-end JS 
frameworks is also a huge plus; think Backbone or Angular)
- Have worked extensively with PHP (ninja-spec)
- Have worked with API's
- Love getting applications released into the wild as soon as possible
- Are a HUGE fan of lean development and agile methodologies
- Understand and have used object-oriented development
- Can aim for best practice, but know this isn't always best for 
project timelines
- Know Wordpress (don't need to be a ninja, though)
- Love a good, shiny, usable HTML/CSS interface (and know how to make 
it so)
- Have experience in responsive web interfaces

 *Team Lead ($110k)*

 We want a Team Lead with a positive personality and some pretty awesome 
 technical skills to boot. The job will involve leading a team of 3-4 
 developers on a range of projects for commercial clients (and some 
 not-for-profits).

 This position means you'll be able to take ownership of projects, looking 
 back on their completion with a sense of pride. You're going to be 
 communicating with designers, executives and juniors (with the occasional 
 customer thrown in), so you need to be able to string a sentence together. 
 Communication is key!

 *The Devs (x2 - $90k)*

 You'll be packing a whole bag of awesome. Using your 1337 skills in 
 Node.js development, you get to build out the applications and systems 
 you've designed as part of the team. Your prowess for testing and ensuring 
 quality code is churned out will be highly valued, and you get to have fun 
 while you work.

 Everybody gets a shiny new Mac to work on... unless you want a Windows 
 machine, which is also okay (no judgement here folks).

 Get in contact via this thread or via our Facebook page at 
 http://www.facebook.com/aucodemonkeys

 Many thanks,

 Joshua Ellis

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

[nodejs] Australian Node.js developers wanted (up to $110k) - Western Sydney

2014-01-23 Thread josh . e


You only want to work with the best, and here's an opportunity hot off the 
presses.

The team consists of mostly young, energetic developers in a fun, funky 
environment. The office is modern and fresh. You don't need to wear a suit 
and tie, just semi-casual.*We know you've got to be comfortable to get your 
work done!*

These guys are based out of Seven Hills, and they're offering Sydney rates! 
We're excited to have them on board and they're doing some wonderful things 
on the Net with the newest technologies; using Node.js, PHP, HTML5, CSS3 
and Linux-based servers. They're also moving into mobile app development 
and are happy to give you the opportunity to grow your skills in that area. 
(self high five!)

*The requirements*

We really want people who: -

   - Are a bit of a Node.js ninja (experience with front-end JS frameworks 
   is also a huge plus; think Backbone or Angular)
   - Have worked extensively with PHP (ninja-spec)
   - Have worked with API's
   - Love getting applications released into the wild as soon as possible
   - Are a HUGE fan of lean development and agile methodologies
   - Understand and have used object-oriented development
   - Can aim for best practice, but know this isn't always best for project 
   timelines
   - Know Wordpress (don't need to be a ninja, though)
   - Love a good, shiny, usable HTML/CSS interface (and know how to make it 
   so)
   - Have experience in responsive web interfaces

*Team Lead ($110k)*

We want a Team Lead with a positive personality and some pretty awesome 
technical skills to boot. The job will involve leading a team of 3-4 
developers on a range of projects for commercial clients (and some 
not-for-profits).

This position means you'll be able to take ownership of projects, looking 
back on their completion with a sense of pride. You're going to be 
communicating with designers, executives and juniors (with the occasional 
customer thrown in), so you need to be able to string a sentence together. 
Communication is key!

*The Devs (x2 - $90k)*

You'll be packing a whole bag of awesome. Using your 1337 skills in Node.js 
development, you get to build out the applications and systems you've 
designed as part of the team. Your prowess for testing and ensuring quality 
code is churned out will be highly valued, and you get to have fun while 
you work.

Everybody gets a shiny new Mac to work on... unless you want a Windows 
machine, which is also okay (no judgement here folks).

Get in contact via this thread or via our Facebook page at 
http://www.facebook.com/aucodemonkeys

Many thanks,

Joshua Ellis

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

2013-10-04 Thread Josh Chittick
Hi everyone,

Had a go at making a short 30 minute course showing how to create a basic 
web application with Express and deploy to Heroku.
Would be great to get some critical feedback as it is the first recording I 
have done!

Best for beginner - intermediate node developers, with some Javascript 
knowledge.

https://www.udemy.com/nodejs-in-30/

Thanks,
Josh


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

2013-08-17 Thread Josh Ragem
I've had logging woes recently trying debug code with the help of different 
logging frameworks.

I have several projects for which I am responsible, and these projects have 
to be tested in a production-like environment (solaris on a remote server) 
instead of my development environment (macbook pro on my lap). I could 
probably do some fancy vm stuff and a little more dependency injection in 
my tests... but sometimes it's really more worth it to put the thing up, 
let it break, and read the logs to find out why.

PROBLEM:
log levels.

When I am looking for a mysterious bug, I don't always know where the 
problem is so I don't always know which log lines I want to see in the 
logs. Maybe the one line that will illuminate the issue is at level 'trace' 
and I won't ever see it because it is buried under a billion other log 
lines (like, maybe we are siege testing).

SOLUTION:
Tagged logs!

log = new Tagalog({
acorn:fs.createWriteStream('../myAcorns.log')
})
...
log.debug('did you steal my #acorn? ' + stolen? 'yes' : 'no')

[myAcorns.log]-
did you steal my #acorn? yes 

AhHA!

I wrote and published an alpha version of 'tagalog' on npm to test it out. 
It's pretty silly right now (no formatted strings, no way to print objects, 
etc.), but even at this stage I could use it to tag my logs and isolate the 
subjects I am interested in, instead of trusting yesterday me to know that 
tomorrow me wants a particular log line at level 'EMERGENCY! OH NOES!'.

To recap:
1. tagged logs
2. debug quickly
3. 
4. profit!

Please check it out at https://github.com/JoshRagem/tagalog and see how 
this idea works for you.

Josh

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

2013-08-17 Thread Josh Ragem
I am familiar with bunyan and how you can add arbitrary fields to the JSON 
output. The client lets you filter based on those fields, but it still has 
the weakness of hiding log lines under log levels and giving you more than 
you want.

Tagged logs allow you to ignore subjects you are not interested in. You can 
very simply turn off the noise when you are debugging and get to the 
problem more quickly. You could filter tags on the way out of the program, 
or you could filter tags when reading in a file (tagalog does not do this 
right now, but it might). Tagging is the way you have the content describe 
itself, instead of setting an arbitrary number to say how 'important' it is.

Imagine that you are debugging a program and you don't have the luxury of 
using breakpoints; With log levels you need to set the verbosity at maximum 
because you need to see all your lines to hunt down the bug. Unfortunately 
you now are inundated with every single log line that you ever wrote (even 
the dumb ones, like 'I am here!'). There are lots of ways you could handle 
this issue, but why are you wasting time printing stuff you don't want to 
look at? With tagalog you can put as many hashtags as you want in your log 
string and tagalog will send that string out to every stream that is 
matched to a hashtag. You would write multiple log files, each one dealing 
with a different subject and debug them one by one.

The total development time that I have put into tagalog is under a half 
hour, so I wouldn't advise you to use it as much of anything right now. I 
used a proprietary tagged log system at a past job and my experience with 
tags has been so much better than with log levels. 

(I am aware that tagalog is a language, I've met many nice people who can 
speak it :) )

Josh

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

2013-03-20 Thread josh
works!

is it identical to this one? if not, what is the difference?

request(reqObj, function (err, response, body){
  feedparser.parseString(body)
.on('article', callback);});


On Tuesday, March 19, 2013 1:11:40 PM UTC-7, Dan MacTough wrote:

 Josh, sorry about the outdated documentation. The pipe method doesn't work 
 anymore. I've updated the README.

 I still encourage you to try using streams (although I haven't had a 
 chance to update to streams2 yet).

 The correct method would be:

 feedparser.parseStream(request({ 'uri': 'http://substack.net/blog.xml' }))
   .on('article', function (article) {
 //do something
   });

 -Dan

 On Tuesday, March 19, 2013 12:51:58 AM UTC-4, josh wrote:

 this is almost  a copy paste from feedparser readme.
 I know I miss something but not sure what it is.

 var request = require('request');
 var feedparser = require('feedparser');

 request({ 'uri': 'http://substack.net/blog.xml' 
 }).pipe(feedparser.stream);

 stream.js:52
   dest.on('drain', ondrain);
^
 TypeError: Cannot call method 'on' of undefined
 at Request.Stream.pipe (stream.js:52:8)



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

2013-03-18 Thread josh
this is almost  a copy paste from feedparser readme.
I know I miss something but not sure what it is.

var request = require('request');
var feedparser = require('feedparser');

request({ 'uri': 'http://substack.net/blog.xml' }).pipe(feedparser.stream);

stream.js:52
  dest.on('drain', ondrain);
   ^
TypeError: Cannot call method 'on' of undefined
at Request.Stream.pipe (stream.js:52:8)

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

2013-02-28 Thread Josh Kurz
@Nicotene any progress on releasing some of the npm modules? Or do you have 
any suggestions as to ecommerce modules that have been effective in your 
development process? 

On Thursday, May 10, 2012 2:55:51 PM UTC-4, guzelgoz wrote:

 Hi all,

 I've been searching and searching but couldn't find any project/open 
 source node e-commerce platform. As I am running some e-commerce websites 
 using the PhP prestashop solution, I was really hoping to find some sort of 
 e-commerce project but Nada!

 Ideally, I would like to use Expressjs and MongoDB. Do you know any 
 e-commerce project that I could participate?

 If not, I would like to invite anybody to start a project. I think it 
 would have great interest and at least I would participate to it - as a 
 novice node programmer ;) but a serious user that may help on what is 
 needed.

 Looking forward to your feedbacks!
 Thanks,
 Hakan


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

2013-01-27 Thread josh
I need to emit LWES event, and reading about an event structure here 
http://www.lwes.org/docs/doxygen/html/structlwes__event.html  it looks like 
i need 1 byte string, 2 bytes number a struct and a hash of attributes. 
I know about dgram but not sure how to send the correct info in the socket. 
any tips?

// i don't know what should be the structure so i wrote it as json.
var data = {
  name: my-event,
  url: my-app.foo.com/register,
  responseTime: 25 ms,
  description: registration endpoint,
  statusCode: 201
};

var dgram = require('dgram');
// var data = convertToBinary(data);   // I need to find a way to convert 
the json to binary 

  

var message = new Buffer(data);
var client = dgram.createSocket(udp4);

client.send(message, 0, message.length, 12345, 127.0.0.1, function(err, 
bytes) {
client.close();
});


btw, This is an example with Ruby that works:
# test.rb
require 'json'
require 'lwes'  # http://lwes.rubyforge.org/LWES/Emitter.html

emitter = LWES::Emitter.new(:address = '127.0.0.1', :port = 12345)
emitter.emit 'my-event', JSON(ARGF.read)

This is how I test it:
1) I listen to events with this command:  lwes-event-printing-listener -m 
127.0.0.1
2) I run my test.rb with: echo '{key: value}' | ruby test.rb
3) I see this in the console of the listener:
my-event[4]
{
SenderPort = 63162;
key = value;
ReceiptTime = 1359274824724;
SenderIP = 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





[nodejs] Re: Running tests directly and as part of a suite

2013-01-27 Thread josh
Daniel, your suggestion will make my test files shorter and DRY, but on the 
other hand running my tests might be less intuitive than before -
node unit/test/test_404.js vs node unit/test/runner.js 
unit/test/test_404.js.
I want to make it easy as possible to run the tests, so at the moment I 
prefer to have some verbosity in the test file itelf.

Benjamin, Joe looks interesting but I am not sure if I want to introduce 
another dependency to my project, unless it really add a lot of value.
in addition it's written in coffeescript, which will introduce some 
difficulties for me and future developers on this code base.
I guess to solve this issue I can create a copy of joe in javascript, but 
not sure if it adds a ton of value that justify it. we'll see about that.
at this point I prefer to stick to one language. of course this is very 
subjective topic and I might change my mind in the future.

Thanks for those suggestions guys. I really appreciate it! 

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





[nodejs] Running tests directly and as part of a suite

2013-01-26 Thread josh
I want to run my test file alone - node test/unit/test_404.js
but also with the test suite - node test/unit/runner.js

to achieve that I added an if/else statement in each test file to check if 
the code is running directly with the node executable or if it's required 
by other file.
if it was run directly, I run my server before running the test. 
if the file was required by the test suite runner, I just export the test 
so the runner will call it (module.exports = test).

Here are 2 version of one of the test files - 
http://hastebin.com/fovofufome.js  
They are doing the same thing, except that in version 2 I moved the 
runServerBeforeTest function to it's own helper file. 
I found the first version more readable but it's more verbose and I need to 
repeate that in each test file.
Any opinions or even different approaches for testing?

btw, I deliberately uses node's built-in asserts and not using any test 
framework. I would like to feel pain before adding libraries and so far I 
am happy with this 'leas' approach.

Pasting my code here as well:
   
// test_404.js version 1
// core modulesvar assert = require('assert');
// npm packagevar request = require('request');

// GET /not-exist should return 404 - not foundfunction test(config) {
  console.log('GET /not-exist');

  request({
  uri: http://localhost:; + config.webSitePort + /not-exist,
  followRedirect: false 
}, 
function (err, res, body) {
  if (err) {
console.log('Error in ' + __filename + '. ' + err);
  } else {
assert.equal(res.statusCode, 404)
// process.exit();
  };
});
};
// The following code let us run this test file by itself or as part of the 
runner.js// if this file is by itself with 'node test_foo.js' we need to run 
the server before calling the test// else - expose the test function since the 
runner.js already run the serverif (module === require.main) {
  runServerBeforeTest();
} else {
  module.exports = test;
};
function runServerBeforeTest() {
  // my modules
  var config = require('../../config/test.js');
  var app = require('../../app.js');

  app.init(config, function (err, msg) {
if (err) {
  console.log('Error during application init: ' + err);
} else {
  console.log(msg);
  app.start(test(config));
}
  });
};

// test_404.js version 2

// core modulesvar assert = require('assert');
// npm packagevar request = require('request');

// GET /not-exist should return 404 - not foundfunction test(config) {
  console.log('GET /not-exist');

  request({
  uri: http://localhost:; + config.webSitePort + /not-exist,
  followRedirect: false 
}, 
function (err, res, body) {
  if (err) {
console.log('Error in ' + __filename + '. ' + err);
  } else {
assert.equal(res.statusCode, 404)
// process.exit();
  };
});
};
// The following code let us run this test file by itself or as part of the 
runner.js// if this file is by itself with 'node test_foo.js' we need to run 
the server before calling the test// else - expose the test function since the 
runner.js already run the serverif (module === require.main) {
  runServerBeforeTest();
  require(__dirname + '/helper.js').runServerBeforeTest(test);
} else {
  module.exports = test;
};



// helper.js - after my server is listening, run a given test

module.exports.runServerBeforeTest = runServerBeforeTest;
function runServerBeforeTest(test) {
  // my modules
  var config = require('../../config/test.js');
  var app = require('../../app.js');

  app.init(config, function (err, msg) {
if (err) {
  console.log('Error during application init: ' + err);
} else {
  console.log(msg);
  app.start(test(config));
}
  });
};

// runner.js - after my server is listening - run all test*.js files 
// my modulesvar config = require('../../config/test.js');var app = 
require('../../app.js');var helper = require(__dirname + '/helper.js');
function runTests() {
  console.log('running tests:');

  testFiles = [];
  var test = null;
  testFiles = require(fs).readdirSync(__dirname).filter(function(file) {
return (/^test/.test(file)) 
  });
  
  testFiles.forEach(function(file) {
test = require(./ + file);
if (typeof(test) === 'function') {
  test(config);
}
  });
};

app.init(config, function (err, msg) {
  if (err) {
console.log('Error during application init: ' + err);
  } else {
console.log(msg);
app.start(runTests(config));
  }
});


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

2013-01-07 Thread Josh Santangelo
Thanks for the replies, all. I'm messing around with it more and not having 
any luck with connect or connection events. At this point I can only 
assume that node/socket is doing the right thing and it's my client code 
not connecting correctly.

I'm having trouble finding any examples of a C# app connecting to node, but 
surely someone's done it? The code I'm using is very similar to the sample 
code at the bottom of this MSDN 
page: 
http://msdn.microsoft.com/en-us/library/system.net.sockets.socket(v=vs.95).aspx

On Friday, January 4, 2013 7:27:35 PM UTC-8, Ben Evans wrote:

 Hi Josh,

 If it's any use to you, when i first gave Node a shot I wrote a very basic 
 chat app. Feel free to use it/reference: 
 https://github.com/bencevans/Little-Chat-Script

 Features:

 * Socket.IO Realtime Messaging
 * Connection Indicator

 and that's about it but I hope it's of some help.

 Good Luck and Happy Hacking!

 On Friday, 4 January 2013 23:38:17 UTC, Josh Santangelo wrote:

 I'm trying to build a simple server where multiple clients connect over 
 TCP, and any message from a client is relayed to all the others. This isn't 
 going to be used for a chat room, but it's basically the same idea.

 I tried building this with socket.io but got stuck pretty quickly:

 var io = require('socket.io').listen(81);

 console.log('foo');
 io.sockets.on('connect', function (socket) {
   console.log('connected...');

   socket.on('disconnect', function () {
 console.log('disconnected');
   });
 });

 I see foo trace out, and on the client side it looks like I'm 
 connected, but connected and disconnected never trace out, so I'm 
 guessing those event handlers aren't working for some reason.

 I'm not married to socket.io, and actually using fewer modules would be 
 better, but I'm surprised I couldn't find a code sample for this use case 
 since it sounds like it's a pretty common node.js usage.

 Obviously this is my first time using node.js! Any pointers would be very 
 helpful.

 thanks,
 -josh



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

2013-01-07 Thread Josh Santangelo
I tried the very basic sample code from the socket.io home page in a 
browser and that seemed to work correctly, further confirming 
my suspicion that it's on the client side.

On Monday, January 7, 2013 1:20:25 PM UTC-8, Josh Santangelo wrote:

 Thanks for the replies, all. I'm messing around with it more and not 
 having any luck with connect or connection events. At this point I can 
 only assume that node/socket is doing the right thing and it's my client 
 code not connecting correctly.

 I'm having trouble finding any examples of a C# app connecting to node, 
 but surely someone's done it? The code I'm using is very similar to the 
 sample code at the bottom of this MSDN page: 
 http://msdn.microsoft.com/en-us/library/system.net.sockets.socket(v=vs.95).aspx

 On Friday, January 4, 2013 7:27:35 PM UTC-8, Ben Evans wrote:

 Hi Josh,

 If it's any use to you, when i first gave Node a shot I wrote a very 
 basic chat app. Feel free to use it/reference: 
 https://github.com/bencevans/Little-Chat-Script

 Features:

 * Socket.IO Realtime Messaging
 * Connection Indicator

 and that's about it but I hope it's of some help.

 Good Luck and Happy Hacking!

 On Friday, 4 January 2013 23:38:17 UTC, Josh Santangelo wrote:

 I'm trying to build a simple server where multiple clients connect over 
 TCP, and any message from a client is relayed to all the others. This isn't 
 going to be used for a chat room, but it's basically the same idea.

 I tried building this with socket.io but got stuck pretty quickly:

 var io = require('socket.io').listen(81);

 console.log('foo');
 io.sockets.on('connect', function (socket) {
   console.log('connected...');

   socket.on('disconnect', function () {
 console.log('disconnected');
   });
 });

 I see foo trace out, and on the client side it looks like I'm 
 connected, but connected and disconnected never trace out, so I'm 
 guessing those event handlers aren't working for some reason.

 I'm not married to socket.io, and actually using fewer modules would be 
 better, but I'm surprised I couldn't find a code sample for this use case 
 since it sounds like it's a pretty common node.js usage.

 Obviously this is my first time using node.js! Any pointers would be 
 very helpful.

 thanks,
 -josh



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

2013-01-07 Thread Josh Santangelo
In case anyone else comes across this thread, the answer was to not use a 
raw socket, but rather to use a full client. There is a .NET client 
here: http://socketio4net.codeplex.com/

On Monday, January 7, 2013 2:32:13 PM UTC-8, Josh Santangelo wrote:

 I tried the very basic sample code from the socket.io home page in a 
 browser and that seemed to work correctly, further confirming 
 my suspicion that it's on the client side.

 On Monday, January 7, 2013 1:20:25 PM UTC-8, Josh Santangelo wrote:

 Thanks for the replies, all. I'm messing around with it more and not 
 having any luck with connect or connection events. At this point I can 
 only assume that node/socket is doing the right thing and it's my client 
 code not connecting correctly.

 I'm having trouble finding any examples of a C# app connecting to node, 
 but surely someone's done it? The code I'm using is very similar to the 
 sample code at the bottom of this MSDN page: 
 http://msdn.microsoft.com/en-us/library/system.net.sockets.socket(v=vs.95).aspx

 On Friday, January 4, 2013 7:27:35 PM UTC-8, Ben Evans wrote:

 Hi Josh,

 If it's any use to you, when i first gave Node a shot I wrote a very 
 basic chat app. Feel free to use it/reference: 
 https://github.com/bencevans/Little-Chat-Script

 Features:

 * Socket.IO Realtime Messaging
 * Connection Indicator

 and that's about it but I hope it's of some help.

 Good Luck and Happy Hacking!

 On Friday, 4 January 2013 23:38:17 UTC, Josh Santangelo wrote:

 I'm trying to build a simple server where multiple clients connect over 
 TCP, and any message from a client is relayed to all the others. This 
 isn't 
 going to be used for a chat room, but it's basically the same idea.

 I tried building this with socket.io but got stuck pretty quickly:

 var io = require('socket.io').listen(81);

 console.log('foo');
 io.sockets.on('connect', function (socket) {
   console.log('connected...');

   socket.on('disconnect', function () {
 console.log('disconnected');
   });
 });

 I see foo trace out, and on the client side it looks like I'm 
 connected, but connected and disconnected never trace out, so I'm 
 guessing those event handlers aren't working for some reason.

 I'm not married to socket.io, and actually using fewer modules would 
 be better, but I'm surprised I couldn't find a code sample for this use 
 case since it sounds like it's a pretty common node.js usage.

 Obviously this is my first time using node.js! Any pointers would be 
 very helpful.

 thanks,
 -josh



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

2013-01-04 Thread Josh Santangelo
I'm trying to build a simple server where multiple clients connect over 
TCP, and any message from a client is relayed to all the others. This isn't 
going to be used for a chat room, but it's basically the same idea.

I tried building this with socket.io but got stuck pretty quickly:

var io = require('socket.io').listen(81);

console.log('foo');
io.sockets.on('connect', function (socket) {
  console.log('connected...');

  socket.on('disconnect', function () {
console.log('disconnected');
  });
});

I see foo trace out, and on the client side it looks like I'm connected, 
but connected and disconnected never trace out, so I'm guessing those 
event handlers aren't working for some reason.

I'm not married to socket.io, and actually using fewer modules would be 
better, but I'm surprised I couldn't find a code sample for this use case 
since it sounds like it's a pretty common node.js usage.

Obviously this is my first time using node.js! Any pointers would be very 
helpful.

thanks,
-josh

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

2012-12-17 Thread josh
Redis might not be optimal for my case since it store everything in memory 
and i might be in a situation where apple server is not available and many 
failed messages will be saved in memory very quickly. also, if I plan to 
keep those messages for reporting etc, i should store it in a more 
persistent DB. 

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

2012-12-16 Thread josh
I am about to build a push notification service for iOS (android in the 
future). I don't know at the moment how much load it should handle, but 
let's assume it's 500 requests per second. it might be lower, but i would 
rather built it to handle it.

I found a good post about flickr - 
http://code.flickr.net/2012/12/12/highly-available-real-time-notifications/
they have 1..n (php) http servers that send reuests to Redis. Redis publish 
each request to at least 2 node severs (2 data centers) that 'compete' on 
doing the push (using locking feature of Redis).
so a single Redis is the center of the activity, and as long as it's 
running, there is no loss of notifications but Redis it's a single point of 
failure.
maybe they have some way to replicate Redis, but they didn't mention it?

1)
What about the following approach: http request - load balancer - 1..n 
machines each with node and Redis.
The load balancer will make sure to send each request to different 
node+redis instance.
When request comes, I'll make a call to MongoDB (see #2), see if the device 
id is a registered device and ony than i'll save the data in Redis, make 
the push to Apple and update the status in Redis.
I'll also have some background process that retry the failed ones and I 
might create a web interface that query all the Redis instances and display 
info about failures/successes. 
In this approach there might be a bit more data loss (when server dies or 
crashes, but not on server restart) but code complexity and scaling seems 
easy.

2)
I have other data (registered devices and info about different apps) that I 
plan to store in MongoDB and use replica-sets for redundency.
on each request I'll have to access it before saving into Redis. if I feel 
that it's too slow to hit MongoDB on each request, i can load this data to 
memory when the server starts but i'll have
to figure out what to do when the data on MongoDB changed.

3)
Also, I don't know how APNS (apple push service) works yet. 
do I need to send it messages in batches or it will be fine with many 
individual messages (from different devices)?


basic flow:

device id found in Mongo?
  save in Redis
  send to apple
update status in Redis

Any suggestions/code samples/blog posts 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


[nodejs] Re: Architecture of a scalable push notification service

2012-12-16 Thread josh
also, if I have 2 cores, should i have node+Redis on each?

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


Re: [nodejs] [ANN] node-avro 0.2: Avro support for Node.js

2012-11-07 Thread Josh Faul
At work, we use protobuf to communicate between all of our services. That 
said, we're mostly a Ruby shop.  A few of the devs here have been working 
hard on our new implementation, which uses the actual protoc compiler to 
generate classes instead of some hand-parsing craziness that we used to 
use.  I've been working a bit on an implementation for Node based on this 
work, but life keeps getting in the way.  If anyone wants to have a crack 
at it, I highly recommend digging through the generator they worked on, 
available 
at https://github.com/localshred/protobuf/tree/master/ext/ruby_generator

Props to BJ and Brandon for awesomeness. :)

--Josh

On Wednesday, November 7, 2012 11:54:58 AM UTC-7, Jacob wrote:

 Since we're on this topic, what is the general state of 
 Avro/Thrift/Protobufs. Are many people using them in production? I 
 know Thrift is supposed to have native support, but the generated code 
 is much less complete than the Java version. Protobufs seem to have a 
 dynamic library that more or less provides a dynamic interface. 

 - Jacob 

 On Wed, Nov 7, 2012 at 8:41 AM, Manuel Simoni msi...@gmail.comjavascript: 
 wrote: 
  Hi everybody, 
  
  I'm releasing the first stable version of node-avro under the MIT 
 license: 
  https://github.com/collectivemedia/node-avro 
  
  Best regards, 
  Manuel Simoni 
  
  -- 
  Job Board: http://jobs.nodejs.org/ 
  Posting guidelines: 
 https://github.com/joyent/node/wiki/Mailing-List-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.comjavascript: 
  To unsubscribe from this group, send email to 
  nodejs+un...@googlegroups.com javascript: 
  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: a simple http server making current folder accessible from web?

2012-10-31 Thread Josh Faul
I actually use this in my .zshrc:
alias servethis=python -m SimpleHTTPServer 

And then I have an easily accessible bookmark for it.  Very handy for 
testing simple things.

On Sunday, October 28, 2012 5:48:39 AM UTC-6, Angelo Chen wrote:

 I did some google, and found out python has that: 

 python -m SimpleHTTPServer 


 On Oct 28, 5:26 pm, Ryan Schmidt google-2...@ryandesign.com wrote: 
  On Oct 28, 2012, at 02:53, Angelo Chen wrote: 
  
   trying to find a quick and dirty solution in nodejs: often need to 
 access a folder in mac from  ipad's Safari, is there a simple, one file 
 nodejs script that can do it? thanks, 
  
  Be more specific. Define access. 
  
  If you just want to see the contents of a folder on your Mac from your 
 iPad and access MobileSafari-compatible files inside it, for example, you 
 could run any web server on your Mac and let it serve that folder. Since 
 I'm guessing that's not what you meant, let us know what you meant. 


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


Re: [nodejs] Re: A quest for a more accurate net.isIP() for IPv6

2012-10-04 Thread Josh Erickson
Thanks guys! I didn't know that about split operations.

Jonny, do you have benchmarks handy on your django port? If not, I'll hack 
something together and get them myself. If it is faster, I'd just rather it 
be brought into node itself then me stumble around in the dark anymore.

This past day I've done some more thinking on how regex might be done 
differently so as to not use splits and less lines. The result is the code 
below. The additions to the regex currently found in node fix the :: prefix 
issue as well as a::b::c and a:b:c situations. The trade off is that in 
some cases the tests can 3-5 times slower than the old net.isIP. I still 
think that's okay if better results are given. Still though, I want to 
believe this could be faster. I do have some code laying around for 
converting an IPv6 string to Buffer object.

It's also ran though the test-net-isip.js unit without issue, which is more 
than I could have said for my last set of code.

Beyond these, perhaps delving into some C and sending data straight to 
inet_pton and letting it success or fail would bring the speed up.

isIP = function(input) {
  if (!input) {
return 0;
  } else if 
(/^(\d?\d?\d)\.(\d?\d?\d)\.(\d?\d?\d)\.(\d?\d?\d)$/.test(input)) {
var parts = input.split('.');
for (var i = 0; i  parts.length; i++) {
  var part = parseInt(parts[i]);
  if (part  0 || 255  part) {
return 0;
  }
}
return 4;
  } else if 
(/^::$|^::1$|^([a-fA-F0-9]{0,4}::?){1,7}([a-fA-F0-9]{0,4})$/.test(input)  
!(/::.+::/.test(input))) {
if (input.match(/:/g).length  7  !(/::/.test(input))) {
  return 0;
}
return 6;
  } else {
return 0;
  }
};

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


[nodejs] ANN: statelet

2012-08-23 Thread Josh Johnston
Hi all, I've published a module that I've been using for a little while and 
find quite useful: https://npmjs.org/package/statelet

Take a look at the examples, feedback greatly appreciated.  

TLDR: States are a lot like Events, but more permanent in nature.  An Event 
describes a change at a point in time, and a State describes the thing 
itself while notifying you whenever it changes.

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups nodejs group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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: what does the \n in response.write('hello\n'); responsible for?

2012-08-11 Thread josh
var http = require('http');
 
http.createServer(function (request, response) {
  response.write('Hello');
  setTimeout(function(){
response.end('world');
  }, 5000);
}).listen(3001);


this code will not display 'Hello' right away. it will display 'Hello 
world' after 5 seconds.
changing it to response.write('Hello\n') will display it right away. 

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups nodejs group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] what does the \n in response.write('hello\n'); responsible for?

2012-08-09 Thread josh
i noticed that response.write('hello\n'); will send 'hello' to the client. 
but ommiting the \n does not. is it chrome specific or
is that node's way to stream part of the response to it's clients?

also, is node server always streams the response back to it's client?

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


[nodejs] how to do performance test of my POST service

2012-08-03 Thread josh
I am trying to improve our existing file upload API (using sinatra) and see 
if Node can be a better alternative.
i am using formidable to upload the file, than I stream(read) the file from 
disk into put request that saves it on our cloud servers, and finally, I 
save some meta data into a mysql. 
I make sure nothing is blocking and never load the file into memory, by 
using streaming.

please review my code and let me know what can I improve.
also, i tested it with jmeter and here are the results: 
http://i.imgur.com/PSWjH.png?1http://i.imgur.com/PSWjH.png?1
I set it up with 20 concurrent connections for 1 minute.

the problem with my test is it relies on the network connection and i don't 
really know how much time was spent on the server itself, 
how much memory, cpu and bandwidth was used? what is the speed of disk 
writes my server can handle?

one idea i can think of is taking samples from top command on the server to 
figure out the memory and cpu.
any tips/tools ideas or other things i should do?

here http://pastebin.com/xmh281hq is most of the code (with syntax 
highlight) and I also pasted it here: 

// server.js

process.env.TMP = '/tmp/upload';

// core modules
var http = require('http');
var util = require('util');

// non-core packages
var formidable = require('formidable'); // easy handling of file uploads
var mysql = require('mysql');

// my modules
var saveMeta = require('./saveMeta.js'); // save name in mysql
var saveFile = require('./saveFile.js'); // save file on my private cloud

var connection = mysql.createConnection({
  host : 'localhost',
  database : 'test',
  user : '',
  password : '',
});

connection.connect();

http.createServer(function(req, res) {
  // curl -F myupload=@/pic.JPG 0.0.0.0:3001/api -v
  if (req.url == '/api'  req.method.toLowerCase() == 'post') {
// parse a file upload
var form = new formidable.IncomingForm();

form.parse(req, function(err, fields, files) {
  res.writeHead(200);
  res.end();
});

form.on('file', function(name, file) {
  //save file in private cloud and save meta info in mysql
  saveFile(connection, file.name, file.path, saveMeta);
});

return;
  }

}).listen(3001);


// -
// saveFile.js

module.exports = saveFile;

var fs = require('fs');
var request = require('request');


// get file size and send to my cloud
//
// arguments:
// connection - mysql connection
// name - original file name
// path - path on temp directory
// saveMeta -  callback for saving into mysql
function saveFile(connection, name, path, saveMeta) {
  //adding a random number to file name. my cloud require unique names
  var rand = Math.floor(Math.random()*1).toString(); 
  var url = 'http://my-private-cloud.com:5000/test-' + rand;

  function getFileSize(cb) {
fs.stat(path, function(err, stats) {
  if(err) {
console.log('error while reading the file:' + path, err);
  } else {
if(cb) {
  cb(stats.size);
}
  }
});
  };

  // stream(read) the file from hardrive into put request that saves it on 
our cloud
  //
  // curl -sSf -T file1 http://my-private-cloud.com:5000/test
  // 200 - file was saved
  // anything else - file was not saved
  function sendFileToCloud(fileSize) {
var file = fs.createReadStream(path)
  .pipe(request.put({url: url, headers:{'Content-Length': fileSize}}, 
function(err, res, body){
if(err) {
  console.log('error in PUT request to my cloud:', err);
} else {
  // console.log('status from cloud:', res.statusCode);
  // console.log('file url:', url);
  if(res.statusCode === 200) {
saveMeta(connection, name, path, url) 
  }
}
  }));

file.on('data', function(chunk) {
})

file.on('end', function() {
});

file.on('error', function(e) {
  console.log('error:', e);
});
  };

  getFileSize(sendFileToCloud);
};

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

2012-08-03 Thread josh
awesome advice. i wanted to do that but didn't figure it out yet!

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


[nodejs] Re: sending a file using HTTP PUT

2012-07-25 Thread josh
problem solved:

var file = fs.createReadStream(path)
  .pipe(request.put({url: url, headers:{'Content-Length': fileSize}}, 
function(err, res, body){
if(err) {
  console.log('error', err);
} else {
  console.log('status', res.statusCode);
  if(res.statusCode === 200) {
console.log('success'); 
  }
}
  }));


note: i had to pass the fileSize by using the async function fs.stat()

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

2012-07-24 Thread josh
btw i am able to do PUT using fs.readFile but i don't want to load each 
file into memory.
is my api suppose to support streaming or should this piping approach works 
with any server?

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups nodejs group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] API for uploading files using formidable - don't see the temporary file and 'file' event not emitted

2012-07-24 Thread josh
I want to create an end-point for uploading image files. i want it to be as 
fast as possible 
I use formidable but the 'file' event never being emitted and i don't see 
the file in /tmp/upload (process.env.TMP).

any idea why? 

http://pastebin.com/sMefhfsf

maybe it's the way i curl it?
curl -H Content-type: application/x-www-form-urlencoded --upload-file 
pic.JPG 0.0.0.0:3001/api -v


   1.form.parse(req, function(err, fields, files) {
   2.   console.log(fields); // = a lot of text in the terminal
   3.   console.log(files); // = {}
   4.  
   5.   res.writeHead(200);
   6.   res.end();
   7. });
   8.
   9. form.on('file', function(name, file) {
   10.   console.log('file event', name); // never gets here
   11. });
   

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

2012-07-23 Thread josh
I read Hughes-Croucher slides from his talk at velocity conference - Using 
Node.js to improve the performance of Mobile apps and Mobile web.
can someone explain slide 50 - Node.js allows you to tune rendering 
between client and server based on the network - 
http://www.slideshare.net/sh1mmer/using-nodejs-to-improve-the-performance-of-mobile-apps-and-mobile-web

is the idea is to measure the time it takes to send packets from each 
client and the device type and based on it to decide whether to render html 
on the server or send back json 
and let the client do the render?
high bandwidth, high latency = render html on the server and send html back.
low bandwidth, low latency, powerful device = send json back and render 
html on the client 


is that what he means? 
are there more advantages for mobile devices and the usage of node?

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


Re: [nodejs] Re: e-Commerce platform

2012-07-21 Thread josh
1) for any open source project your goal is to get as many people as 
possible participating.
there are a lot more JS programmers than CS programmers out there.
by choosing CS you are reducing the number of people who can contribute to 
your project.

2) ECMAScript 6 is going to add the - operator so if you like CS since you 
type less, this advantage is about to disappear (at least on the server).


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


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

2012-07-12 Thread josh
// test.js
var i=0;
debugger;



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


how to display the value of i?

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


[nodejs] why is node server easier for maintaining state between requests?

2012-07-09 Thread josh
http://vimeo.com/40554843 
this is Mikeal's presentation from 'Keeping It Realtime Conference'
watch minute 7:30-8:30.  

he say that node, unlike ruby/php/python allow you to store your cache in 
the server process and instead of an external process (i assume memcached 
is a common one).
is that due to the fact that we use closures in js, so all the variables 
are available to all the callbacks?
Does it mean to store my state in simple variables like array and hashes?
I know that a node process has only 1.7GB of memory due to a v8 limitation. 
isn't it a problem in that regard?

also, can't you have state in ruby by using public variables on the server 
that are available to any request?   

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


[nodejs] Re: accessing a variable in a function that is exported from a module (using mapletree routing module)

2012-07-04 Thread josh
thanks guys. both ways works. i prefer the module.export.foo way since i 
don't need to pass the variable to multiple functions.

On Tuesday, July 3, 2012 2:47:58 PM UTC-7, josh wrote:

 I have a variable in server.js. how to access it from within a function 
 that is exported from a module? 
 I use mapletree as my routes library that provide me define function -

 var usersCollections = {};
 router.define( '/user', require('./routes/user.js') 

 //routes/user.js

 module.exports = user;

 function user (req, res) {
   console.log('collection', usersCollection); // not defined
   return res.end();
 };

 http://pastebin.com/SLHM85Xt

 here is the complete project - 
 https://github.com/oren/Y-U-NO-BIG


-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups nodejs group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] accessing a variable in a function that is exported from a module (using mapletree routing module)

2012-07-03 Thread josh
I have a variable in server.js. how to access it from within a function 
that is exported from a module? 
I use mapletree as my routes library that provide me define function -

var usersCollections = {};
router.define( '/user', require('./routes/user.js') 

//routes/user.js

module.exports = user;

function user (req, res) {
  console.log('collection', usersCollection); // not defined
  return res.end();
};

http://pastebin.com/SLHM85Xt

here is the complete project - 
https://github.com/oren/Y-U-NO-BIG

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups nodejs group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] accessing a variable in a function that is exported from a module (using mapletree routing module)

2012-07-03 Thread josh
fast routing library. instead of using express i use plain node.js + 
routing lib -
https://github.com/saambarati/mapleTree



On Tuesday, July 3, 2012 2:49:06 PM UTC-7, Marak Squires wrote:

 What is a Maple Tree?

 On Tue, Jul 3, 2012 at 2:47 PM, josh macmillan.jos...@gmail.com wrote:

 I have a variable in server.js. how to access it from within a function 
 that is exported from a module? 
 I use mapletree as my routes library that provide me define function -

 var usersCollections = {};
 router.define( '/user', require('./routes/user.js') 

 //routes/user.js

 module.exports = user;

 function user (req, res) {
   console.log('collection', usersCollection); // not defined
   return res.end();
 };

 http://pastebin.com/SLHM85Xt

 here is the complete project - 
 https://github.com/oren/Y-U-NO-BIG

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

2012-06-23 Thread josh
thanks. i figure it out and here are the 2 examples:

// raw

var https = require('https');
var querystring = require('querystring');

var post_data = querystring.stringify({
  'assertion' : 'abc'
  'audience' : '0.0.0.0'
});

var options = {
  host: 'browserid.org',
  path: '/verify',
  method: 'POST',
  'headers' : {
'content-type' : 'application/x-www-form-urlencoded',
'Content-Length': post_data.length
  }
};

var req = https.request(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();


//---
// using request

var request = require('request');

var assertion = 'abc';

var options = {
  'method' : 'POST',
  'uri' : 'https://browserid.org/verify',
  'body' : 'assertion='+ assertion + 'audience=0.0.0.0',
  'headers' : {
'content-type' : 'application/x-www-form-urlencoded'
  }
};

request(options, function (error, response, body) {
  if (!error  response.statusCode == 200) {
console.log('body', body) 
  } else {
console.log('body', body);
  }
})

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

2012-06-23 Thread josh
Another question, regarding the documentation of http - 
how come the res argument of the callback that is called on http.reuest is 
not listening to the 'end' event in the example? 
http://nodejs.org/api/http.html#http_http_request_options_callback

Also, what is the size of a chunk? is it always the same in node?
  


On Saturday, June 23, 2012 3:17:33 PM UTC-7, josh wrote:

 I try to POST to this url - https://browserid.org/verify. using row node 
 i get: getaddrinfo ENOENT and using the request package i get: Content-Type 
 expected to be one of: application/x-www-form-urlencoded, application/json.

 Another question - Is there any reason not to use browserID for 
 authentication? it seems like an easy way to avoid remembering hounders of 
 passwords. 

 // POST using row node

 var http = require('http');

 var options = {
   host: 'https://browserid.org',
   port: 80,
   path: '/verify',
   method: 'POST'
 };

 var req = http.request(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);
 });

 // write data to request body
 req.write(assertion=abcaudience=0.0.0.0);
 req.end();

 //-

 // POST using the request package

 var http = require('http');

 var options = {
   host: 'https://browserid.org',
   port: 80,
   path: '/verify',
   method: 'POST'
 };

 var req = http.request(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);
 });

 // write data to request body
 req.write(assertion=abcaudience=0.0.0.0);
 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: 2 issues - 'Error: socket hang up' and too many phantom.js processes running

2012-05-01 Thread josh
Here is what I did to solve it. I am curious to know if there are better 
ideas.

I added a check for stream.fd to the 'end' event and I only move the file 
to the real folder if it's not null.
this solved the issue with corrupted files.

res.on('end', function (chunk) {
  if(stream.fd === null) {
console.log('not renaming');
  } else {
console.log('renaming');
fs.rename(tmpfilename, filename)
  }
  stream.end();
});

The other issue - multiple instances of phantom.js, I solved by passing 
hash to the child_process.exec command:

  var options = { 
encoding: 'utf8',
timeout: 7000,
maxBuffer: 200*1024,
killSignal: 'SIGTERM',
cwd: null,
env: null 
  }

exec('phantomjs rasterize.js www.google.com 1.png', options, fn);

passing the options will make sure the process is killed if it took more 
than 7 seconds to run.


lastly - 
I am not sure how streams works. what i noticed is when i use 'return' 
within a route, the 'end' event is being emitted.
another mystery I have is where do I tell express to stream the file? is it 
this line - res.sendfile  ?


-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups nodejs group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] 2 issues - 'Error: socket hang up' and too many phantom.js processes running

2012-04-30 Thread josh
I have 2 tiny node services:
1. screenshot service 
(https://github.com/fzaninotto/screenshot-as-a-service) - get's url and can 
stream back a snapshop of it.
2. image updater - calls the screenshot service every few minutes with 5 
urls.

Here is the code for the image updater.

require('http');
var url  = require('url');
var fs   = require('fs');
var environment = process.env.NODE_ENV || 'development';
var config = require('./config/' + environment + '.js');
var interval = config.interval * 1000 * 60; //we want minutes

function createImages(){ 
  console.log(new Date().toUTCString(), ' - creating images');
  for (name in config.urls) {
var options = url.parse(config.screenshotServiceUrl + 
config.urls[name]);
createImage(name, options);
  };
}

// get request to our screenshot service and creating an image file
function createImage(name, options) {
  http.get(options, function(res) {
var stream = fs.createWriteStream(config.imagesPath + name + '.png');

res.on('data', function (chunk) {
  stream.write(chunk);
});

res.on('end', function (chunk) {
  stream.end();
});
  });
};

createImages();

// every 5 minutes
setInterval(function() {
  createImages();
}, interval);

After a few hours (maybe days sometimes) of running them, I have one out of 
the following 2 issues - 
1. The image updater crashes with this message: 'Error: socket hang up'.
2. The machine is getting slow since there are multiple instances of 
phantomjs, the tool used by the screenshot service. I have to manualy kill 
them (ps aux|grep phantomjs | awk '{print $2}' xargs kill -9).

my node version - 0.6.14
google for the first issue led me to this discussion - 
https://groups.google.com/forum/#!topic/nodejs/kYnfJZeqGZ4 but it seems to 
be an old version of node.

Any tips and ideas ore welcome!

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups nodejs group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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] 2 issues - 'Error: socket hang up' and too many phantom.js processes running

2012-04-30 Thread josh
thank you. i'll add it to my code.

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups nodejs group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, 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: 2 issues - 'Error: socket hang up' and too many phantom.js processes running

2012-04-30 Thread josh
I found out the reason for those issues - disconnecting from the internet 
for a split second.
when i disconnected my laptop, the socket error showed up and i noticed 
more and more instances of phantom.js being created, but never dies.
the image updater service didn't crash (if i remember correctly) and when i 
hit ctrl+c the phantom.js instances didn't die, but no new instances were 
created.

the only time i need internet connection is when the screenshot service 
take a snapshot using phantom.js.
my guess is that the image updater keeps on calling the screenshot service 
but from some reason, the screenshot service can't handle the requests, it 
create another instance of phantom.js and emit the socket error back to the 
caller, even though the connection is back.

any idea how to deal with this error?

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

2012-04-22 Thread josh
I am building 2 separate express sites:
clients website - visitors can talk to me (the admin of the site) via
chat (1 on 1 only. they can't see each other).
admin website - for me, the admin, to see all current conversations
and the ability to reply to whatever user I want.

I am using socket.io to emit messages from the clients website to the
admin website.

Is there a way to update the Admin UI whenever the admin site receives
a message?
Is there a way from the UI to emit a message back to the client's
browser?
Is there a problem with the design of my sites? maybe i should have 3
separate apps and not 2 (so the socket.io server will stand on it's
own).

Any other alternatives/suggestions would be great.
Thanks!

this code is part of the Admin server:

  basket = {}; // holds a hash of sockets

  socket.on('msg', function (data) {
socket.get('nickname', function (err, name) {
  console.log('Chat message by ', name, ' saying', data.text);
  var to = basket[name];
   // i don't want to send this from here. i want the admin to see
all messages from different users
   // and he should be able to reply whenever he wants to
  //to.emit('msg', { text: what's up  + name });
});
  });
});

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