Skip to content

Instantly share code, notes, and snippets.

View sebinsua's full-sized avatar
🐚

Seb Insua sebinsua

🐚
View GitHub Profile
@sebinsua
sebinsua / broken-test.js
Created December 24, 2013 17:00
Mocha will not detect AssertionError exceptions inside a dependency mocked out using proxyquire when executing a middleware on an express app with supertest.
var express = require('express'),
request = require('supertest'),
expect = require('chai').expect,
proxyquire = require('proxyquire');
var someplaceElsewhere = {
configure: function () {
return {
callsThis: undefined,
aMethod: function (query) {
@sebinsua
sebinsua / gist:8118001
Last active January 1, 2016 08:28
Not able to a catch AssertionError's from within an app wrapped by supertest
var express = require('express'),
request = require('supertest'),
sinon = require('sinon'),
expect = require('chai').expect;
var AssertionError = require("assert").AssertionError;
var throwAssertionErrorAndRespond = function (req, res) {
throw new AssertionError({ message: "[2] Mocha should see this." });
res.send('{ "success": true }');
@sebinsua
sebinsua / gist:8549914
Created January 21, 2014 22:37
Problem with scoping
// I cannot change this object.
var normalResponseObject = {
send: function (status, data) {
alert("This was executed.");
}
};
var aScope = function () {
var reaction, status;
@sebinsua
sebinsua / gist:8549923
Created January 21, 2014 22:38
Solution to scoping problem
// I cannot change this object.
var normalResponseObject = {
send: function (status, data) {
alert("This was executed.");
}
};
var generateProxiedResponseSender = function (res) {
var oldSend = res.send;
var context = this;
@sebinsua
sebinsua / keybase.md
Created October 8, 2014 12:02
keybase.md

Keybase proof

I hereby claim:

  • I am sebinsua on github.
  • I am sebinsua (https://keybase.io/sebinsua) on keybase.
  • I have a public key whose fingerprint is B9FD 6FC2 115A A22C 9FE6 24C3 3EB6 34BB A9A9 5787

To claim this, I am signing this object:

Verifying that +sebinsua is my openname (Bitcoin username). https://onename.io/sebinsua
@sebinsua
sebinsua / ramda-with-bluebird.js
Last active August 29, 2015 14:14
Use of Ramda with Bluebird
var Q = require('bluebird'),
R = require('ramda');
var shouldError = false;
var a = function (arg) {
return new Q.Promise(function (resolve, reject) {
resolve("[a] resolved");
});
};
@sebinsua
sebinsua / async.js
Created April 27, 2015 14:05
Testing Babel async styles in Node v0.10.29
import Promise from 'bluebird';
async function bar(message) {
const newMessage = await new Promise(function (resolve, reject) {
console.log(message);
resolve(`${message} printed`);
});
return newMessage;
}
As for jstruct itself:
- [ ] [Implement this as another kind of pluggable selector.](https://github.com/sebinsua/jstruct/blob/master/jstruct.js#L10)
- [ ] [Add error validations back in.](https://github.com/sebinsua/jstruct/blob/master/jstruct.js#L69)
- [ ] [Implement a deep/recursive cross between this, reduce and struct#deepPick.](https://github.com/sebinsua/jstruct/blob/master/jstruct.js#L121)
* clean readme.
Write es6 example.
---
* integrate into jstruct
@sebinsua
sebinsua / PACKAGE_EXPORTS.md
Last active November 29, 2017 11:14
Description of package exports.
Build Consumer Description Key in package.json
CommonJS
(main version)
Node/bundlers Transpiled and contains require and module.exports. main
ES module Modern browsers/bundlers Transpiled apart from import and export statements. module
UMD Old browsers Transpiled, minified, containing IIFE's and has all dependencies baked-in. browser