This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| var Transform = require('stream').Transform, | |
| inherits = require('util').inherits; | |
| var noBuf = new Buffer(0); | |
| module.exports = factory; | |
| function factory(start, end) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [kris.re@krisre foo]$ node bar | |
| double queue 100000 29 | |
| double queue 200000 54 | |
| reverse queue 100000 18 | |
| reverse queue 200000 64 | |
| queue 100000 38 | |
| queue 200000 49 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| var Promise = require('bluebird'), | |
| Deque = require('double-ended-queue'); | |
| module.exports = Queue; | |
| function Queue(opts) { | |
| opts = opts || { }; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CoinsVote.find( {} ,"name vote ip submitted" , function (err, data) { | |
| if (err) { | |
| console.error(err); | |
| return; | |
| } | |
| if (data === null) { | |
| console.log("No results"); | |
| return; | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| HTML: | |
| <form action="/api/thing" method="post" enctype="multipart/form-data"> | |
| <input name="caption"> | |
| <input type="file" name="file"> | |
| <input type="submit" value="Submit"> | |
| </form> | |
| Request: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var pg = require('pg'); | |
| var request = require('request'); | |
| var Promise = require('bluebird'); // version 2.0! | |
| // pg interface is a bit awkward to promisify | |
| var connect = Promise.promisify(pg.connect, pg); | |
| pg.connect = function (connString) { | |
| return connect(connString).spread(function (client, done) { | |
| client.done = done; | |
| Promise.promisify(client, { suffix: '$' }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var sequelize = new Sequelize('postgres:/tmp'); | |
| var CM = sequelize.transactionManager.ConnectorManager; | |
| sequelize.transactionManager.ConnectorManager = function (sequelize, config) { | |
| var cm = new CM(sequelize, config); | |
| cm.pg.defaults.database = 'database_name'; | |
| return cm; | |
| } | |
| sequelize.getQueryInterface().QueryGenerator |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // config.amqp = connection parameters | |
| var worker = new Worker( | |
| extend({ }, { | |
| exchange: 'exchange', | |
| bindings: { | |
| 'exchange': [ | |
| // queue we process from | |
| 'class.method.job', | |
| 'class.method.settled' | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Promise=require('bluebird'); | |
| var SerialPort = require("serialport").SerialPort | |
| var openedPort=false; | |
| var puerto; | |
| var Serial = function(puerto) { | |
| var self = this; | |
| self.openedPort = false; | |
| //crea un objeto serialport, abre el puerto |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Promise = require('bluebird'), | |
| redis = require('redis'); | |
| var db = redis.createClient(); | |
| Promise.promisifyAll(Object.getPrototypeOf(redis), { suffix: '$' }); | |
| function _scan(cmd, key) { | |
| function recurse(ttl, cur) { | |
| return cmd(key, cur).then(function (cur, val) { | |
| if (cur) { |