Skip to content

Instantly share code, notes, and snippets.

Avatar
🐚

Seb Insua sebinsua

🐚
View GitHub Profile
@sebinsua
sebinsua / broken-test.js
Created Dec 24, 2013
Mocha will not detect AssertionError exceptions inside a dependency mocked out using proxyquire when executing a middleware on an express app with supertest.
View broken-test.js
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 Jan 1, 2016
Not able to a catch AssertionError's from within an app wrapped by supertest
View gist:8118001
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 Jan 21, 2014
Problem with scoping
View gist:8549914
// 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 Jan 21, 2014
Solution to scoping problem
View gist:8549923
// 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;
View 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:

View gist:69ce74a0d0b548a7e05f
Verifying that +sebinsua is my openname (Bitcoin username). https://onename.io/sebinsua
@sebinsua
sebinsua / ramda-with-bluebird.js
Last active Aug 29, 2015
Use of Ramda with Bluebird
View ramda-with-bluebird.js
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 Apr 27, 2015
Testing Babel async styles in Node v0.10.29
View async.js
import Promise from 'bluebird';
async function bar(message) {
const newMessage = await new Promise(function (resolve, reject) {
console.log(message);
resolve(`${message} printed`);
});
return newMessage;
}
View TODO
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 Nov 29, 2017
Description of package exports.
View PACKAGE_EXPORTS.md
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