Wednesday, 14 May 2014

How to use Ionic framework with Ripple web browser based emulator

http://ripple.incubator.apache.org/
droid gang
droid gang (Photo credit: valanzola.t)
First prepare Android platform:

ionic platform add android ionic build android 

Install Ripple emulator with node.js NPM.

npm install -g ripple-emulator 

and run it:

ripple emulate --path platforms/android/assets/www


Last step can be also used in ordinary PhoneGap / Cordova project.

Links:
- Ionic Framework


Enhanced by Zemanta

Thursday, 1 May 2014

Backbone model sample (javascript)

Following sample script demonstrates all Backbone.js libraray model related functions:
  • attributes
    • setting default values
    • getting list of attributes
  • constructor
  • validation 
  • methods
  • converting to JSON

Person = Backbone.Model.extend({
// default values of attributes
defaults:{
age:0,
children: []
},
// validation
validate: function(attributes){
if(attributes.age<0){
console.log("Validation error, person can't be negative age!");
return "person can't be negative age";
}
},
// constructor method
initialize: function(){
console.log("New person was born");
this.bind("error",function(model,error){
console.log("ERROR:"+model);
});
// Listen to attribute changes (using bind)
this.bind("change:name", function(){
var currentName=this.get("name");
console.log("Name changed from "+currentName + " to " + name);
});
},
// custom methods
adopt: function(newChildsName){
var childrenArraya=this.get("children");
childrenArraya.push(newChildsName);
this.set({"children": childrenArraya});
},
replaceNameAttr: function(name){
this.set({name: name});
}
});
var person = new Person();
person.set({name: "John", lastName:"Dove", children: ["First","Second"]});
person.adopt("Tara");
// validation is only run on save method or by turning on validate option on set method (since Backbone 0.9.10)
person.set("age", -5 , {validate : true});
this.person.save({age: -10});
console.log("Hi, "+person.get("name")+" and "+person.get("children"));
person.replaceNameAttr("Johny");
// person.set({name: "Milan"});
// convert to JSON
console.log(person.toJSON());
// show all attributes
console.log(person.attributes);

Additional resources:

Friday, 25 April 2014

Chocolatey is incompatible with version 2.1.31022.9038 - How to update nuget client in Chocolatey

I become a big fun of Chocolatey lately! :) While installing some tools I received following error:


Chocolatey (v0.9.8.20) is installing wget and dependencies. By installing you accept the license for wget and each dependency you are installing.

The schema version of 'Microsoft.AspNet.Mvc' is incompatible with version 2.1.31022.9038 of NuGet.

Please upgrade NuGet to the latest version from http://go.microsoft.com/fwlink/?LinkId=213942.


Sollution:

cd C:\Chocolatey\chocolateyinstall
nuget update -Self
And it should work!

C:\cd C:\Chocolatey\chocolateyInstall
C:\Chocolatey\chocolateyinstall>nuget.exe update -self
Checking for updates from https://nuget.org/api/v2/.
Currently running NuGet.exe 2.1.0.
Updating NuGet.exe to 2.8.2-beta.
Update successful.