Skip to content

Instantly share code, notes, and snippets.

View EugeneKostrikov's full-sized avatar

Eugene Kostrikov EugeneKostrikov

  • Chisinau, Moldova
View GitHub Profile
process.on('message', function(msg){
require(msg.path)();
});
var when = require('when'); //It is a regular A+ Promises library
function somethingThatThrows(){
throw new Error('Boom');
}
when.resolve('Hello')
.then(function(result){
somethingThatThrows();
return result;
var i = setInterval(function(){
setInterval(function(){
console.log('reached');
}, 100);
}, 100);
setTimeout(function(){
clearInterval(i);
}, 101);
var async = require('async');
async.parallel([
function(done){
while(true){}
},
function(done){
console.log('second running');
setInterval(function(){
console.log('second interval running');
@EugeneKostrikov
EugeneKostrikov / gist:5b560a3b826722296804
Created October 4, 2014 10:19
Constant -> Provider
.provider('Test', ['constant', function(constant){
return {
$get: ['constant', function(sameConstant){
sameConstant === constant;
}]
}
});
module.exports = function(connection){
return {
thumb: function(doc){
if(doc.thumbnails) return;
var Thumbnal = connection.model('Thumbnail');
Thumbnail.generate(doc.url, function(err, thumb){
doc.thumbnails = thumb;
doc.save()
});