@remosu and I have been working during the last months in another pet project: backmongo.
backmongo is a simple REST interface for MongoDB written in Python that can be used straight away from a Backbone application.
We plan to use it in our next backbone pet projects, so we'll add new features as we need them.
Record of experiments, readings, links, videos and other things that I find on the long road.
Registro de experimentos, lecturas, links, vídeos y otras cosas que voy encontrando en el largo camino.
Monday, July 23, 2012
Monday, July 16, 2012
Articles and Posts read
Learning and Software Craftsmanship
Don’t Offload Your Memory Quite Yet: Cognitive Science, Memory, and Education
How do you know when someone is great?
TestPyramid
TDD Problems
CustomerAffinity
Limits of performance optimization
The Old Is New Again
Three Strikes And You Refactor
Back to the Basics of Functional Programming
Programming Breaks Things
C++
Relentless Assault
New Native Languages
Go
gocheck: Rich testing for Go
Python
Python as a Lisp dialect
Entrepreneurship and Management
#weareatwar
Precariedad, empleo y competitividad
Wake Up Call – If You Spend It, They Will Come
Rappers And Cabbies
8 consejos sobre cómo emprender a los que no he hecho caso
Numerical Stuff
The pitfalls of verifying floating-point computations
Science
Secret Computer Code Threatens Science
El cambio climático y los modelos de simulación por ordenador
El misterio del huevo en rotación y la fuente de leche
Fooling the masses with performance results on parallel computers – prelude
Spain and Europe
La silenciosa expansión del 15-M
Hacer el ridículo no inspira confianza
Don’t Offload Your Memory Quite Yet: Cognitive Science, Memory, and Education
How do you know when someone is great?
TestPyramid
TDD Problems
CustomerAffinity
Limits of performance optimization
The Old Is New Again
Three Strikes And You Refactor
Back to the Basics of Functional Programming
Programming Breaks Things
C++
Relentless Assault
New Native Languages
Go
gocheck: Rich testing for Go
Python
Python as a Lisp dialect
Entrepreneurship and Management
#weareatwar
Precariedad, empleo y competitividad
Wake Up Call – If You Spend It, They Will Come
Rappers And Cabbies
8 consejos sobre cómo emprender a los que no he hecho caso
Numerical Stuff
The pitfalls of verifying floating-point computations
Science
Secret Computer Code Threatens Science
El cambio climático y los modelos de simulación por ordenador
El misterio del huevo en rotación y la fuente de leche
Fooling the masses with performance results on parallel computers – prelude
Spain and Europe
La silenciosa expansión del 15-M
Hacer el ridículo no inspira confianza
Sunday, July 15, 2012
Last Pet Project: Event-Driven Molecular Dynamics
During the last week @remosu and I have been pair-programming a pet project: edmd.
It is a Python implementation of a simple Event-Driven Molecular Dynamics algorithm described in the Event-Driven Molecular Dynamics chapter of the book Computational Granular Dynamics: Models and Algorithms by Thorsten Pöschel and Thomas Schwager.
We plan to revisit edmd in the future to optimize the event-updating phase by using a cell list.
It is a Python implementation of a simple Event-Driven Molecular Dynamics algorithm described in the Event-Driven Molecular Dynamics chapter of the book Computational Granular Dynamics: Models and Algorithms by Thorsten Pöschel and Thomas Schwager.
We plan to revisit edmd in the future to optimize the event-updating phase by using a cell list.
Saturday, July 14, 2012
Articles and Posts read
Learning and Software Craftsmanship
12 Dozen Places To Educate Yourself Online For Free
VIM adventures
Celebrate Learning, Not Success or Failure
Leer y aprehender
Do What Works, Not What’s Satisfying: Pseudo-Striving and our Fear of Reality-Based Planning
Design Patterns in Dynamic Languages
What BDD has taught me
Programmers are Trees
Can You Be Your Own Producer?
Agile and Lean
Post-Agile and Pliant Software – The Emperor’s New Agile
Post-Agile?
C++
The “Void Star” Crowd
A collection of design patterns in C++
Haskell
A Haskell bookshelf
Go
Network programming with Go
Entrepreneurship and Management
España no es Silicon Valley, pero ...
El sesgo cognitivo del emprendedor
More Bureaucratic Than A Bureau
Numerical stuff
Project of the Month: Cojac, A Numerical Problem Sniffer
Science
Some brief responses to the Sage Bionetworks Congress
Así sufre la ciencia el peor hachazo
El cuello de botella de la ciencia
Porque #sinCiencia básica no hay progreso
#SinCiencia sólo queda el caos
Spain and Europe
Los bajos salarios en Alemania: una especialidad del terror
La ‘marca España’ cotiza a la baja en el mundo
Peor que en la crisis de los 80: 3 millones, 15% de empleos destruidos
12 Dozen Places To Educate Yourself Online For Free
VIM adventures
Celebrate Learning, Not Success or Failure
Leer y aprehender
Do What Works, Not What’s Satisfying: Pseudo-Striving and our Fear of Reality-Based Planning
Design Patterns in Dynamic Languages
What BDD has taught me
Programmers are Trees
Can You Be Your Own Producer?
Agile and Lean
Post-Agile and Pliant Software – The Emperor’s New Agile
Post-Agile?
C++
The “Void Star” Crowd
A collection of design patterns in C++
Haskell
A Haskell bookshelf
Go
Network programming with Go
Entrepreneurship and Management
España no es Silicon Valley, pero ...
El sesgo cognitivo del emprendedor
More Bureaucratic Than A Bureau
Numerical stuff
Project of the Month: Cojac, A Numerical Problem Sniffer
Science
Some brief responses to the Sage Bionetworks Congress
Así sufre la ciencia el peor hachazo
El cuello de botella de la ciencia
Porque #sinCiencia básica no hay progreso
#SinCiencia sólo queda el caos
Spain and Europe
Los bajos salarios en Alemania: una especialidad del terror
La ‘marca España’ cotiza a la baja en el mundo
Peor que en la crisis de los 80: 3 millones, 15% de empleos destruidos
Thursday, June 7, 2012
Avoiding XMLHTTPRequest problem using jQuery on Node.js
We are using Mocha to test a Backbone application on node.
We decided to change from Jasmine to Mocha because we prefer how it handles asynchronous calls using done callback. The other thing we like from Mocha is the possibility of running tests on node. Since a big part of our code did not depend on the DOM, this freed us from having to configure a html file just to load ours tests.
We have a development server running flask at http://localhost:5000 that exposes a REST API for our backbone models. When we were running our tests on a browser, we needed to had a static html file served by flask which had to be configured in order to load all the libraries required to run our tests.
When we started running the tests on node, that html file wasn't needed anymore, but we had to change the backbone collections url from relative to absolute and use require to load the libraries.
This is how our tests looked like:
We were wrong, because we started to get this other error message:
They recommended using the node-XMLHttpRequest node module which is
We decided to change from Jasmine to Mocha because we prefer how it handles asynchronous calls using done callback. The other thing we like from Mocha is the possibility of running tests on node. Since a big part of our code did not depend on the DOM, this freed us from having to configure a html file just to load ours tests.
We have a development server running flask at http://localhost:5000 that exposes a REST API for our backbone models. When we were running our tests on a browser, we needed to had a static html file served by flask which had to be configured in order to load all the libraries required to run our tests.
When we started running the tests on node, that html file wasn't needed anymore, but we had to change the backbone collections url from relative to absolute and use require to load the libraries.
This is how our tests looked like:
var assert = require('assert');
var should = require('should');
var jQuery = require("jquery");
var Backbone = require('backbone');
Backbone.setDomLibrary(jQuery);
var BMModel = Backbone.Model.extend({
idAttribute: "_id"
});
var BMCollection = Backbone.Collection.extend({
model: BMModel,
url : "nn"
});
describe("banana", function(){
describe("read all", function(){
var bmcollection;
var expected;
beforeEach(function(done){
bmcollection = new BMCollection();
bmcollection.url = 'http://localhost:5000/collection_tests/';
bmcollection.fetch({success: function(){
done();
}});
});
it("gets contents from banana", function(){
bmcollection.models.should.have.lengthOf(2);
});
But we were getting an unexpected error with the following message:
No Transport.This was happening because jQuery, by default, does domain detection. We turned this off by setting:
jQuery.support.cors = true;Since the tests weren't running in a browser, we thought that this was enough to get rid of of the same origin trap.
We were wrong, because we started to get this other error message:
Object #After some googling we found someone seeking help at stackoverflow to solve the same problem.has no method 'open'
They recommended using the node-XMLHttpRequest node module which is
a wrapper for the built-in http client to emulate the browser XMLHttpRequest object.We installed it by doing:
This can be used with JS designed for browsers to improve reuse of code and allow the use of existing libraries.
npm install xmlhttprequestThen in the tests code we just had to add:
var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
jQuery.support.cors = true;
jQuery.ajaxSettings.xhr = function () {
return new XMLHttpRequest;
}
and our tests started to run.
Subscribe to:
Posts (Atom)