[nodejs] BSON to v8::Object performance issue

2017-11-14 Thread Jean-Marc Le Roux
Hello,

I'm trying to create NodeJS bindings for libbson.
One of the things I need is to be able to transform a bson_t document into 
a v8::Object.
Loading, iterating on bson_t documents and matching them with MongoDB-style 
queries it very fast: 50ms to load from my HDD, iterate and filter 26000 
bson_t documents.
On the same machine, converting the same BSON documents into v8::Object is 
painfully slow.
So I suspect I missed something.

Here is my code:

Local
iterator_to_value(Isolate* isolate, const bson_iter_t* iter)
{
switch (bson_iter_type(iter))
{
case BSON_TYPE_INT32:
return Number::New(isolate, bson_iter_int32(iter));
break;
case BSON_TYPE_INT64:
return Number::New(isolate, bson_iter_int64(iter));
break;
case BSON_TYPE_DOUBLE:
return Number::New(isolate, bson_iter_double(iter));
break;
case BSON_TYPE_DOCUMENT:
{
bson_iter_t sub_iter;
bson_iter_recurse(iter, _iter);

Local obj = Object::New(isolate);
while (bson_iter_next(_iter))
{
const char* key = bson_iter_key(_iter);

obj->Set(
String::NewFromUtf8(isolate, key),
iterator_to_value(isolate, _iter)
);
}

return obj;
}
break;
case BSON_TYPE_ARRAY:
{
bson_iter_t sub_iter;
uint32_t length;
const uint8_t* array_data;

bson_iter_array(iter, , _data);
bson_iter_recurse(iter, _iter);

Local array = Array::New(isolate);
int i = 0;

while (bson_iter_next(_iter))
{
array->Set(i++, iterator_to_value(isolate, _iter));
}

return array;
}
break;
case BSON_TYPE_OID:
{
const bson_oid_t* oid = bson_iter_oid(iter);
char oid_buffer[25];

bson_oid_to_string(oid, oid_buffer);

return String::NewFromOneByte(isolate, (uint8_t*)oid_buffer);
}
break;
case BSON_TYPE_UTF8:
{
uint32_t length;
return String::NewFromUtf8(isolate, bson_iter_utf8(iter, 
));
}
break;
}

return Null(isolate);
}

Local
fill_object(Isolate* isolate, Local& obj, const bson_t* document)
{
bson_iter_t iter;
if (bson_iter_init(, document))
{
while (bson_iter_next())
{
const char* key = bson_iter_key();

obj->Set(
String::NewFromUtf8(isolate, key),
iterator_to_value(isolate, )
);
}
}

return obj;
}

As you can see, it's very straight forward.
*Transforming 26400 bson_t into v_::Object takes 1.23s.*

I tried doing what I believe to be the same code in pure JS with a 
representative sample Object :

