Skip to content

Instantly share code, notes, and snippets.

View cdhowie's full-sized avatar

Chris Howie cdhowie

View GitHub Profile
@cdhowie
cdhowie / promise-node-shim.js
Created April 13, 2017 13:53
Simple shim for promise-nodecb interop without requiring a full-blown promise library. (Useful as a boilerplate for AWS Lambda functions.)
Promise.fromCallback = fn =>
new Promise((r, j) => {
fn((err, result) => err ? j(err) : r(result));
});
Promise.prototype.nodeify = function (cb) {
cb && this.then(r => cb(null, r), cb);
return cb ? undefined : this;
};
#ifndef OPTIONAL_HPP
#define OPTIONAL_HPP
#include <utility>
namespace gamesolver {
template <typename T>
class optional {
public: