How the JavaScript heatmap implementation works?

A heatmap is a powerful way to visualise data. Given a matrix of data each value is represented by a color. The implementation of the heatmap algorithm is expensive in computation terms: for each grid’s pixel you need to compute its colour from a set of known values. As you can thing, it is not feasible to be implement it on the ...

Read More »

Testing Network Errors With MongoDB

Someone asked on Twitter today for a way to trigger a connection failure between MongoDB and the client. This would be terribly useful when you’re testing your application’s handling of network hiccups. You have options: you could use mongobridge to proxy between the client and the server, and at just the right moment, kill mongobridge. Or you could use packet-filtering ...

Read More »

JavaScript String Split Example

When building or maintaining an interactive website, it may happen that the input you get from the user can be correct in meaning, but written as a long string separated by special characters such as commas or semicolons. In these cases, JavaScript string split functions come to the rescue. You can split the long string into small ones and save ...

Read More »

Learning Angular: Unit Testing watch expressions

Today I wanted to write a unit test for a watch expression on my controller. What seemed quite obvious initially, turned out to be quite nasty. Anyway, thx to a nice community member on the Angular IRC, I was able to quickly resolve the issue. So, here’s the story.   This article is part of my “Learning NG” series, presenting ...

Read More »

Promises you can trust

JavaScript Promises provide a strong programming model for the future of JavaScript development. So here I’m playing with promises. First I need a bit of a package.json file:           Now I can write my first test (test/promises_test.js): Notice that the “it” function takes a “done” function parameter to ensure that the test waits until the promise ...

Read More »

Many Web.config have merged together

You can have more than one Web.config in an application and they will all be merged in the end, which is fine. Also, if you have a problem with the configuration for a given project it will usually show up in your development environment right away and will not make it to production. But here is a problem that occurred ...

Read More »

JavaScript String Contains Example

Usually, programming languages have a special preprocessed function to find a substring of a string. But what happens when you language of choice doesn’t have one? Well the answer to that is: You make one! How exactly do you write such function in JavaScript, we are going to show you below.               Does a ...

Read More »

Avoid test code duplication in Jasmine tests

Test code has to be treated like production code. Obviously we cannot charge the customer for it, it’s something that helps us developers to make sure we keep our codebase healthy, which ultimately is the responsibility we have towards our customers. Thus we need to apply the same best practices principles as we do for our production code, where, code ...

Read More »

Watch file changes and propagate errors with Gulp

Gulp fever infected me. Streaming model is very interesting and modern. After initial excitement, I started to experience first pitfalls. This is understandable for such young project. I am going to describe my problem with watching file changes and propagating errors. Error in Gulp by default breaks the pipe, terminates the build/test and whole Gulp process with some error code. ...

Read More »