education and CGO

How to save the planet

Actually, according to Marvin Minksy, the co-founder of┬áMassachusetts Institute of Technology’s Artificial Intelligence lab, who is according to some people ‘the smartest guy we know’, it won’t be too hard at all. All we have to do is wait 16 more years, after which solar technology will be so advanced and cheap that we can easily use all that solar energy to power the world.

Of course it doesn’t hurt to start now, but according to Marvin solar energy advances follow the law of Moore (not More, Moore). Moore says every 2 years computers will be twice as fast and twice as powerful. So far that has been true for over 30 years.

The video below is hilarious but at the end gets a little more serious…

(This is a Blog Action Day post)

Blog Action Day

Excellent resource for IE6 bug solving

http://www.virtuosimedia.com/tutorials/ultimate-ie6-cheatsheet-how-to-fix-25-internet-explorer-6-bugs

A dead simple, lightweight javascript calendar

calendar-size-badgeI recently needed a good light weight javascript calendar but couldn’t find it. The problem is that online I could find many calendars, but they all suffered from one of two problems: they were either too heavy, or they were badly written (aka coding like it’s 1999).

I hereby present a very lightweight javascript calendar object. It can be used anywhere where you need to select a date.

It features the following:

  • no library. That’s right, it does NOT use mootools, it does NOT use jQuery.
  • clean code. Yes it can be improved, but that would make it a heavy calendar again.
  • it does not do Date magic. If you want date magic I can recommend date.js. (oh, and that means things like ‘3 days ago’ etc.)
  • it’s lightweight, mainly because it doesn’t do magic and it doesn’t have a library. It’s 2K uncompressed, 1.5K using dean edwards packer.
  • no popup windows. All

Download

Download mbcalendar 1.0

Usage

var cal = new MBCalendar('inp', 'btn', 'click');

Where

  • inp is the id of the input that will be retrieving the calendar, and
  • btn is the id of the element that will trigger the calendar to show, and
  • click is the name of the event that will trigger the calendar
  • in the onload script, in this example ‘out’ is the id of the element that will hold the calendar.

This way it can be used as a date picker, but it can also be used as a visible calendar with navigation (static). Basically the output is simply the HTML, so you can use it anywhere.

All dates van be individually styled, since they all get a unique id. Also all dates get class names so you can style either a certain year, month, or day of the month. E.g. ‘.y2009’ will style every date in 2009, ‘.m3’ will style every march, and ‘.y2009.m3’ will style every day in March, 2009.

Source code

Now for the code

/*(c) Michiel van der Blonk 2009 - license: http://www.opensource.org/licenses/mit-license.php*/

function MBCalendar(m, y)
{
this.m = m;
this.y = y;
this.weekDays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
}

MBCalendar.prototype.$ =  function(s) {return document.getElementById(s)};

// export as array
MBCalendar.prototype.toArray = function() {
var d;
var dates = [];
for (var i=1;i<32;i++)
{
d = new Date(this.y,this.m-1, i);
if (d.getMonth() == this.m-1)
dates.push(d);
}
return dates;
};

// export as html
MBCalendar.prototype.toHTML = function() {
var i;
var ret, dayId, dayClass;
ret = dayId = dayClass = '';
var dates = this.toArray();
ret += '
<table class="cal">' + '
<tr>';
for (i in [0,1,2,3,4,5,6])
ret += '
<th>' + this.weekDays[parseInt(dates[i].getDay())].substr(0,1) + '</th>
';
ret += '</tr>
<tr>';
for (i in dates)
{
var d = dates[i];
if ((parseInt(i) % 7) == 0)
ret += '</tr>
';
if ((parseInt(i)+1 % 7==0) && i<dates .length)
ret += '
<tr>';
dayClass = 'y'+d.getFullYear() + ' m' +(d.getMonth()+1) + ' d' + d.getDate();
dayId = 'day-' + parseInt(d.getTime()/86400000);
ret += '
<td id="' + dayId + '" class="' + dayClass +'">' + dates[i].getDate() + '</td>
';
}
ret = ret + '</dates></table>
';
return ret;
};

