Gonzalo Ayuso | Web Architect

September 9, 2009

Soy rico

Filed under: Uncategorized — gonzaloayuso @ 10:22 am

Lunes 7:00. Suena el despertador. Normalmente cuando suena el despertador es el peor momento del día. Hoy encima me ha sentado especialmente mal (lunes, vacaciones recientes, …). Llego a la oficina, miro el correo y me encuentro con esto:

Hello,

I am Kun Chun, a legal practitioner. A defunct client of mine, that bears the same last name as yours, passed away due a heart-related condition on January 12th 2005. His heart condition was as a result of the death of all the members of his kinsfolk in the tsunami disaster on the 26th December 2004 in Sumatra Indonesia.

I am contacting you to seek your consent to present you as a successor to my late client, who has a deposit of $19million. This will be executed under a legal arrangement that will protect you against any legal ramification. If this business proposition offends your moral values, do accept my apology.

I can be reached on: xxx@xxx.xx

Best regards,

Kun Chun

Pues eso: un pobre hombre se muere en el tsunami de Sumatra en el 2004. Ese pobre hombre (descanse en paz) se apellidaba igual que yo (mira tu que casualidad) por lo que paso a ser su sucesor heredando una fortuna de 19 millones de dólares (ole). Y yo sin saberlo. Menos mal que Kun Chun se ha percatado de ello y me lo hace saber mandandome un email.

Internet es genial. Hoy he ganado 19 millones de dólares sin hacer nada. Entiendo que al amigo Kun tendré que pagarle algo pero pida lo que pida se lo merecerá. Menos mal que este correo ha pasado el filtro antispam porque de otra manera no me habría enterado.

July 30, 2009

antivirus

Filed under: personal — gonzaloayuso @ 7:12 pm

Acabo de recibir un correo con propaganda de un antivirus. Es una lástima que no use antivirus porque el producto tiene una pinta buenísima. Literal copiado del correo:

Máxima eficacia del mercado en detección de virus (99,65%).

Una eficacia ni mas ni menos del 99,65%. Nada del 99% ni de un mísero 99,5%. Me ofrece un 99,65%. No se como se calcula ese porcentaje pero tiene muy buena pinta. Hombre mejor seía un 99,73% o un 99,82% pero la verdad es que un 99,65% esta muy bien.

Ademas me dicen que el producto esta:

Basado en la tecnología del líder en detección de virus de [nombreDelAntivirus] Lab.

Es de agradecer. Parce que tienen un laboratorio dentro del cual tienen varias personas y me ofrecen la tecnología del lider de ellos. Nada del mas pardillo ni mas ni menos que del lider.

Y lo que mas me ha asombrado:

Escaneo continuo de e-mails y del tráfico de Internet.

Con un par. Escaneo continuo de todo el tráfico de internet.

En fín, es una pena que no use esos productos porque si no este antivirus seria mi primera opción. Estoy seguro casi al 99,65% de ello.

May 8, 2009

Server side web frameworks are dead

Filed under: Web Development — gonzaloayuso @ 7:35 pm

Server side web frameworks are dead. Long life to client side web frameworks. Struts, JSF, Spring, Ruby on Rails, Cake, Symfony … (even my framework in PHP ;) ) as full stack web framework are dead. Logic is moving to the client side. Javascript, the language used as deadly weapon in the browser wars nowadays is the key of the web. Server logic is getting thin. A thin server side framework serving JSON (Zend Framework is really cool for this) plus a good and strong client side framework such as Dojo or ExtJs with a good widget set with all the application logic can be the new parading of web develop.

A must-see speech about web tendencies about this idea:

April 18, 2009

mixin dojo and google api libraries

Filed under: Technology, Web Development, dojo — gonzaloayuso @ 1:39 pm

I’m working in a dojo application and I also need to use some goolge api like feeds, maps and books. Dojo is very versatile adding new components using dojo.require. when all dojo components are loaded dojo.addOnLoad callback is fired.

dojo.require("dojo.io.script");
dojo.require("dojo.data.ItemFileReadStore");
dojo.addOnLoad(function(){
    console.log('all is ready');
});

dojo.require is great. It also alloy us to create nested onLoad callbacks

dojo.require("dojo.io.script");
dojo.require("dojo.data.ItemFileReadStore");

