Hi, my name is Jhon Jario Roa and this is my blog. Here you'll find a little bit of java, python, javascript, linux, birt, jasper, objective C, extJS and other stuff. You also are gonna find some solutions that worked for me.
Sunday, October 19, 2014
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
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
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
Tuesday, July 15, 2014
.Net ReportViewer datetime format problem am/pm
I was having troubles formating a datetime parameter with am/pm. No matter the formatting, it was always missing the am/pm .
- The expression was Parameters!initDate.Value and I got 2014/01/07 12:00:00
I also tried
-Format(Parameters!initDate.Value,"yyyy/MM/dd hh:mm:ss tt") and I got 2014/01/07 12:00:00
and so on....
So I decided to use an if to evaluate the hour and manually set the am/pm:
=Format(Parameters!initDate.Value,"yyyy/MM/dd hh:mm:ss ") + IIf(Parameters!initDate.Value.Hour > 11, "pm", "am")
- The expression was Parameters!initDate.Value and I got 2014/01/07 12:00:00
I also tried
-Format(Parameters!initDate.Value,"yyyy/MM/dd hh:mm:ss tt") and I got 2014/01/07 12:00:00
and so on....
So I decided to use an if to evaluate the hour and manually set the am/pm:
=Format(Parameters!initDate.Value,"yyyy/MM/dd hh:mm:ss ") + IIf(Parameters!initDate.Value.Hour > 11, "pm", "am")
Tuesday, June 10, 2014
Python: install pip and Flask on windows 8
Install pip:
> python get-pip.py
Install Flask:
> python -m pip install Flask
Resource:
http://pip.readthedocs.org/en/latest/installing.html
> python get-pip.py
Install Flask:
> python -m pip install Flask
Resource:
http://pip.readthedocs.org/en/latest/installing.html
Subscribe to:
Posts (Atom)