lundi 20 avril 2015

How to generate shell script in eclipse when we build the program?

I like to generate shell script in eclipse when we build the program? In shell script, it contains all the dependencies of JAR.

So that, I will invoke the shell script file in Node.js to process the action.

In google, everyone said about Manifest/Plug in, I am little bit confused about the steps.

dimanche 19 avril 2015

Using logstash and elasticseach

I'm actually using node-bunyan to manage log information through elasticsearch and logstash and I m facing a problem.


In fact, my log file has some informations, and fills great when I need it.


The problem is that elastic search doesn't find anything on



http://localhost:9200/logstash-*/



I have an empty object and so, I cant deliver my log to kibana.


Here's my logstash conf file :



input {
file {
type => "nextgen-app"
path => [ "F:\NextGen-dev\RestApi\app\logs\*.log" ]
codec => "json"
}
}

output {

elasticsearch {
host => "localhost"
protocol => "http"
}

}


And my js code :



log = bunyan.createLogger({
name: 'myapp',
streams: [
{
level: 'info',
path: './app/logs/nextgen-info-log.log'
},
{
level: 'error',
path: './app/logs/nextgen-error-log.log'
}
]
})

router.all('*', (req, res, next)=>
log.info(req.url)
log.info(req.method)
next()
)


NB : the logs are well written in the log files. The problem is between logstash and elasticsearch :-/


EDIT : querying http://localhost:9200/logstash-*/ gives me "{}" an empty JSON object Thanks for advance


Incompatible node.js version

I used to install node-png: npm install node-png -g


I got a message says:



npm WARN engine node-png@0.4.3: wanted: {"node":"0.8.x"} (current: {"node":"0.12.2","npm":"2.7.4"})



How to fix it, note: I use earlier version ,,


Azure SQL Read timeout

The following code



var query = {
identifier: identifier,
state: commons.OTP_TOKEN_LIFECYCLE_STATES.UNUSED
};

this.store.where(query).take(1).read({
success: function(results){
console.log('Got some kickass randomness');
resolve(results);
},

error: function(err){
console.log("Error while reading the data");
console.error(err);
reject({});
}
});


Fails giving a timeout on azure mobile backend services. This.table is a reference to the table "otp tokens".


I have tried many things from changing the node.js version to updating the mssql driver installed on the server. But IT NEVER WORKS.


More intrestingly writes are extremely fast.


I also added a logger to log "read" from the "otp tokens" table, to my surprise it never fires.


Anybody got an insight in what is going on ?


How to limit the number of nodes?(Spritekit)

Hey guys i have a little problem check it out:



override func touchesBegan(touches: Set, withEvent event: UIEvent) {

for touch in (touches as! Set<UITouch>) {

var Location:CGPoint = touch.locationInNode(self)
var Node:SKNode = self.nodeAtPoint(Location)

if(Location.x < self.size.width/2) {

node2.addchild(sprite2)
node1.removeFromParent()
}
if (Location.x > self.size.width/2) {

node1.addchild(sprite1)

node2.removeFromParent()
}


The problem is that when i tap for exmple 10 times on the same side of the screen (lets say the right side) it apppears 10 spritenodes and i can t use "hidden" because of the physicsBody can you guys help me?


Running and debugging Karma tests in a Docker container

I want to dockerize my entire node.js app and run everything inside a docker container, including tests.


It sounds easy if you're using PhantomJS and I actually tried that and it worked.


One thing I like though about running tests in Chrome - easy debugging. You could start Karma server, open devtools, set a breakpoint in a test file (using debugger statement) and run Karma - it will connect to the server run tests, and stop at the breakpoint, allowing you from there to do all sorts of things.


Now how do I do that in a docker container?




  • Should I start Karma server (with Chrome) on a hosting machine and tell somehow Karma-runner inside the container to connect to it, to run the tests? (How do I do that anyway?)




  • Is it possible to run Chrome in a docker container (it does sound like a silly question, but when I tried docker search desktop bunch of things come up, so I assume it is possible (?)




  • Maybe it's possible to debug tests in PhantomJS (although I doubt it would be as convenient as with Chrome devtools)




Would you please share your experience of running and debugging Karma tests in a docker container?


mongoose deep populate based on query

I'm populating the mongoose model using deepPopulate plugin like so:



User.findOne({_id: req.params.user_id})
.deepPopulate('classes.assignments.submissions')
.exec(function (err, user) {
res.send(user);
})


And I want the submissions to be populated based on the query - only submissions for a current user - something like .where(submissions.user == req.params.user_id). I can't find the solution for this and end up in a situation where current user can see submissions from other users.


I was trying to set submissions for other users to null manually inside the exec:



for (var i = 0; i < user.classes.length; i++) {
var cl = user.classes[i];
for (var i = 0; i < cl.assignments.length; i++) {
var assign = cl.assignments[i];
for (var i = 0; i < assign.submissions.length; i++) {
var subm = assign.submissions[i];
if(subm.user != req.params.user_id){
subm = null
};
};
};
};


But it still returns not filtered submissions.