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 then 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

Stack Overflow

  • if you cannot find it here, you cannot find it anywhere. StackOverflow is a site by programmers for programmers. Try to answer one of those questions, they’re hard.

my second first ping.fm message

checking out http://ping.fm

my first ping.fm message

this is my first http://ping.fm message

Automating science itself

Finding laws of nature is not really a creative process.. It’s merely extracting the rules that are embedded in nature. It’s no surprise that now somebody came up with a way to automate finding the laws of nature…

check it out:
http://www.guardian.co.uk/science/video/2009/apr/02/eureka-machine-artificial-intelligence

10 worst Microsoft Excel practices

tableI have met a lot of people who know they ‘know’ Excel, even sometimes stating they are experts of some sort. Well, they were not, and I could usually spot it because they make one of the following ‘mistakes’. Of course they get the job done, but in the long run they usually got themselves into trouble with it. I used to be such a person myself, until I became a full time Excel and VBA trainer.

So here it goes, starting with the worst:

1. Using tables

Tables (like years on the left column months on the top row) are nice for a visual report, but the data cannot be used in any other way. If you’ve read my recent article about the TableToListConverter, you know why. Excel is an excellent analyzer of data, as long as this data is organized in rows (lists), much like a database.

2. Using cell references

Don’t you hate those formulas like =C1*B6-H3+F5?. They’re horrible to work with. Wouldn’t it be easier to see =Rate*Hours-Discount+ExtraCost?
Well, that’s possible. Just click on the C1 in the top left corner and type the name ‘Rate’, then press Enter. From then on, C1 has an alias of ‘Rate’, and you can use it in formulas.

3. Using too many worksheets

Again too many people use too many worksheet. As above in #1, they create Worksheets named ‘jan’, ‘feb’, ‘mar’, ‘apr’ and so on. Later on it will become very difficult to get totals or filter this data. Forget about multiple worksheets and put everything in one sheet, as long as the data belongs together of course.

4. Using color to indicate meta data

Using a color to indicate something is great if you are the only person using the Excel file. That is hardly ever the case. You would have to explain: ‘well, red means this row is to be deleted, yellow means it’s not checked, and green means it is checked’. That’s nice, thank you, but the sheet looks butt ugly, and if I print this on black and white all that information is suddenly lost.

The correct way to indicate this information is to add another column or more columns next to your data. Give them descriptive heading values, like ‘deleted, checked’. Notice yellow and green can simply be combined by putting yes or no in the ‘checked’ column.

And did you know about the conditional formatting feature? Based on a value or even a formula you can color or format a cell. But, make sure to only do that for formatting that doesn’t relate to valuable information you should have visible in your sheet. It’s a good feature though for e.g. zebra-stripes (odd rows colored different from even rows).

5. Copy & Paste

