Tuesday, August 13, 2013

Wednesday, July 17, 2013

Upgrading to JRuby | Neo4J | rvm on Ubuntu



While upgrading the Wikibrains server I encountered a few snags, I had to bypass these issues by following these steps:
Purging the RVM/Ruby installations: (source)
sudo apt-get --purge remove ruby-rvm
sudo rm -rf /usr/share/ruby-rvm /etc/rvmrc /etc/profile.d/rvm.sh
open new terminal and validate environment is clean from old RVM settings (should be no output):
env | grep rvm
if there was output, try to open new terminal, if it does not help then restart your computer.
\curl -L https://get.rvm.io | 
  bash -s stable --ruby --autolibs=enable --auto-dotfiles

Then Run:

source /usr/local/rvm/scripts/rvm

Now proceed to installing rails:

gem install rails --version '= 0.3.8'
gem install bundler

creating the application with neo4j.rb:
rails _3.2.8_ new myapp -m http://andreasronge.github.com/neo4j/rails.rb -O
note: at the time of this post, there is a conflict between Neo4j.rb and rails 4 dependencies.

Monday, June 24, 2013

Manipulating server data in an Angular controller

I was experiencing an annoying problem every time I was trying to access data I would get back from the server in an Angular.JS controller.
 
As it turns out, every time I shorthanded and wrote something in the essence of:
$scope.myData = Service.getMyData();
It returns a proxy object that the angular view was able to handle though model binding,  but the controller can't and accessing fields of the returned object would return as undefined.

So, the solution is as simple as it it stupid (Also see angular reference):
By passing a function to the service that would catch the returning data, and do the magic there, the returning object is the data itself and not a proxy.
the shorthand should be replaced with:
Service.getMyData({}, function(d){
      $scope.myData= d;
});

In my implementation I often broadcast an event of my own after the data has returned so other controllers that are dependent on this data my react accordingly:

Service.getMyData({}, function(d){
      $scope.myData= d; 
      Context.broadcast("theDataIsReady");//shaking the $rootScope tree
}); 
 
...
 
$scope.$on("theDataIsReady",function(){
     
// a very clever snippet of code
  }); 

Special thanks to Ravit.

Saturday, June 8, 2013

Angular.js JSONP with Rails

A couple of snippets to remind myself on how to JSONP angular and rails. (cross domain Ajaxing)



- -

Wednesday, June 5, 2013

App Context for Angular.JS

I'm now deep into converting the Wikibrains client application to the Angular.js Javascript infrastructure.
One of the most basic tools I needed was an application wide context to shift around data and events between controllers.

This is what I came up with:

Thursday, April 11, 2013

Javascript Visualization Toolkits

As part of my search for a nice visualization scheme for my projects, I've stumbled upon to consecutive libraries that are manages by the same team of people (owned by Mike Bostock).

The first one is the Protovis library that is no longer under active development, but does have a very nice feature set.

The same team went on to develop a new visualization library called D3.js available on Github.



A simpler set of visualization tools can be found at the flot JQuery plugin. These are mostly linear charts with limited animation, but very useful for most cases of visualization requirements.











In case something really fancy, 3D with a touch of gravity is required, there is always Mr. doob with an assortment of amazing webGL stuff. My personal favorite being the Ball Pool.