window.onload = function() {
var $ = function(s) {return document.getElementById(s)};
var c;
$('showCal').onclick = function() {
var y = $('year').value;
var m = $('month').value;
c = new MBCalendar(m, y);
$('out').innerHTML = c.toHTML();
};
$('prev').onclick = function() {
var d = new Date(c.y,c.m-2,1);
c = new MBCalendar(d.getMonth()+1, d.getFullYear());
$('out').innerHTML = c.toHTML();
}
$('next').onclick = function() {
var d = new Date(c.y,c.m,1);
c = new MBCalendar(d.getMonth()+1, d.getFullYear());
$('out').innerHTML = c.toHTML();
}
};

If you like you can integrate the prev, next and show methods in the Calendar object itself of course. I invite all javascript experts to crunch the code even more, without making it unreadable!

If you don’t integrate that code, you will need to add some standard HTML in a page to get a functional Calendar demonstration:

<input type="text" id="year" value="" />
<input type="text" id="month" value="" />
<button type="button" id="showCal">Show Calendar</button>
<button type="button" id="prev">prev</button>
<button type="button" id="next">next</button>

Some alternative calendars you might like:

update: there was still some debug code in there, it’s removed now. Also it seems wordpress messes up the code when I paste it. Change line 16 to have the ‘<‘ char instead of &lt;

Awesome list of mootools resources

Check that out, if ever I need anything mootools I will find it here.

http://www.w3avenue.com/2009/07/28/list-of-really-useful-plugins-and-resources-for-mootools/

Safe Drinking Water For Everyone, I mean Everyone

Orion graduated

Now all he needs to learn is to listen to Mom and Dad. For the rest all is going fine. Too bad he can’t do his acrobatic stunts at school (they say it’s too dangerous).

We didn’t bring a camera, I forgot it while rushing out. Stupid. But we may get some pics from the other parents.

The teacher gets an F for spelling (Orion v/d Blok?)

The accomplishment:

diploma-orion-lillyputters

5 breakthrough technologies that will go mainstream in 5 years

This is my list of 5 technologies that you probably don’t know about yet, and that will go mainstream in less than 5 years. I’d like to check back here in 5 years to see just how right (or wrong) I am.

1. Online rendered games

OTOY delivers server based live rendering. That is a cool thing that can enable live playing of console games that you don’t own. Of course it can also be used more professionally by e.g. architects and film makers.

video

2. Peer to peer hosting

Opera recently announced Opera Unite, their server-less website technology. Although it may not be Opera itself that brings this mainstream, it will certainly change the world. Currently websites are all hosted and delivered by servers not owned by ourselves. The middleman known as ISP will always be in between, charging for services, blocking stuff at will, and basically controlling our behavior on the internet. We (that is everyone) don’t like this, and it needs to change. P2P (peer-to-peer) technology like BitTorrent is key to this, but only supports file sharing. What is needed is web-sharing. Opera Unite is still very beta and techie, but once a “publish button” is available, that could well change. You don’t need Flickr to share pictures with friends, really. But we do need powerful technology like PHP, Java, .NET to be integrated. Javascript alone doesn’t make for the most interesting sites.

3. Augmented reality

It will take a bit longer than just software, but the world is advancing fast to a point where we can start using this. Simply glasses with small screens on the inside will work. GPS in your phone and netbook help to render relevant scenes laid over the exact location you are at. “Assisted reality” may be the first step: point your phone to a product and see it’s specifications, price comparison etc directly on your phone’s screen.

Wikipedia article

4. Flexible displays

This is another one that I envision to arrive on the market soon (a couple of years). You just roll up your e-reader, or roll it out of your netbook. It’s already for sale.

5. Online software development

Sites like topcoder, guru, but especially oDesk will become the trend. But the people you hire will not be unknown to you. Through social networking, virtual presence and web cams they will be much more part of the company then just outsiders. This will require a change in culture though. Currently people are quite ‘scared’ of showing their face to someone on the other side of the Ocean. But just like social networking it will grow quickly.

Things that will go unnoticed

  • social networks – ok, they’ve already made it, but they will not change drastically, and you notice a fatigue starting in everyone who has had the facebook rush for a while. The close circle of friends will continue, but 900 friends? C’mon. Facebook/twitter will end up in Google’s or Microsofts hands anyway.
  • Google wave – It’s the marriage of IM, picture album, bulletin board and email. I believe it actually will take over as the next version of GMail, but it will not be much more than that.
  • Wolfram Alpha – one of the latest hypes. Ultimately just one of the places people may go to to find answers. Will probably be bought by Google anyway.

I had no place for it on the list, and it may take more then 5 years, but solar power will also make it, eventually (within 10 years).

TypePad AntiSpam