Skip to content

Instantly share code, notes, and snippets.

View bas080's full-sized avatar

#!/bin/BasH bas080

View GitHub Profile
'use strict';
const logLevel = require('loglevel');
const timeSpan = require('time-span');
const {identity} = require('lodash');
const {merge} = require('lodash');
/**
* // MessageQueueService.js
*
// 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
@bas080
bas080 / list.js
Last active August 18, 2017 14:41
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)
}
'use strict';
const valueIdentifier = Symbol()
const multiIdentifier = Symbol()
const defaultMethodIdentifier = Symbol()
module.exports = {
multi,
method,
defaultMethod,
'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)
'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.
*
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) => {
" === Auto complete ===
set complete="sflbhst"
" === GUI ===
set gui=none
" === Hints ===
" Only use characters that don't suck to press.
set hintchars="qwertasdfguophjk;"
// 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 ?
*
@bas080
bas080 / protocol.js
Last active September 16, 2016 11:26
/**
* 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
*/