6/25/08

Label cloud for blogger

I have nothing against Blogger's label widget, but I think label clouds are a better visualization for that matter. After searching around I came across phydeaux3 tag clouds. Based on that, I built my own widget for this blog. You can try it here. Type some words inside the box and click the 'create' button. You can also specify the colors you want for bigger and smaller words. Type them in hexadecimal format, without the # sign.


Big words color: #

Small words color: #


You can see the code on the source of this page (if you have javascript enabled, you'll see my label cloud on the sidebar. If not, you'll see the standard label widget). Or you can have the code here:

function cloudify(element_id, elements, options) {
  eReplace = $(element_id);
  var min_oc = null;
  var max_oc = null;
  var labels = elements;
  labels.each(function(e) {
    if(!max_oc || e[0] > max_oc){ max_oc = e[0] }
    if(!min_oc || e[0] < min_oc){ min_oc = e[0] }
  });
  if(min_oc == max_oc){ max_oc++ } // To prevent a divide by zero error
  var min_font_size = options['min_font_size'] || 10;
  var max_font_size = options['max_font_size'] || 30;
  var text = "";
  var log_min_oc = Math.log(min_oc);
  var log_max_oc = Math.log(max_oc);
  var log_diff = log_max_oc - log_min_oc;
  var start_color = stringToColorArray(options['start_color']||'B47B10');
  var end_color = stringToColorArray(options['end_color']||'006600');
  var link_start = "";
  var link_end = "";
  var link_href = function(e){return ""};
  if(options['includes_link']){
    link_start = "><a ";
    link_end = "</a>";
    link_href = function(e){return 'href="' + e[2] + '"'};
  }
  labels.each(function(label) {
    var w = (Math.log(label[0]) - log_min_oc) /(log_max_oc - log_min_oc);
    text = text + '<span' + link_start + ' style="font-size:' +
      String(min_font_size + Math.round((max_font_size - min_font_size) * w)) +
      'px; color:#' + 
      colorArrayToString([0, 1, 2].map(function(i){
        return start_color[i] + Math.round((end_color[i] - start_color[i]) * w);
      })) +
      '" ' + link_href(label) + '>' +
      label[1] + link_end + "</span> ";
  });
  eReplace.update(text);
}
Where elements is an array with element of the form [count, label] and a third element: the link of each label if specified in the options.

Anyway, is a very quick-and-dirty version, if you are interested on it and have troubles, drop a comment.

6/23/08

Google Developer's Day Mexico 2008

Today I attended at Google Developer's Day Mexico 08. To my understanding, it is the first time such event is done here in Mexico, and Google people did a nice work.

The first couple of hours John Farrell (Google Mexico's director) and Alfonso Luna (Marketing director for Latin America) besides giving us an overview of the event they clearly stated the intentions not only for the workshop, but for the Google developers in general.

It is well known that times are changing and the Internet is positioning as one of the most ubiquitous, important mass medium, yet the communication, use and business paradigm is totally different to 'traditional' media such as radio or TV. Internet, unlike the others, is a dynamic medium, in which the most important thing is not the hardware or the infrastructure per se, but the content. Concepts like shared market and 'the long tail' are playing an important role in their business paradigm.

John described us Google as an ecosystem, in which sponsors, partners, content providers, developers and users interact in complex manners. Google's mission may be ambitious, but the truth is that its worldwide presence is something we should be aware of. And we, as developers, are part of this game. So Google has been developing a set of Open Source tools and engines to help developers, in such way we can develop quick, good and cheap. Is a win-win deal.

The rest of the day we were offered a set of conferences and workshop specific to the Google technologies, split by interests (it would be impossible to cover all of them in just one day). The complete agenda can be checked here (I couldn't find an English translation, bear me). Google gears, Google Web Toolkit, OpenSocial, Android, Google App Engine and KML were just some of the topics covered on the workshops, I will be posting about them and my experiences on later posts.

It was an overall nice event, I hope Google to put its eyes on Mexico since I am sure there are lots of good developers that can be a force to be reckoned with.

6/21/08

RubyWeekend game contest - Yarr Blaargh!

Pirates vs. Zombies. That's the main theme of my game, and also the theme of the first RubyWeekend game contest.

It was an interesting contest in which there was only a slightly more than 48 hours to make a themed game. The platform and implementation was free, just it had to be written in Ruby. Among the options available (this presentation contains lots of options for making a game in Ruby) I picked Rubygame.

I have used Gosu before, which is a nice platform. But I wanted to give a try to Rubygame. Both libraries are very similar, maybe Gosu wraps in a little higher level events and sprite manipulation, but Rubygame is very flexible and efficient.

The game is called Yarr Blaargh. After all, what else would you expect to hear in a pirates vs. zombies battle? You can check the code here, altough in 48 hours I had not enough time to finish it, so you will see an incomplete project by now. Perhaps in the next weeks I can polish the details of the game.

6/19/08

Two of sugar, please!

They say coffee and Red Bull. Occasionally vodka.

Oh, yes, but sometimes they forget to make their beds! Not that they are using them very often, programming 'till 4:00 a.m. is funny. They forget to eat and to sleep. And they forget to put sugar on their coffees.

Programmers are not (always) a console terminal. Real world is more than lines of code.

They are programmers. We are programmers. Nerds, and dreamers.