Using copy and paste is fine, as long as you don’t copy when you don’t need to. A simple cell reference will point to value without needing a copy. So if you have a price in a C1 in one worksheet, and need it somewhere else, use =C1, or of course =Rate (see #2 in this list). Another way, which even works for many cells, is go to ‘Edit > Paste Special > Paste Link’.

6. Bad formatting

Excel is good at formatting data automatically, if you insert it in the ‘right’ way. E.g. try typing ‘1-1′ and instead of ‘0′ you will get ‘1-jan’ depending on your date format. So the value is automatically converted to a date value. If you would type ‘January 1, 2009′, most likely Excel won’t recognize this and leave it as a text value. You cannot calculate with text values, but you can with Date values. So if A1 has ‘1-jan’, and B1 has =A1+1 then B1 will become ‘2-jan’.

7. Too complex formulas

Of course, some formulas actually are quite complex, there’s no doubt about it. But there’s no need to make them look complex. Split your formulas in multiple parts, and use named ranges. So instead of =Rate * Hours - Disount + ExtraCost you can use =Rate * Hours in the Amount field and =Amount - Discount + ExtraCost in the Total field.

8. Empty rows and columns

Empty rows are inserted to ‘make a sheet look nice’. However, by splitting e.g. January data and February data this way, Excel will assume you are dealing with two lists, not with one. The totals underneath using autosum will therefor work only on one of these sets. If you wish to have a bit more space, just drag the row height handle, or use Format > Row > Height to set a specific height.

9. Formatting for print

If you enlarge a font to make it look bigger on paper, you are making a mistake. Do it using File > Page Setup > Adjust to

You can adjust to any size without changing the font. The same goes for displaying on the screen in fact. Use View > Zoom, or use the percentage dropdown box in the formatting toolbar.

10.  Not using Pivot Tables.

I intentionally name it this way, since there are so many bad ways of analyzing data, getting totals, count, average and more on a set of data. But there’s only one way to do it extremely efficient, powerful and it brings lots more uses with it. Also, it keeps your data separate from your analysis. It’s called a pivot table. Make sure to have a list of data rows with headings, and then choose Data > Pivot Table. Now just click Finish right away instead of following the wizard. You can now drag in column heading names and be presented with a table with totals.

There’s so much you can do with a pivot table I am going to leave it to Microsoft to explain.

A very practical use of Pivot Tables is e.g. to get only unique values for a certain row. Since these are automatically grouped in a pivot table, you can simply copy and paste the list of unique values from there.

How to shuffle an array

This is a very common programming problem, e.g. when you wish to show some images in random order, when you want to show a random quote, etc. I will show you a solution in JavaScript, but it can be ported to other languages easily.

The common solution to shuffling is to swap random elements, but swapping means you have to constantly work with two elements, and it can be done by using only one. Also, it’s common to randomly swap e.g. 1000 elements, but that wouldn’t work well for very large arrays.

All you have to do is follow a couple of simple steps:

  1. First, of course you start with a simple array, which you have in a specified order.
  2. You place a random element in the output array, and remove the element
  3. Repeat step 2 until the array is empty

Here’s the full code


function shuffle(r) {
	var pos;
	var out = [];
	while (r.length > 0)	{
		pos = parseInt(Math.random()*r.length);
		out.push(r[pos]);
		r = r.slice(0,pos).concat(r.slice(pos+1, r.length));
	}
	return out;
}

Let’s examine the parts. First, the variables pos and out are defined, and out is initialized to an empty array.


	var pos;
	var out = [];

No we “loop” through the array. But, do note that this is not a real loop, in fact we’re constantly going to remove elements until the array is empty. So the simple check on length is enough here.


	while (r.length > 0)	{

We find a random element. For large arrays the Math.random() method can be considered unreliable, but then I mean really large.


		pos = parseInt(Math.random()*r.length);

Next, we add the random element to the output array, using push. Then we remove the element from the original array. This is done in three parts:

  1. get everything on the left of the element
  2. get everything on the right of the element
  3. concat these two arrays to form a new array

That is a really difficult way of removing just one element, but deleting an element from an array is not a native javascript method. John Resig wrote another version of delete


		out.push(r[pos]);
		r = r.slice(0,pos).concat(r.slice(pos+1, r.length));

And last but not least we return the new array:


	}
	return out;
}

Example

Here’s an example of calling the function, shuffling 52 integers


var r=[];
i=52;
while (i--)
	r.push(i);
alert(shuffle(r).join(','));

Extending Array

If you feel so inclined you can make it an extension of the Array object in javascript, like so:


Array.prototype.shuffle = function() {
	var r=this;
	... //rest of code
}

Note the additional "r=this" line.

Drawbacks

There are some drawbacks and warnings to take note of:

  • It can be slow for huge arrays, I would recommend it for arrays under 1000 items
  • It takes up additional space, since it creates a new array
  • The delete can be improved, by using e.g. John Resig’s version

A shorter ‘hack’

The following is a short hack that can most definitely suit one time needs. It’s a form of sorting randomly, which sounds weird, and it is, but it works. However, if the random value is not seeded again, the next time you run it you end up with the exact same sequence.


function shuffle(r) {
  r.sort(function() { return Math.random() } );
}

For more background see e.g. the Fisher Yates shuffle method (which by the way this is not, but this is).

Javascript floating point fix

Javascript has an annoying bug feature, and it’s the wrong result of simple floating point calculations. Try this:


alert(0.1+0.2);

Surprise! The result is 0.30000000000000004.

This can be quite annoying when programming timers, and doing math of course.

Why is this? It’s because floating points work that way, it’s by design. That’s not really a flaw, it’s just to make the process real fast. Just like your pocket calculator has only 8 digits, which isn’t wrong per se, but it’s never fully mathematically correct. Sun Microsystems has some real hardcore background on the floating point issue.

But for us simple programmers, all we want is a fix, right?

Here is one at lars-sh.de. Or download the Math Library directly. Kudos to Lars Knickrehm.

Next Page »