Tuesday, March 26, 2013

Undo delete with AngularJS

An example of how to develop "undo row deleted" functionality using AngularJS and ng-grid.

At last, with angularjs, you can write code that even backend developers can learn to appreciate and love ;)

Monday, January 28, 2013

AngularJS rocks

Great, so now I needed to build a web GUI using pure JavaScript. What to do? There are plenty of frameworks to help you out there, among the most popular: Knockout, Batman, Backbone and Angular.

I looked around and settled for AngularJS after reading http://blog.omkarpatil.com/2012/11/selecting-javascript-web-framework.html

So here's a small but completely functional application written using Angular and Twitter bootstrap. In less that 70 lines of code I managed to access LastFM's APIs and show the list of top artists by country returned from the service. From there we can navigate to see the top albums for each artist and the top tracks. Can you do that as easily with other frameworks? Maybe, but doing it with Angular was easy and fun. I really recommend AngularJS to anyone looking to develop a web based interface.

So what does the code look like?

In angular you start off defining your modules, some factories or/and services and configuring which URLs will trigger which controllers. You also define which templates will be used when a controller is triggered.

Angular provides nice AJAX abstraction in the form of a $resource service that provides means to interact with RESTful server-side data sources. And now for the controllers:

As you can see each controller has its scope and you just inject the resources/factories/services that you have defined previously. This DI has the nice side-effect that it makes your code easy to test. Angular comes with some pretty serious testing facilities so now you can easily unit test your javascript code!

As usual here's the app in action on Heroku and the whole source code.

Sunday, January 6, 2013


Neoflix is an example app using the Neovigator visualization. It uses the Movie Lens dataset and the work of Marko Rodriguez as shown on his blog entry "A Graph-Based Movie Recommender Engine" with some tweaks as shown in this post.

I ported the work of Max de Marzi using Neo4j and Neography shown in the above post series from Ruby to Groovy and JAX-RS. You can see the code here and the live application on the Heroku site.

My version is querying Neo4j using Cypher which is currently slower than Gremlin which is the query DSL used in De Marzi's example. In the next major release of Neo4j query times will likely be much faster.