dojo.addOnLoad(function(){  // <------------
    console.log('all is ready1');
    dojo.require("dijit.TitlePane");
    dojo.require("dijit.Dialog");

    dojo.addOnLoad(function(){ // <------------
        console.log('all is ready 2');
     });
});

google API uses his own loader google.load.

google.load("jquery", "1.3.2");
google.load("feeds", "1");
google.setOnLoadCallback(function() {
    console.log('all is ready');
});

If your application uses both libraries you must take care about onLoad callback of dojo and google because they are not the same.
You can create your own dojo widget for loading google api and forget google.setOnLoadCallback but I want to use libraries as standard as I can (without hacking code every time I have a problem). So I prefer to live with both callbacks.

You can try to do something like this:

google.load("dojo", "1.3");
google.load("feeds", "1");

dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.TabContainer");
dojo.require("dijit.layout.ContentPane");

dojo.addOnLoad(function(){
    // start dojo application
});

This code will work but sometimes will crash. Then you press F5 and all works.
As far as I know you can’t do nested onLoad callbacks with google (it’s a pity), so first you must load google api and load dojo components when google api is ready

So it’s better to use this other version of code:

google.load("dojo", "1.3");
google.load("feeds", "1");
google.setOnLoadCallback(function() {
    dojo.require("dijit.layout.BorderContainer");
    dojo.require("dijit.layout.TabContainer");
    dojo.require("dijit.layout.ContentPane");

    dojo.addOnLoad(function(){
        // start dojo application
    });

});

Speed up page load with asynchronous javascript

Filed under: Technology, Web Development — gonzaloayuso @ 1:13 pm

JavaScript an important part of or web applications. Normally or web is not usable until js is full loaded. Almost all js framework implements an event to notice when the js is ready (dojo.addOnLoad(); $(function() {});) and the page is usable. The page is usable when js is loaded. Sometimes if you are working with dojo you need all js and maybe is better to create an splash screen until all is loaded. But sometimes your app don’t need all js to be usable. I give you a example: I’ve been working in a project with jQuery. I load jQuery library from google cdn

<script type="text/javascript" src="http://www.google.com/jsapi?key=mygoogleApiKey"></script>
<script type="text/javascript">
    google.load("jquery", "1.3.2");
</script>

jQuery is mandatory. The site doesn’t work without this library.

google.setOnLoadCallback(function() {
    $(function() {
        // application code ...
    });
});

I want to put rss feeds of some blogs on the left bar of the application and I need to do it with js. I’m going to use google’s feed api to do it so:

<script type="text/javascript" src="http://www.google.com/jsapi?key=myGoogleApiKey"></script>
<script type="text/javascript">
    google.load("jquery", "1.3.2");
    google.load("feeds", "1"); // <-------------
</script>

And I call to the js function to populates RSS feed into google’s onready callback (setOnLoadCallback)

google.setOnLoadCallback(function() {
    initFeeds() // <-------------
    $(function() {
        // application code ...
    });
});

This version of code works but it has a problem. All application will not be usable until initFeeds ends. The fedds on the left bar are cool but the user don’t need them to use the application. It’s just a decoration so: why we force user to wait until feeds are loaded? The solution is quite simple. Put a timer to free the main js file and populate feed asynchronously

google.setOnLoadCallback(function() {
    setTimeout(initFeeds, 1000); <-------------
    $(function() {
        // application code ...
    });
});

April 10, 2009

fetching book cover with google API and dojo

Filed under: Technology, Web Development, dojo — gonzaloayuso @ 1:15 pm

I want to put the cover of one book into my dojo application. I can use amazon Web service but google API has a nice JSONP interface and also google API uses ISBN instead ASIN to fetch book info and for me is easier to know the ISBN (it is in the first page of every book).
I have a previous post explaining how to use use JSONP with javascript, but now I want to do the same in a dojo-way using dojo.io.script.get

dojo.io.script.get({
    url:"http://books.google.com/books?bibkeys=" + isbn + "&jscmd=viewapi",
    callbackParamName: "callback",
    load: dojo.hitch(this, function(booksInfo){googleCallback(booksInfo);})
});

And finally we are going to use booksInfo to to show our flaming cover:

