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'; | |
| const logLevel = require('loglevel'); | |
| const timeSpan = require('time-span'); | |
| const {identity} = require('lodash'); | |
| const {merge} = require('lodash'); | |
| /** | |
| * // MessageQueueService.js | |
| * |
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
| // implementation | |
| const Promise = require('bluebird'); | |
| /** | |
| * what if we have several services that allow us to get the weather data. We | |
| * preffer certain weather services over others, but if that weather service | |
| * fails to return a data type we want to use another one to try and get it. | |
| * | |
| * To keep the amount of requests being done to a minimum we only want another |
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
| const {head, tail, identity, isEmpty} = require('ramda') | |
| const END_OF_LIST = Symbol() | |
| const car = c => c(identity) | |
| const cdr = c => c((a, b) => b) | |
| function cons(a, b) { | |
| return (f) => { | |
| return f(a,b) | |
| } |
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'; | |
| const valueIdentifier = Symbol() | |
| const multiIdentifier = Symbol() | |
| const defaultMethodIdentifier = Symbol() | |
| module.exports = { | |
| multi, | |
| method, | |
| defaultMethod, |
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' | |
| const {times, equals, take, join} = require('ramda') | |
| function randomBinary() { | |
| return Math.random() < 0.5 ? 0 : 1 | |
| } | |
| function middle(width) { | |
| const values = times(() => 1, width) |
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'; | |
| /** | |
| * the goal of the must monad is to prevent required data not being defined. | |
| * This is done by throwing an error when performing an operation on required | |
| * data. | |
| * | |
| * This plays nice with the monad interface. Whenever a value should throw when | |
| * not being defined the Must monad allows you to do this. | |
| * |
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
| const {update, lens, propEq, lensProp, findIndex} = require('ramda'); | |
| function lensFind(pred) { | |
| let index; | |
| return lens((items) => { | |
| index = findIndex(pred, items); | |
| return items[index]; | |
| }, (item, items) => { |
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
| " === Auto complete === | |
| set complete="sflbhst" | |
| " === GUI === | |
| set gui=none | |
| " === Hints === | |
| " Only use characters that don't suck to press. | |
| set hintchars="qwertasdfguophjk;" |
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
| // In case you do not want to use promisify but do want SailsModel.query to | |
| // return a promise. | |
| // | |
| // Usage: query(User, 'SELECT * WHERE id = ?', [1]); | |
| /** | |
| * @param {Model} model - an instance of a sails model | |
| * @param {string} sql - a sql string | |
| * @param {*[]} values - used to interpolate the string's ? | |
| * |
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
| /** | |
| * Extend a constructor/type with new methods | |
| * | |
| * @param {Constructor} type - reference to a constructor | |
| * @param {Constructor} protocolType - reference to a constructor | |
| * @param {object} properties - which stores the method/property names | |
| * and values | |
| * | |
| * @returns {Constructor} reference which equals the type Constructor | |
| */ |