var array = [];
for (var i = 0; i < 25000; ++i)
{
array.push({
"_id": {
  "$oid": "5a00bad8f759511811e030ba"
},
"attributes": [
  {
"key": "smartshape.scene.node.path|default",
"value": "/scene/Lot444.scene",
"type": "imported"
  },
  {
"key": "max x",
"value": 196.5773162841797,
"type": "computed"
  },
  {
"key": "max y",
"value": 18.55002021789551,
"type": "computed"
  },
  {
"key": "max z",
"value": 22.87815856933594,
"type": "computed"
  },
  {
"key": "min x",
"value": 149.9346771240234,
"type": "computed"
  },
  {
"key": "min y",
"value": 18.54999732971191,
"type": "computed"
  },
  {
"key": "min z",
"value": -23.35353088378906,
"type": "computed"
  },
  {
"key": "box radius",
"value": 23.32131958007814,
"type": "computed"
  },
  {
"key": "center x",
"value": 173.25599670410156,
"type": "computed"
  },
  {
"key": "center y",
"value": 18.55000877380371,
"type": "computed"
  },
  {
"key": "center z",
"value": -0.23768615722655895,
"type": "computed"
  },
  {
"key": "width",
"value": 46.64263916015628,
"type": "computed"
  },
  {
"key": "height",
"value": 2.2888183600855427e-05,
"type": "computed"
  },
  {
"key": "depth",
"value": 46.231689453125,
"type": "computed"
  },
  {
"key": "box volume",
"value": 0.04935534689932106,
"type": 

[nodejs] Nodejs equivalent of Web Javascript URL.createObjectURL(new Blob(["some string code"]))

2017-11-14 Thread DrLightman
Hello,

I need to convert for my nodejs project what I found in a javascript 
environment for web code:

var foo = window.URL.createObjectURL(new Blob([" ..."]) );

Searched but with no luck at all.

Any idea?

Thank you.

-- 
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/00968901-92ed-4607-98cf-39cf64f3e340%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[nodejs] Re: New to node.js. Need help with Node application running through Apache web server

2017-11-14 Thread Zlatko
Hi,

On Friday, November 10, 2017 at 12:07:56 AM UTC+1, Kyle Hall wrote:
>
>
> In order to view the application off our VPN, we set up an Apache proxy to 
> our public-facing test URL: http://www.testdomain.com/calendar. The 
> application runs, but none of our CSS or JS files show up. They are all 
> 404ing in the debugging console, showing up as 
> http://www.testdomain.com/css/layout.css instead of 
> http://www.testdomain.com/calendar/css/layout.css.
>
> We've found that if we add /calendar to the CSS and JS paths in the 
> layout.jade file, it works. But we're wondering if there is a way to set up 
> our Apache proxy so that it only proxies the front-end pages and not the 
> internal CSS and JS folders. The other problem is that we also have JS 
> files at the root of our application, so we would likely have to proxy 
> ignore those files individually as well.
>
 
Well, there are a few things. One, you would be much better off if you 
serve the assets directly by apache. Say your static stuff is in your 
*/var/app/public/assets/{css/img/js}* directory - you would tell your proxy 
(in this case apache) to serve any of the */calendar/assets/** requests 
directly from there. That way you offload serving static files from your 
app server (Node).

The other thing is to setup static route differently - e.g. you probably 
have somewhere in your code a line like this: *app.use('/assets', 
express.static(__dirname + '/public/assets'));* Now, what you do there is 
say *app.use('/calendar/assets', express.static(...));*. The first solution 
is much better because your node app will always work on */ *path if served 
standalone (like when you're working on the app), and your proxy can pick 
and choose on which virtual directory you serve from (e.g. if you want to 
change /calendar to /cal, or even serve from both, your app developers 
don't need to know about this at all, the ops guy sets it up as he wants 
it).

 

-- 
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/923634b1-c60a-4b4d-9ae0-db40208bbcc8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[nodejs] Re: ZebroGaMQ: Communication Middleware for Mobile Gaming based on RabbitMQ and Node.js

2017-11-14 Thread vidya pasupuleti


Frigate Games is a games development studio. We have launched a game called 
Shark Angry Attack On the Humans at Beach-HD 2017. Play store link is: 
https://play.google.com/store/apps/details?id=com.svg.hungryattacksharksimulation=en

-- 
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/a3fdc792-1b2c-42aa-9d9d-5e90886bcc78%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[nodejs] Error: Cannot find module 'sync-request'

2017-11-14 Thread Curtis Paul
var request = require('sync-request');

but when I execute the .js script I get 

Error: Cannot find module 'sync-request'

echo %NODE_PATH%
C:\Program Files\nodejs\node_modules\npm\node_modules

I've done the following...
npm init -y
npm install sync-request
npm install -g sync-request

Googled itfound all kinds of forum posts about it, but didn't find 
anything that helps.

I'm not a nodejs expert but I bet some of you are.

Should I be using NODE_PATHif so is NODE_PATH set correctly?

I can do a require on ('request') at it seems to work fineso why do 
some modules work and others not?

-- 
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/39609cfb-9786-46b9-bf7e-e06115f84252%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[nodejs] combinedTickCallback error in docker container

2017-11-14 Thread David Jeche
I am having an issue with the execution of NodeJS on a Jenkins node. 
initially these tests where functional before. They run OK on the local 
system however when in a container there seem to be issue related to the 
error: 

at _combinedTickCallback (internal/process/next_tick.js:131:7)




I feel like this is a node problem rather than a container problem, because 
of the following:


// This value is used to prevent the nextTickQueue from becoming too
// large and cause the process to run out of memory. When this value
// is reached the nextTimeQueue array will be shortened (see tickDone
// for details).




this is taken from the following: 
https://github.com/nodejs/node/blob/master/lib/internal/process/next_tick.js


It suggests memory to be the issue or something related to the operation of 
node. I am use nightwatch.js with selenium integration. I am interested to 
know if anyone has an idea around how this feature operates.

-- 
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/741d6a26-bc73-4f0e-af9f-dad00152334e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.