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 speedTest = require('speedtest-net'); | |
var TweetIt = require('tweetit'); | |
var creds = require('./creds'); | |
var tweetit = new TweetIt(creds.consumerKey, creds.consumerSecret, creds.accessToken, creds.accessTokenSecret); | |
speedTest({maxTime: 5000}, (error, data) => { | |
if(error){ | |
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
function onDrag(event){ | |
if(!dragging){ | |
return | |
} | |
// Tell the browser you are doing important stuff | |
// It will decide whether or not to delay background tasks for a small period of time | |
// For example, not doing garbage collection if it isn't really critical. | |
// It might also decided not to, if it NEEDS to GC, or paint, or anything. | |
window.requestBackgroundTaskDefer(); |
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 verifyUser = function(username, password, callback){ | |
const userInfo = righto(dataBase.verifyUser, username, password); | |
const rolesInfo = righto(dataBase.getRoles, userInfo); | |
const logStatus = righto(dataBase.logAccess, userInfo, righto.after(rolesInfo)); | |
const result = righto.mate(userInfo, righto.after(logStatus)); | |
result(callback); | |
}; |
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 crel = require('crel'); | |
function fancyCrel(){ | |
var args = Array.prototype.slice.call(arguments); | |
console.log(args); | |
var type = args.shift(); | |
var settings = {}; | |
if(args[0] && typeof args[0] === 'object'){ |
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
function bindContext(object){ | |
return new Proxy({ | |
get: function(target, key){ | |
if(typeof target[key] === 'function' && !target.hasOwnProperty(key)){ | |
return target[key].bind(target); | |
} | |
return target[key]; | |
} | |
}); |
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 crel = require('crel'); | |
crel(document.body, | |
crel('div', | |
crel('h1', 'hello') | |
) | |
); |
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 template = 'just your average string template using {type}', | |
matchToken = /\{(.+?)\}/g; | |
function compile(source){ | |
var positions = {}, | |
fnString = 'return "' + source.replace( | |
matchToken, | |
function(match, key) { | |
return '" + (scope["' + key + '"] || "") + "'; | |
} |
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 json = righto.from(xmltojsonhttpclient.get()), | |
transform = righto.from(SearchModel.get, json), | |
mappedData = righto.from(SearchController.get, transform), | |
contractData = righto.from(ContractModel.get, mappedData), | |
mappedContractData = righto.from(ContractController.get, contractData); | |
mappedContractData(function(error, result){ | |
// Do what you want. | |
}); |
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
// Assumes <Thing>.get is a normal err-back API. | |
var json = righto.from(xmltojsonhttpclient.get()), | |
transform = righto(SearchModel.get, json), | |
mappedData = righto(SearchController.get, transform), | |
contractData = righto(ContractModel.get, mappedData), | |
mappedContractData = righto(ContractController.get, contractData); | |
mappedContractData(function(error, result){ | |
// Do what you want. |
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 matches = righto(getSoccerMatches); // <- Ye Olde error-back | |
var results = righto(getSoccerResults); // <- Ye Olde error-back | |
var detailedMatches = righto.sync(function(matches, results){ | |
return matches.map(function( match ) { | |
return { | |
name: match.name, | |
score: findScoreForMatch(match, results) | |
}; | |
}); |