Skip to content

Instantly share code, notes, and snippets.

View BryanDonovan's full-sized avatar

Bryan Donovan BryanDonovan

View GitHub Profile
@BryanDonovan
BryanDonovan / node-protobuf-install-issue-2
Created September 21, 2015 18:02
node-protobuf install issue with latest NaN module
$ npm i
> node-protobuf@1.2.7 install /Users/bdonovan/code/node/node-protobuf
> node-gyp rebuild
CXX(target) Release/obj.target/protobuf/src/init.o
CXX(target) Release/obj.target/protobuf/src/native.o
../src/native.cpp:11:32: error: use of undeclared identifier 'NanNew'
Local<FunctionTemplate> tpl = NanNew<FunctionTemplate>(New);
^
@BryanDonovan
BryanDonovan / node-protobuf-install-error.txt
Created September 19, 2015 17:46
Error log from attempt at installing node-protobuf with Node.js 4.1.0
bdonovan /tmp $ npm i node-protobuf
|
> node-protobuf@1.2.7 install /private/tmp/node_modules/node-protobuf
> node-gyp rebuild
CXX(target) Release/obj.target/protobuf/src/init.o
In file included from ../src/init.cpp:1:
In file included from ../src/common.h:7:
../node_modules/nan/nan.h:324:27: error: redefinition of 'NanEnsureHandleOrPersistent'
NAN_INLINE v8::Local<T> NanEnsureHandleOrPersistent(const v8::Local<T> &val) {
@BryanDonovan
BryanDonovan / restify_client_proxy_server_test.js
Last active August 29, 2015 14:23
Trying to use restify client with a proxy server
//
// setup:
// npm i restify@3.0.3 request@2.58.0 http-proxy@1.11.1
//
var assert = require('assert');
var http = require("http");
var restify = require('restify');
var request = require('request');
var httpProxy = require('http-proxy');
client = MegaMusic::Client.new(:app_token => 'foo')
client.log_in
client.playlists.get_collection(:user_id => client.user.id)
module MegaMusic
class Client
def initialize(args={})
@app_token = args[:app_token]
# etc.
end
function immediate(cb) {
cb(new Error('immediate'));
}
function err_inside_next_tick(cb) {
process.nextTick(function() {
cb(new Error('next_tick'));
});
}
@BryanDonovan
BryanDonovan / nodejs-mocha-jakefile.js
Last active December 14, 2015 03:39
Example jakefile to run mocha tests
var Mocha = require('mocha');
var mocha = new Mocha({reporter: 'spec', ui: 'bdd'});
function run_tests(cb) {
mocha.addFile('./test/foo.unit.js');
mocha.run(function(failures) {
cb(failures);
});
}
@BryanDonovan
BryanDonovan / gist:1326766
Created October 31, 2011 02:19
jshint-autofix-bug
redis_client.set(key, JSON.stringify(doc), function(redis_err, response) {
});
var url = "/"+user_id+"/likes?access_token="+offline_token;
// the above becomes
// var url = " /"+ user_id + "/likes?access_token ="+ offline_token;
@BryanDonovan
BryanDonovan / nested_test_cases_test.js
Created October 29, 2011 23:21
Failing unit test for nodeunit issue #123
exports.nestedTestCases = function (test) {
var call_order = [];
var s = {
setUp: function (callback) {
call_order.push('setUp');
callback();
},
tearDown: function (callback) {
call_order.push('tearDown');
callback();