General purpose

Be creative, be concrete



Notes on Dojo: How to create a Data Store

The Dojo Framework logoTested on: Dojo 1.7.2

To create a Data Store first of all we have to fetch data from a source. For example, we can have a JSON file that contains data about books. The structure of the JSON file called bibliography.json is shown below.

[
  {
    "ID"        : 1,
    "Title"     : "Book 1 Title",
    "Publisher" : "Book 1 Publisher",
    "City"      : "Book 1 City",
    "Authors"   : "Author 1, Author 2",
    "Year"      : "2001"
  },
  ...
]

To load this data we can use the Dojo XHR functionalities. Once data are fetched, we are able to create the store using, for instance, in memory data.

require(
  [
    "dojo",
    "dojo/store/Memory"
  ],
  function(dojo, MemoryStore){
    var store = null;

    var fetchData = dojo.xhrGet({ // returns a deferred object
      url: "bibliography.json",
      handleAs: "json",
      error: function(error){
      console.error("Something goes wrong: " + error.message);
      }
    });
    
    fetchData.then(function(data){
      store = new MemoryStore({data: data, idProperty: "ID"});
      
      console.log(store); // print on console the store object
      
      // query the store
      var result = store.query({"Title": "Book 1 Title"});
      console.log(result);
    });
  }
);

If all goes well, we will see on the console the retrieved information and the result of the query.

References

DjangoDay 2012, Brescia: slides

Yestarday in Brescia, the WEBdeBS association organized the DjangoDay, the first event in Italy dedicated to the Django Framework.

Below you can find my slides about Django and Rapid Application Prototyping.

It was a great conference, with great speakers and nice people. Thanks to Cristiano, Valeria, Sam, Szilveszter, Aymeric, Vittorio, Alessandro, Denis, Paolo, WEBdeBS, the DjangoDay staff and all people with whom I chatted but unfortunately I forgot names (sorry :-P).

MethodCamp 2012

Yesterday I attended the MethodCamp 2012 organized by Sketchin. I contributed to the discussion with a talk about wireframes inspired by a post published on ZURBlog and some personal studies and work experiences carried on in the last 3 years.

Thank you to all for the nice day and the interesting discussion. See you next year!

How to update Facebook, Twitter and Linkedin from Google+

Nowadays, social networks are good places to promote more or less everything. When I publish a new post on my blog I used to share the link on Google+, Facebook, Linkedin and Twitter.

Personally, I’m lazy and I don’t want to waste time updating each social network in order to advertise my new posts. At the moment, Google+ is my favorite social platform and I wish to publish a post on it and that the other social networks have updated automatically.

On the web I looked for a solution and after some attempts I found a service that solves my problem. ManageFlitter is a web application that enables to publish Google+ posts on Twitter. In addition, ManageFlitter offers a lot of interesting tools to manage a Twitter account.

Once we subscribed the service, we have to add the Twitter to Facebook app to our Facebook account and set the Twitter account in our Linkedin settings page.

Some suggestions

When we create a new post on Google+, we have add a description that is suitable for Twitter. Feel free to use hashtags etc. Create a post on Google+ In this way we create a post that is coherent with Facebook, Linkedin and of course Twitter. How our post appears on Facebook, Linkedin and Twitter.