Sunday, October 19, 2014

python - PIP : ImportError: cannot import name IncompleteRead

I got the error:

ImportError: cannot import name IncompleteRead

The solution was reinstalling pip:

sudo easy_install freeze
sudo apt-get remove python-pip
sudo apt-get autoremove
wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py --no-check-certificate
sudo python get-pip.py

Resource:

http://suanfazu.com/discussion/140/pip-install-importerror-cannot-import-name-incompleteread/p1

Angular js: re render directive dinamycally

Here is a great and simple example of how is done:

http://jsfiddle.net/7Waxv/2/

Tuesday, October 7, 2014

Share data among controllers

Use $ rootScope

var app = angular.module('mymodule',[]);
app.controller('Ctrl1', ['$scope','$rootScope',
  function($scope, $rootScope) {
    $rootScope.showBanner = true;
}]);

app.controller('Ctrl2', ['$scope','$rootScope',
  function($scope, $rootScope) {
    $rootScope.showBanner = false;
}]);

Source:
http://stackoverflow.com/questions/20181323/passing-data-between-controllers-in-angular-js



Monday, September 29, 2014

Python nested classes json encoder


Json pickle will do the trick : http://jsonpickle.github.io/

## import lib
import jsonpickle

## create class
class Thing(object):
    def __init__(self, name):
        self.name = name

## create class instance
obj = Thing('Awesome')

## from obj to json string
frozen = jsonpickle.encode(obj)

## from json string to obj
thawed = jsonpickle.decode(frozen)

Thursday, August 21, 2014

Goddady wildcard subdomain url call handling

If I type in the browser www.jhonjairoroa87.com, the blog is shown. But when I type test.jhonjairoroa87.com, there was no page loaded. So iI wabnted to enable the routing from anysubdomain.jhonjairoroa.com to this blog.

So, the solution was:

Go to GoDaddy's DNS Manager, the first table on top should say A(Host), click the button under that first table that says Quick Add. In the first text field, enter an asterisk (*), in the second one, the IP address to redirect to (the same one you have for the @ record on top). Click "Save Zone File" on top-right and confirm.

This creates a catch-all record to anysub.yourdomain.com.

Reference: 

Friday, August 1, 2014

RequireJS: Uncaught Error: Module name "underscore" has not been loaded yet for context: _. Use require([])

I was getting the error

Uncaught Error: Module name "underscore" has not been loaded yet for context: _. Use require([])

Solved it adding the shim values in the require js config:

require.config({
    paths:{
        jquery:'jquery/jquery-min',
        underscore:'underscore/underscore-min',
        backbone:'backbone/backbone-min'
    }, 
    // here
    shim: {
        underscore: {
            exports: '_'
        },
        backbone: {
            deps: ["underscore", "jquery"],
            exports: "Backbone"
        },
        waitSeconds: 15
    }
});

Source: http://stackoverflow.com/questions/16774214/trouble-combining-require-js-and-backbone-js-underscore-js