googleCallback: function(booksInfo) {
        var div = dojo.byId('divId');
        div.innerHTML = '';
        var mainDiv = dojo.doc.createElement('div');
        var x = 0;
        for (i in booksInfo) {
            // Create a DIV for each book
            var book = booksInfo[i];
            var thumbnailDiv = dojo.doc.createElement('div');
            thumbnailDiv.className = "thumbnail";

            // Add a link to each book's informtaion page
            var a = dojo.doc.createElement("a");
            a.href = book.info_url;
            a.target = '_blank';

            // Display a thumbnail of the book's cover
            var img = dojo.doc.createElement("img");
            img.src = book.thumbnail_url + '&zoom=1';
            img.border = 0;
            a.appendChild(img);
            thumbnailDiv.appendChild(a);

            mainDiv.appendChild(thumbnailDiv);
        }
        div.appendChild(mainDiv);
}

Consuming external javascript services with Dojo

Filed under: Technology, Web Development, dojo — gonzaloayuso @ 12:56 pm

I want to include goggle’s GSbookBar in one dokjo application. Unfortunately this API doesn’t have a JSONP interface. I need to include one external js file and use GSbookBar object. It’s really simple but I want to so something different. The book bar appears only in one pop up of one tab in my application. It isn’t a main part so I don’t want to load the external script every time the user loads the application.

Dojo has dojo.io.script.get to load external scripts. Its a cool way to do the traditional:

var scriptElement = document.createElement("script");
scriptElement.setAttribute("id", "jsonScript");
scriptElement.setAttribute("src", "http://external/script.js");
scriptElement.setAttribute("type", "text/javascript");
document.documentElement.firstChild.appendChild(scriptElement);

dojo.io.script.get is an elegant way load external scripts. It provides us the same interface to consume JSONP and no-JSONP scripts. One important thing when we include some external js functionality in our projects is that we need to know when the external js script is loaded to use its functionality. To do it dojo.io.script.get fires load event. In scripts without JSONP interface dojo uses checkString. Dojo evaluates checkString
“typeof(” + checkString + “) != ‘undefined’ and fires load event when is loaded.

The trick I use to load external scripts is find one js object in the script and use it as checkString. In this example the checkString is GSbookBar js object

GSbookBar = undefined;
dojo.io.script.get({
    url:"http://www.google.com/uds/solutions/bookbar/gsbookbar.js?mode=new",
    checkString: "GSbookBar",
    load: dojo.hitch(this, function(){
    window._uds_bbw_donotrepair = true;
    var bookBar;
    var options = {
        largeResultSet : !true,
        horizontal : true,
        autoExecuteList : {
            cycleTime : GSbookBar.CYCLE_TIME_MEDIUM,
            cycleMode : GSbookBar.CYCLE_MODE_RANDOM,
            thumbnailSize: GSbookBar.thumbnailsSmall,
            executeList : [data.title, data.author]
        }
    }
    bookBar = new GSbookBar(this.bookBar, options);
    dialog.resize(); // hack because of a bug in dojo 1.3
    dialog.show();  // I have created dialog dijit widget previosly
})

March 29, 2009

Blog posts

Filed under: personal — gonzaloayuso @ 10:22 pm

virus letal

Filed under: Uncategorized — gonzaloayuso @ 10:17 pm

He recibido un aviso muy importante:

Si recibes una llamada al móvil, y en la pantalla aparece INVIABLE con DOS signos de exclamación (‘!!’): NO DESCUELGUES EL TELÉFONO, NI INTENTES RENUNCIAR A LA LLAMADA. Déjalo sonar hasta que pare, y después borra directamente la llamada perdida. Se trata de un virus muy potente que destruye por completo el mecanismo del teléfono: cuando esto pasa es imposible arreglarlo o tratar de encontrar una solución al problema.

Esto me parece el no vas. No solo es el virus mas destructivo del mundo mundial, sino que además te impide tratar de buscar una solución al problema.

Que Dios nos pille confesados.

March 23, 2009

killall firefox-bin

Filed under: Technology, Web Development — gonzaloayuso @ 7:48 pm

As a web developer firefox is my only choice. I need other browser to test my applications but I can’t live without firebug. I now there are other firebug-clone for other browsers but firebug is the number one.

But normally I have a console ready to type

killall firefox-bin

It’s really cool when one tab of your firefox becomes crazy and all firefox instance dies.Next generation of browsers will solve this problem. But at least now Chrome is not ready under Linux.

What can I do?, Only Cry? ;)

Older Posts »

Blog at WordPress.com.