Skip to content

Instantly share code, notes, and snippets.

View petrjoachim's full-sized avatar
🦆
Getting ducks in a row

Petr Joachim petrjoachim

🦆
Getting ducks in a row
View GitHub Profile
@zdychacek
zdychacek / proxy.js
Last active November 11, 2016 11:19
Proxy for remote method calls
// require Proxy API normalization polyfill because current V8's implementation doesn't support standardized API
const Reflect = require('harmony-reflect');
function createProxy (action) {
// create the callable proxy
function _createCallableProxy (name) {
const methodNames = [ name ];
return new Proxy(function () {}, {
@hajovsky
hajovsky / gist:9778146
Created March 26, 2014 07:12
how to thunkify the mongodb native
// npm install mongodb thunkify-wrap co
var mongo = require('mongodb');
var t = require('thunkify-wrap');
var co = require('co');
co(function*(){
var db = yield t(mongo.MongoClient.connect)('mongodb://127.0.0.1:27017/test');
var items = db.collection('items');
// cleanup