Monthly Archives: December 2011

A message from Wikipedia

Source: Wikipedia

From Wikipedia author Aniruddha Kumar

I can speak Hindi, Urdu, English, Sanskrit and Moroccan. But I can’t read what’s on my computer screen.

Being blind online means I have to listen to all the text — including ads. That’s one of the reasons I rely on Wikipedia so much. It doesn’t waste my time by making me sit through advertising like almost every other website.

Wikipedia is one of the most beautiful things in the world. It takes the concept that everyone has a basic right to information and makes it into something real — a tool that’s free for anyone to access, even blind people like me, and completely neutral.

When I first found out about Wikipedia — that I could be part of this amazing collective project — I knew I wanted to contribute. And I’m asking you to join me.

Will you support Wikipedia with a gift of $5, €10, ¥1000 or whatever you can afford?

Wikipedia gets almost as many visitors as huge sites like Google and Facebook, but it operates on a tiny fraction of their resources. And it depends entirely on donations from readers like you.

Instead of ads, Wikipedia has a community of millions of volunteer editors double-checking every word and citation. I’m so grateful for them – their work makes learning online possible.

The philosophy of Wikipedia is to make a sea from drops. And it applies to everyone who contributes, whether a few edits or a few dollars.

Thank you,

Aniruddha Kumar
Wikipedia Author

The message says it all. Most of the time, web pages are filled with advertisement. It only make us annoying, but with Aniruddha, it cause a lot of problems.

And I also hope for a free Wikipedia.

A quick experiment on HTML5 Canvas


/** Vietnamese: một thử nghiệm nhỏ lên trang canvas của HTML5 **/

HTML5 is out for a while, and many people have already play with it. Inspired by the great article here, I managed to make a simple dirty experiment.

<!DOCTYPE html>

<html lang="en">


    <title>Good night</title>


  <body><script type="text/javascript">
  if ( !window.requestAnimationFrame ) {

    window.requestAnimationFrame = ( function() {

      return window.webkitRequestAnimationFrame ||
      window.mozRequestAnimationFrame ||
      window.oRequestAnimationFrame ||
      window.msRequestAnimationFrame ||
      function( /* function FrameRequestCallback */ callback, /* DOMElement Element */ element ) {

        window.setTimeout( callback, 800 / 60 );


    } )();

</script><script type="text/javascript">
var canvas, context;
var xx = new Array();
var yy = new Array();
for (var i = 0; 40 > i; i++) {
   xx[i] = Math.random()*600;
   yy[i] = Math.random()*150;

function init() {
  canvas = document.createElement( 'canvas' );
  canvas.width = 600;
  canvas.height = 400;
  context = canvas.getContext( '2d' );
  document.body.appendChild( canvas );
function animate() {
  requestAnimationFrame( animate );
function draw() {
  var time = new Date().getTime() * 0.001;
  var x = Math.cos( time ) * 250 + 300;
  var y = Math.sin( time ) * 250 + 300;
  if(150 >= y) {context.fillStyle = 'rgb(250,250,250)';}
  else {
    if (200 >= y) {
    } else {
      context.fillStyle='rgb(14, 14, 14)';
  context.fillRect( 0, 0, 600, 400 );
  context.fillStyle = 'rgb(255,255,0)';

  context.arc( x, y, 15, 0, Math.PI * 2, false );
  context.fillStyle = 'rgb(0,0,255)';
  context.fillRect(0, 215, 600, 400);
   for (var i = 0; 15 > i; i++) {
      context.fillStyle = 'rgb(255,255,255)';
      context.arc(xx[i], yy[i], 1, 0, Math.PI * 2, false );
      if (y > 200) {
          if (Math.floor(time) % 2 == 0) {
            context.fillStyle = 'rgb(255,255,255)';
            context.arc(xx[i], yy[i] + 215, 1, 0, Math.PI * 2, false );
          } else {
            context.fillStyle = 'rgb(255,255,255)';
            context.arc((yy[i] / 150) * 600, (xx[i] / 600)*150 + 215, 1, 0, Math.PI * 2, false );

You can view the example online here.

Free ads: thanks for the start-up Handcraft for letting me quickly “craft” this product.

Quick note on Java time

The analog timer, From
One of the things I dislike most in Java is… unfriendly. DateTime manipulation is a typical example. I think at least one time, a Java developer will encounter this message: getYear() is deprecated.

Such a simple and often-heavily-used function is deprecated. So programmers must walk around by the Calendar class.

Calendar localCalendar = Calendar.getInstance();
Calendar utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
Date date = new Date();

TimeZone localTimeZone = localCalendar.getTimeZone();

System.out.println("Year: " + localCalendar.get(Calendar.YEAR));
System.out.println("Month: " + localCalendar.get(Calendar.MONTH) + 1);
System.out.println("Day: " + localCalendar.get(Calendar.DATE));
System.out.println("Day of week: " + localCalendar.get(Calendar.DAY_OF_WEEK));
System.out.println("Hour: " + localCalendar.get(Calendar.HOUR_OF_DAY));
System.out.println("Minute: " + localCalendar.get(Calendar.MINUTE));

System.out.println("Timezone: " + localTimeZone.getDisplayName());
System.out.println("UTC Hour: " + utcCalendar.get(Calendar.HOUR));
System.out.println("UTC Minute: " + utcCalendar.get(Calendar.MINUTE));

Although Java big heads all have valid reasons for this inconvenience – which is the complexity of time manipulation, I still think this way is over-killing. Yes, no computer is accurate enough to calculate the correct solar time. But we are no astronomy expert, who cares if the time lacks one or two leap seconds*? Daylight saving stuffs is still necessary, but shouldn’t be too much of a problem.

In the end, I think Java powerful libraries should also make it easy to do simple tasks, instead thinking ahead too much for easy enlargement later**. With the Internet as popular as today, I think we can safely calculate “simple” time only, leaving the task to do additional astronomy calculation for the big servers, and cover the gaps by synchronizing.

(*) Like leap year, a leap second is sometimes added to our current timeline to cover the gaps between solar year & normal year. Because a leap second is too small,  people seldom notice. Reference:

(**) Java has the reputation for easy scaling, and this is very true in my experience. On the opposite, small application is suddenly heavy at their very first cradle time, because a fair amount of efforts are put in “making room” for future changes.