This file contains 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
#!/bin/bash | |
cd /tmp | |
apt-get update | |
apt install -y libtool pkg-config build-essential autoconf automake uuid-dev git wget | |
git clone git://github.com/jedisct1/libsodium.git | |
cd libsodium/ | |
./autogen.sh | |
./configure && make check | |
make install | |
ldconfig |
This file contains 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
/* | |
Listens to an EventEmitter and reduces the data returned. The EventEmitter must at least three types of events: | |
- dataEvent: it sends the data to be reduced | |
- endEvent: it signals the completion of the operation | |
- errorEvent: it sends an error. The operation is interrupted to handle it | |
*/ | |
function reduceEventEmmitter({dataEvent, endEvent, errorEvent = null}, accumulator = [], reducer, eventEmitter, cb) { | |
eventEmitter.on(dataEvent, function handleDataEvent(data) { | |
accumulator = reducer(accumulator, data); | |
}); |
This file contains 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
const async = require('async'); | |
const pg = require('pg') | |
// QueryConnect: (QuerySource, Callback) -> Connection | |
// QueryDisconnect: Connection -> Connection | |
// getSmartQuery : (QueryConnect, QueryDisconnect, QuerySource) -> SmartQuery | |
function getSmartQuery(connect, disconnect, querySource) { | |
let conn = null; | |
function connectClient(query, _connectClient) { |
This file contains 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
const unique = list => list.filter((value, index, list) => list.indexOf(value) === index); | |
const sortNumber = (a, b) => a - b; | |
const expandBlock = (accum, block) => { | |
if (block.indexOf('-') === -1) { | |
accum.push(parseInt(block)); | |
return accum; | |
} |
This file contains 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
const searchedBookShelf = originalBooks.reduce((searchedBook, originalBook) => { | |
if (originalBook.id === bookOnShelf.id) { | |
return originalBook.shelf; | |
} | |
return searchedBook; | |
}, null); |
This file contains 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
const Q = require('q'); | |
/** | |
* Method to reduce observable to a promise. | |
* | |
* @param observable | |
*/ | |
function reduceToPromise(observable) { | |
return observable.reduce((acc, item) => [...acc, item], []) | |
.toPromise(Q.Promise); |
This file contains 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
const fn = require('fn.js'); | |
const has = fn.curry(function(key, object) { | |
if (!object[key]) { | |
throw new Error(`Missing key '${key}' on object`); | |
} | |
return object; | |
}) |
This file contains 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
const fn = require('fn.js'); | |
const or = fn.curry((defaultValue, value) => value ? value : defaultValue); |
This file contains 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
const Rx = require('rx'); | |
getPages(5, 1) | |
.then(reduceToPromise) | |
.then(console.log) | |
function getPages(perPage, page) { | |
return new Promise(function(resolve, reject) { | |
resolve(getAllPages(perPage, page)); | |
}); |
This file contains 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
const Q = require('q'); | |
/** | |
* Transforms a Q Promise to a Promise | |
* @param {QPromise} qpromise | |
* @return {Promise} | |
*/ | |
function qp(qpromise) { | |
return new Promise(function(resolve, reject) { | |
qpromise |
NewerOlder